Skip to content

Commit 9ab9411

Browse files
committed
feat: early return on class
Signed-off-by: 11happy <soni5happy@gmail.com>
1 parent eb0f54b commit 9ab9411

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

crates/ruff_linter/src/checkers/ast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ impl SemanticSyntaxContext for Checker<'_> {
845845
for scope in self.semantic.current_scopes() {
846846
match scope.kind {
847847
ScopeKind::Class(_) => {
848-
continue;
848+
return false;
849849
}
850850
ScopeKind::Function(_) | ScopeKind::Lambda(_) => {
851851
if let Some(mut binding_id) = scope.get(name) {

crates/ruff_linter/src/linter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ mod tests {
10721072
10731073
def f(a):
10741074
class Inner:
1075-
global a
1075+
global a # ok
10761076
",
10771077
PythonVersion::PY310,
10781078
"GlobalParameter"

crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_GlobalParameter_global_parameter_3.10.snap

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,3 @@ invalid-syntax: name `a` is parameter and global
5454
27 |
5555
28 | def f(a):
5656
|
57-
58-
invalid-syntax: name `a` is parameter and global
59-
--> <filename>:30:16
60-
|
61-
28 | def f(a):
62-
29 | class Inner:
63-
30 | global a
64-
| ^
65-
|

0 commit comments

Comments
 (0)