Add comment regarding class scope short circuit (#6101)

This commit is contained in:
Zanie Blue 2023-07-26 14:55:05 -05:00 committed by GitHub
parent 564304eba2
commit 2d2673f613
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -313,6 +313,20 @@ impl<'a> SemanticModel<'a> {
if seen_function && matches!(symbol, "__class__") {
return ReadResult::ImplicitGlobal;
}
// Do not allow usages of class symbols unless it is the immediate parent, e.g.:
//
// ```python
// class Foo:
// a = 0
//
// b = a # allowed
// def c(self, arg=a): # allowed
// print(arg)
//
// def d(self):
// print(a) # not allowed
// ```
//
if index > 0 {
continue;
}