blob: 85ee86fbfa355a061cc6f52816121104c652e102 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# pylint: disable=too-few-public-methods, unnecessary-lambda-assignment
"""check for scope problems"""
class Well:
"""well"""
attr = 42
get_attr = lambda arg=attr: arg * 24
# +1: [undefined-variable, used-before-assignment]
get_attr_bad = lambda arg=revattr: revattr * 42
revattr = 24
bad_lambda = lambda: get_attr_bad # [undefined-variable]
bad_gen = list(attr + i for i in range(10)) # [undefined-variable]
class Data:
"""base hidden class"""
class Sub(Data):
"""whaou, is Data found???"""
attr = Data() # [undefined-variable]
def func(self):
"""check Sub is not defined here"""
return Sub(), self # [undefined-variable]
class Right:
"""right"""
class Result1:
"""result one"""
OK = 0
def work(self) -> Result1:
"""good type hint"""
return self.Result1.OK
class Wrong:
"""wrong"""
class Result2:
"""result two"""
OK = 0
def work(self) -> self.Result2: # [undefined-variable]
"""bad type hint"""
return self.Result2.OK
|