mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-25 21:37:26 +00:00
Summary -- This PR resolves both the typing-related and syntax error TODOs added in #17563 by tracking a set of `global` bindings for each scope. As discussed below, we avoid the additional AST traversal from ruff by collecting `Name`s from `global` statements while building the semantic index and emit a syntax error if the `Name` is already bound in the current scope at the point of the `global` statement. This has the downside of separating the error from the `SemanticSyntaxChecker`, but I plan to explore using this approach in the `SemanticSyntaxChecker` itself as a follow-up. It seems like this may be a better approach for ruff as well. Test Plan -- Updated all of the related mdtests to remove the TODOs (and add quotes I forgot on the messages). There is one remaining TODO, but it requires `nonlocal` support, which isn't even incorporated into the `SemanticSyntaxChecker` yet. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Carl Meyer <carl@astral.sh> |
||
|---|---|---|
| .. | ||
| annotations | ||
| assignment | ||
| binary | ||
| boolean | ||
| boundness_declaredness | ||
| call | ||
| class | ||
| comparison | ||
| comprehensions | ||
| conditional | ||
| declaration | ||
| diagnostics | ||
| directives | ||
| doc | ||
| exception | ||
| expression | ||
| function | ||
| generics | ||
| import | ||
| literal | ||
| loops | ||
| narrow | ||
| regression | ||
| scopes | ||
| shadowing | ||
| snapshots | ||
| stubs | ||
| subscript | ||
| suppressions | ||
| type_of | ||
| type_properties | ||
| type_qualifiers | ||
| unary | ||
| with | ||
| .mdformat.toml | ||
| attributes.md | ||
| cycle.md | ||
| dataclass_transform.md | ||
| dataclasses.md | ||
| decorators.md | ||
| descriptor_protocol.md | ||
| final.md | ||
| intersection_types.md | ||
| invalid_syntax.md | ||
| known_constants.md | ||
| mdtest_config.md | ||
| mdtest_custom_typeshed.md | ||
| metaclass.md | ||
| mro.md | ||
| named_tuple.md | ||
| overloads.md | ||
| pep695_type_aliases.md | ||
| properties.md | ||
| protocols.md | ||
| slots.md | ||
| statically_known_branches.md | ||
| sys_platform.md | ||
| sys_version_info.md | ||
| terminal_statements.md | ||
| type_api.md | ||
| typed_dict.md | ||
| union_types.md | ||
| unpacking.md | ||
| unreachable.md | ||