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
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)
'template': 'count {{count.0}}, {{count.1}}, '
'{{count.100}}, {{nope.0}}',
'data': {
- "count": [5,4,3,2,1],
+ "count": [5, 4, 3, 2, 1],
}
}