mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-11 22:29:39 +00:00
Add comment regarding class scope short circuit (#6101)
This commit is contained in:
parent
564304eba2
commit
2d2673f613
1 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue