ruff/crates
Andrew Gallant a77db3da3f
[ty] Add completions for from module import <CURSOR> (#18830)
There were two main challenges in this PR.

The first was mostly just figuring out how to get the symbols
corresponding to `module`. It turns out that we do this in a couple
of places in ty already, but through different means. In one approach,
we use [`exported_names`]. In another approach, we get a `Type`
corresponding to the module. We take the latter approach here, which is
consistent with how we do completions elsewhere. (I looked into
factoring this logic out into its own function, but it ended up being
pretty constrained. e.g., There's only one other place where we want to
go from `ast::StmtImportFrom` to a module `Type`, and that code also
wants the module name.)

The second challenge was recognizing the `from module import <CURSOR>`
pattern in the code. I initially started with some fixed token patterns
to get a proof of concept working. But I ended up switching to mini
state machine over tokens. I looked at the parser for `StmtImportFrom`
to determine what kinds of tokens we can expect.

[`exported_names`]:
23a3b6ef23/crates/ty_python_semantic/src/semantic_index/re_exports.rs (L47)
2025-06-23 10:43:25 -04:00
..
ruff Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_annotate_snippets
ruff_benchmark [ty] Add Tanjun benchmark (#18850) 2025-06-21 18:29:02 +02:00
ruff_cache
ruff_db [ty] Add more benchmarks (#18714) 2025-06-18 13:41:38 +02:00
ruff_dev
ruff_diagnostics
ruff_formatter
ruff_graph fix casing of analyze.direction variant names (#18892) 2025-06-23 14:30:30 +02:00
ruff_index
ruff_linter [flake8-simplify] Fix SIM911 autofix creating a syntax error (#18793) 2025-06-23 16:24:47 +02:00
ruff_macros Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_notebook
ruff_options_metadata
ruff_python_ast [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_ast_integration_tests [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_codegen [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_formatter [pylint] Supress PLE2510/2512/2513/2514/2515 autofix if the text contains an odd number of backslashes (#18856) 2025-06-23 10:11:51 +02:00
ruff_python_index
ruff_python_literal
ruff_python_parser Disallow newlines in format specifiers of single quoted f- or t-strings (#18708) 2025-06-18 14:56:15 +02:00
ruff_python_resolver
ruff_python_semantic [flake8-comprehensions] Handle template strings for comprehension fixes (#18710) 2025-06-19 16:23:46 -05:00
ruff_python_stdlib
ruff_python_trivia Treat ty: comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_trivia_integration_tests
ruff_server Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_source_file
ruff_text_size
ruff_wasm Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ruff_workspace Unify OldDiagnostic and Message (#18391) 2025-06-19 09:37:58 -04:00
ty [ty] Support --python=<symlink to executable> (#18827) 2025-06-21 20:28:47 +01:00
ty_ide [ty] Add completions for from module import <CURSOR> (#18830) 2025-06-23 10:43:25 -04:00
ty_project [ty] Add more benchmarks (#18714) 2025-06-18 13:41:38 +02:00
ty_python_semantic [ty] Add completions for from module import <CURSOR> (#18830) 2025-06-23 10:43:25 -04:00
ty_server [ty] Add python.ty.disableLanguageServices config (#18230) 2025-06-17 13:50:45 +05:30
ty_test Remove extra dot in rule documentation (#18871) 2025-06-23 00:33:21 +00:00
ty_vendored Sync vendored typeshed stubs (#18679) 2025-06-15 10:20:33 +01:00
ty_wasm