File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
resources/test/fixtures/pyflakes Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -126,3 +126,22 @@ def f(x: int):
126
126
def f ():
127
127
if any ((key := (value := x )) for x in ["ok" ]):
128
128
print (key )
129
+
130
+
131
+ def f () -> None :
132
+ is_connected = False
133
+
134
+ class Foo :
135
+ @property
136
+ def is_connected (self ):
137
+ nonlocal is_connected
138
+ return is_connected
139
+
140
+ def do_thing (self ):
141
+ # This should resolve to the `is_connected` in the function scope.
142
+ nonlocal is_connected
143
+ print (is_connected )
144
+
145
+ obj = Foo ()
146
+ obj .do_thing ()
147
+
Original file line number Diff line number Diff line change @@ -291,14 +291,14 @@ where
291
291
}
292
292
293
293
// Mark the binding in the defining scopes as used too. (Skip the global scope
294
- // and the current scope.)
294
+ // and the current scope, and, per standard resolution rules, any class scopes .)
295
295
for ( name, range) in names. iter ( ) . zip ( ranges. iter ( ) ) {
296
296
let binding_id = self
297
297
. semantic_model
298
298
. scopes
299
299
. ancestors ( self . semantic_model . scope_id )
300
300
. skip ( 1 )
301
- . take_while ( |scope| !scope. kind . is_module ( ) )
301
+ . filter ( |scope| !( scope. kind . is_module ( ) || scope . kind . is_class ( ) ) )
302
302
. find_map ( |scope| scope. get ( name. as_str ( ) ) ) ;
303
303
304
304
if let Some ( binding_id) = binding_id {
You can’t perform that action at this time.
0 commit comments