ruff/crates
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
..
ruff Default to latest supported Python version for version-related syntax errors (#17529) 2025-05-06 10:19:13 -04:00
ruff_annotate_snippets ruff_annotate_snippets: address unused code warnings 2025-04-07 08:24:08 -04:00
ruff_benchmark Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_cache Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_db [ty] Update salsa (#17937) 2025-05-08 12:02:53 +02:00
ruff_dev Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_diagnostics
ruff_formatter Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_graph [ty] Update salsa (#17937) 2025-05-08 12:02:53 +02:00
ruff_index Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_linter [airflow] Fix SQLTableCheckOperator typo (AIR302) (#17946) 2025-05-08 14:34:55 +02:00
ruff_macros Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_notebook Split SourceLocation into LineColumn and SourceLocation (#17587) 2025-04-27 11:27:33 +01:00
ruff_python_ast Implement deferred annotations for Python 3.14 (#17658) 2025-05-05 06:40:36 -05:00
ruff_python_ast_integration_tests Visit Identifier node as part of the SourceOrderVisitor (#17110) 2025-04-01 16:58:09 +02:00
ruff_python_codegen Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_formatter Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_index Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_literal Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_parser [parser] Flag single unparenthesized generator expr with trailing comma in arguments. (#17893) 2025-05-07 14:11:35 -04:00
ruff_python_resolver Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_semantic [isort] Check full module path against project root(s) when categorizing first-party (#16565) 2025-05-05 11:40:01 -05:00
ruff_python_stdlib Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_trivia Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_python_trivia_integration_tests
ruff_server Default to latest supported Python version for version-related syntax errors (#17529) 2025-05-06 10:19:13 -04:00
ruff_source_file Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_text_size Use #[expect(lint)] over #[allow(lint)] where possible (#17822) 2025-05-03 21:20:31 +02:00
ruff_wasm Default to latest supported Python version for version-related syntax errors (#17529) 2025-05-06 10:19:13 -04:00
ruff_workspace Default to latest supported Python version for version-related syntax errors (#17529) 2025-05-06 10:19:13 -04:00
ty Update ty metadata (#17943) 2025-05-08 13:24:31 +02:00
ty_ide [ty] Update salsa (#17937) 2025-05-08 12:02:53 +02:00
ty_project [ty] Update salsa (#17937) 2025-05-08 12:02:53 +02:00
ty_python_semantic [ty] Implement global handling and load-before-global-declaration syntax error (#17637) 2025-05-08 10:30:04 -04:00
ty_server [ty] Add basic file watching to server (#17912) 2025-05-07 19:03:30 +02:00
ty_test [ty] Update salsa (#17937) 2025-05-08 12:02:53 +02:00
ty_vendored [ty] Add support for __all__ (#17856) 2025-05-07 21:42:42 +05:30
ty_wasm [ty] Fix duplicate diagnostics for unresolved module when an import from statement imports multiple members (#17886) 2025-05-06 12:37:10 +01:00