whitelist a bandit false positive and improve type annotation

This commit is contained in:
Anthony Sottile 2019-05-19 09:38:48 -07:00
parent 89b0bb87d7
commit dcd37ec3d4
2 changed files with 6 additions and 6 deletions

View file

@ -385,11 +385,11 @@ def token_is_newline(token):
def count_parentheses(current_parentheses_count, token_text):
# type: (int, str) -> int
"""Count the number of parentheses."""
current_parentheses_count = current_parentheses_count or 0
if token_text in "([{":
if token_text in "([{": # nosec
return current_parentheses_count + 1
elif token_text in "}])":
elif token_text in "}])": # nosec
return current_parentheses_count - 1
return current_parentheses_count

View file

@ -337,9 +337,9 @@ def test_log_token(token, log_string):
@pytest.mark.parametrize('current_count, token_text, expected', [
(None, '(', 1),
(None, '[', 1),
(None, '{', 1),
(0, '(', 1),
(0, '[', 1),
(0, '{', 1),
(1, ')', 0),
(1, ']', 0),
(1, '}', 0),