Files
Semyon Proshev c9f889c811 PY-3996 Fixed: Don't flag underscore-prefixed variables as unused (or make not doing so an option).
Update PyRedeclarationInspection, PyShadowingNamesInspection and PyUnusedLocalInspection to ignore names that starts with underscore.
2017-06-29 19:04:07 +03:00

68 lines
2.0 KiB
Python

global_foo = 1
def test_outer_function():
foo = 1
def bar():
<weak_warning descr="Shadows name 'foo' from outer scope">foo</weak_warning>, <weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning> = 1, 2
def baz(<weak_warning descr="Shadows name 'foo' from outer scope">foo</weak_warning>, <weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning>, <weak_warning descr="Shadows name 'baz' from outer scope">baz</weak_warning>):
pass
def nested():
def <weak_warning descr="Shadows name 'baz' from outer scope">baz</weak_warning>(<weak_warning descr="Shadows name 'foo' from outer scope">foo</weak_warning>):
<weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning> = 1
def test_outer_class():
baz = 1
quux = 2
spam = 3
class C(object):
def foo(self):
def foo():
def <weak_warning descr="Shadows name 'bar' from outer scope">bar</weak_warning>():
class <weak_warning descr="Shadows name 'C' from outer scope">C</weak_warning>:
def baz(self):
pass
def bar():
pass
<weak_warning descr="Shadows name 'baz' from outer scope">baz</weak_warning> = 2
def spam(self):
pass
quux = 1
def test_outer_global():
global global_foo
global_foo = 2
def test_outer_comprehensions():
print(x for x in range(10))
print([y for y in range(10)])
def f(x, <weak_warning descr="Shadows name 'y' from outer scope">y</weak_warning>):
pass
def test_outer_single_underscore():
_ = "abc"
def foo():
_ = "def"
# PY-3996
def test_outer_underscore_prefixed():
_a = "abc"
def foo():
<weak_warning descr="Shadows name '_a' from outer scope">_a</weak_warning> = "def"
# PY-3996
def test_outer_underscore_prefixed_parameter():
def foo(_a):
def bar(_a):
print(_a)
print(_a)