ruff/crates/ty_python_semantic/resources/mdtest/diagnostics
Brent Westbrook 57bf7dfbd9
[ty] Implement global handling and load-before-global-declaration syntax error (#17637)
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>
2025-05-08 10:30:04 -04:00
..
attribute_assignment.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
invalid_argument_type.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
no_matching_overload.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
semantic_syntax_errors.md [ty] Implement global handling and load-before-global-declaration syntax error (#17637) 2025-05-08 10:30:04 -04:00
shadowing.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unpacking.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unresolved_import.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
unsupported_bool_conversion.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
version_related_syntax_errors.md Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00