From 34cbae5213eb09299f544b225252e93bf6653d28 Mon Sep 17 00:00:00 2001 From: Daniel Morrison Date: Tue, 16 Apr 2019 19:26:34 -0400 Subject: [PATCH] Flake8 cleanup --- chevron/renderer.py | 5 +++-- test_spec.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/chevron/renderer.py b/chevron/renderer.py index 43e97dc..80c0681 100644 --- a/chevron/renderer.py +++ b/chevron/renderer.py @@ -68,13 +68,14 @@ def _get_key(key, scopes): try: # Try the dictionary (Complex types) scope = scope.__dict__[child] - except: + except (TypeError, AttributeError): # Try as a list scope = scope[int(child)] # Return an empty string if falsy, with two exceptions # 0 should return 0, and False should return False - if scope is 0: + # While using is for this check is undefined it works and is fast + if scope is 0: # noqa: F632 return 0 if scope is False: return False diff --git a/test_spec.py b/test_spec.py index 72ef263..9030ce0 100755 --- a/test_spec.py +++ b/test_spec.py @@ -120,7 +120,9 @@ class ExpandedCoverage(unittest.TestCase): def test_missing_key_partial(self): args = { 'template': 'before, {{> with_missing_key }}, after', - 'partials_dict': {'with_missing_key': '{{#missing_key}}bloop{{/missing_key}}'} + 'partials_dict': { + 'with_missing_key': '{{#missing_key}}bloop{{/missing_key}}', + }, } result = chevron.render(**args) @@ -363,7 +365,7 @@ class ExpandedCoverage(unittest.TestCase): 'template': 'count {{count.0}}, {{count.1}}, ' '{{count.100}}, {{nope.0}}', 'data': { - "count": [5,4,3,2,1], + "count": [5, 4, 3, 2, 1], } } -- 2.47.3