Skip to content

Commit

Permalink
Remove TODOs in unused-variable tests (#6162)
Browse files Browse the repository at this point in the history
Further discussion suggested making no changes (one warning per name per scope).
  • Loading branch information
jacobtylerwalls committed Apr 3, 2022
1 parent a93602d commit 0880d95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
13 changes: 5 additions & 8 deletions tests/functional/u/unused/unused_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def hello(arg):
return True
raise Exception

# pylint: disable=redefined-outer-name, wrong-import-position,misplaced-future
# pylint: disable=wrong-import-position,misplaced-future
from __future__ import print_function
PATH = OS = collections = deque = None

Expand Down Expand Up @@ -94,6 +94,7 @@ def test_global():
""" Test various assignments of global
variables through imports.
"""
# pylint: disable=redefined-outer-name
global PATH, OS, collections, deque # [global-variable-not-assigned, global-variable-not-assigned]
from os import path as PATH
import os as OS
Expand All @@ -111,17 +112,15 @@ def function2():
try:
1 / 0
except ZeroDivisionError as error:
# TODO fix bug for not identifying unused variables in nested exceptions see issue #4391
try:
1 / 0
except ZeroDivisionError as error:
except ZeroDivisionError as error: # [redefined-outer-name]
raise Exception("") from error

def func():
try:
1 / 0
except ZeroDivisionError as error:
# TODO fix bug for not identifying unused variables in nested exceptions see issue #4391
try:
1 / 0
except error:
Expand All @@ -131,7 +130,6 @@ def func2():
try:
1 / 0
except ZeroDivisionError as error:
# TODO fix bug for not identifying unused variables in nested exceptions see issue #4391
try:
1 / 0
except:
Expand All @@ -144,7 +142,7 @@ def func3():
print(f"{error}")
try:
1 / 2
except TypeError as error: # [unused-variable]
except TypeError as error: # [unused-variable, redefined-outer-name]
print("warning")

def func4():
Expand All @@ -153,8 +151,7 @@ def func4():
except ZeroDivisionError as error: # [unused-variable]
try:
1 / 0
except ZeroDivisionError as error:
# TODO fix bug for not identifying unused variables in nested exceptions see issue #4391
except ZeroDivisionError as error: # [redefined-outer-name]
print("error")


Expand Down
25 changes: 14 additions & 11 deletions tests/functional/u/unused/unused_variable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ unused-import:55:4:55:38:unused_import_from:Unused namedtuple imported from coll
unused-import:59:4:59:40:unused_import_in_function:Unused hexdigits imported from string:UNDEFINED
unused-variable:64:4:64:10:hello:Unused variable 'my_var':UNDEFINED
unused-variable:76:4:76:8:function:Unused variable 'aaaa':UNDEFINED
global-variable-not-assigned:97:4:97:39:test_global:Using global for 'PATH' but no assignment is done:UNDEFINED
global-variable-not-assigned:97:4:97:39:test_global:Using global for 'deque' but no assignment is done:UNDEFINED
unused-import:103:4:103:28:test_global:Unused platform imported from sys:UNDEFINED
unused-import:104:4:104:38:test_global:Unused version imported from sys as VERSION:UNDEFINED
unused-import:105:4:105:15:test_global:Unused import this:UNDEFINED
unused-import:106:4:106:19:test_global:Unused re imported as RE:UNDEFINED
unused-variable:110:4:110:10:function2:Unused variable 'unused':UNDEFINED
unused-variable:147:8:148:28:func3:Unused variable 'error':UNDEFINED
unused-variable:153:4:158:26:func4:Unused variable 'error':UNDEFINED
unused-variable:165:4:166:12:main:Unused variable 'e':UNDEFINED
undefined-loop-variable:172:10:172:11:main:Using possibly undefined loop variable 'e':UNDEFINED
global-variable-not-assigned:98:4:98:39:test_global:Using global for 'PATH' but no assignment is done:UNDEFINED
global-variable-not-assigned:98:4:98:39:test_global:Using global for 'deque' but no assignment is done:UNDEFINED
unused-import:104:4:104:28:test_global:Unused platform imported from sys:UNDEFINED
unused-import:105:4:105:38:test_global:Unused version imported from sys as VERSION:UNDEFINED
unused-import:106:4:106:15:test_global:Unused import this:UNDEFINED
unused-import:107:4:107:19:test_global:Unused re imported as RE:UNDEFINED
unused-variable:111:4:111:10:function2:Unused variable 'unused':UNDEFINED
redefined-outer-name:117:8:118:42:function2:Redefining name 'error' from outer scope (line 114):UNDEFINED
redefined-outer-name:145:8:146:28:func3:Redefining name 'error' from outer scope (line 141):UNDEFINED
unused-variable:145:8:146:28:func3:Unused variable 'error':UNDEFINED
unused-variable:151:4:155:26:func4:Unused variable 'error':UNDEFINED
redefined-outer-name:154:8:155:26:func4:Redefining name 'error' from outer scope (line 151):UNDEFINED
unused-variable:162:4:163:12:main:Unused variable 'e':UNDEFINED
undefined-loop-variable:169:10:169:11:main:Using possibly undefined loop variable 'e':UNDEFINED

0 comments on commit 0880d95

Please sign in to comment.