From 035f6cf8238211d097c991677fde6b5bc046a57b Mon Sep 17 00:00:00 2001 From: Michael Merickel <github@m.merickel.org> Date: Fri, 26 Oct 2018 02:58:42 +0200 Subject: [PATCH] Merge pull request #3400 from mmerickel/flake8-errors --- tests/test_scaffolds/test_template.py | 10 +++++----- src/pyramid/scripts/pcreate.py | 2 +- .flake8 | 2 ++ tests/test_urldispatch.py | 12 +++++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.flake8 b/.flake8 index f8da47c..958f8f9 100644 --- a/.flake8 +++ b/.flake8 @@ -6,6 +6,8 @@ E731 # W503: line break before binary operator (flake8 is not PEP8 compliant) W503 + # W504: line break after binary operator (flake8 is not PEP8 compliant) + W504 exclude = src/pyramid/compat.py src/pyramid/scaffolds/alchemy diff --git a/src/pyramid/scripts/pcreate.py b/src/pyramid/scripts/pcreate.py index 9022590..ee3c60e 100644 --- a/src/pyramid/scripts/pcreate.py +++ b/src/pyramid/scripts/pcreate.py @@ -266,7 +266,7 @@ try: # use absolute imports __import__(pkg_name, globals(), locals(), [], 0) - except ImportError as error: + except ImportError: pkg_exists = False if not pkg_exists: return True diff --git a/tests/test_scaffolds/test_template.py b/tests/test_scaffolds/test_template.py index d9a2dfa..fc6b9f3 100644 --- a/tests/test_scaffolds/test_template.py +++ b/tests/test_scaffolds/test_template.py @@ -46,23 +46,23 @@ def test_render_template_with_escaped_double_braces(self): inst = self._makeOne() result = inst.render_template( - '{{a}} {{b}} \{\{a\}\} \{\{c\}\}', {'a': '1', 'b': '2'} + '{{a}} {{b}} \\{\\{a\\}\\} \\{\\{c\\}\\}', {'a': '1', 'b': '2'} ) self.assertEqual(result, bytes_('1 2 {{a}} {{c}}')) def test_render_template_with_breaking_escaped_braces(self): inst = self._makeOne() result = inst.render_template( - '{{a}} {{b}} \{\{a\} \{b\}\}', {'a': '1', 'b': '2'} + '{{a}} {{b}} \\{\\{a\\} \\{b\\}\\}', {'a': '1', 'b': '2'} ) - self.assertEqual(result, bytes_('1 2 \{\{a\} \{b\}\}')) + self.assertEqual(result, bytes_('1 2 \\{\\{a\\} \\{b\\}\\}')) def test_render_template_with_escaped_single_braces(self): inst = self._makeOne() result = inst.render_template( - '{{a}} {{b}} \{a\} \{b', {'a': '1', 'b': '2'} + '{{a}} {{b}} \\{a\\} \\{b', {'a': '1', 'b': '2'} ) - self.assertEqual(result, bytes_('1 2 \{a\} \{b')) + self.assertEqual(result, bytes_('1 2 \\{a\\} \\{b')) def test_module_dir(self): import sys diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py index 57f81b5..772250e 100644 --- a/tests/test_urldispatch.py +++ b/tests/test_urldispatch.py @@ -346,7 +346,9 @@ self.assertEqual(generator({'baz': 1, 'buz': 2}), '/foo/1/biz/2/bar') def test_custom_regex(self): - matcher, generator = self._callFUT('foo/{baz}/biz/{buz:[^/\.]+}.{bar}') + matcher, generator = self._callFUT( + 'foo/{baz}/biz/{buz:[^/\\.]+}.{bar}' + ) self.assertEqual( matcher('/foo/baz/biz/buz.bar'), {'baz': 'baz', 'buz': 'buz', 'bar': 'bar'}, @@ -358,7 +360,7 @@ def test_custom_regex_with_colons(self): matcher, generator = self._callFUT( - 'foo/{baz}/biz/{buz:(?:[^/\.]+)}.{bar}' + 'foo/{baz}/biz/{buz:(?:[^/\\.]+)}.{bar}' ) self.assertEqual( matcher('/foo/baz/biz/buz.bar'), @@ -379,13 +381,13 @@ self.assertEqual(generator({'baz': 1, 'buz': 2}), '/foo/1/biz/2/bar') def test_custom_regex_with_embedded_squigglies(self): - matcher, generator = self._callFUT('/{buz:\d{4}}') + matcher, generator = self._callFUT('/{buz:\\d{4}}') self.assertEqual(matcher('/2001'), {'buz': '2001'}) self.assertEqual(matcher('/200'), None) self.assertEqual(generator({'buz': 2001}), '/2001') def test_custom_regex_with_embedded_squigglies2(self): - matcher, generator = self._callFUT('/{buz:\d{3,4}}') + matcher, generator = self._callFUT('/{buz:\\d{3,4}}') self.assertEqual(matcher('/2001'), {'buz': '2001'}) self.assertEqual(matcher('/200'), {'buz': '200'}) self.assertEqual(matcher('/20'), None) @@ -393,7 +395,7 @@ def test_custom_regex_with_embedded_squigglies3(self): matcher, generator = self._callFUT( - '/{buz:(\d{2}|\d{4})-[a-zA-Z]{3,4}-\d{2}}' + '/{buz:(\\d{2}|\\d{4})-[a-zA-Z]{3,4}-\\d{2}}' ) self.assertEqual(matcher('/2001-Nov-15'), {'buz': '2001-Nov-15'}) self.assertEqual(matcher('/99-June-10'), {'buz': '99-June-10'}) -- Gitblit v1.9.3