Michael Merickel
2018-10-26 25737fd6a412f4fe9b780305c0260bb6e938be1b
fix new lint errors from flake8
4 files modified
26 ■■■■■ changed files
.flake8 2 ●●●●● patch | view | raw | blame | history
src/pyramid/scripts/pcreate.py 2 ●●● patch | view | raw | blame | history
tests/test_scaffolds/test_template.py 10 ●●●● patch | view | raw | blame | history
tests/test_urldispatch.py 12 ●●●●● patch | view | raw | blame | history
.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
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
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
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'})