[ty] Assign lower completions ranking to deprecated functions and classes#23089
Merged
BurntSushi merged 2 commits intoastral-sh:mainfrom Feb 9, 2026
Merged
[ty] Assign lower completions ranking to deprecated functions and classes#23089BurntSushi merged 2 commits intoastral-sh:mainfrom
BurntSushi merged 2 commits intoastral-sh:mainfrom
Conversation
Typing conformance resultsNo changes detected ✅ |
|
BurntSushi
approved these changes
Feb 5, 2026
Member
BurntSushi
left a comment
There was a problem hiding this comment.
LGTM with a nit.
Note that this doesn't handle the auto-import case, which will require parsing out the @deprecated decorator explicitly (auto-import doesn't have access to ty's type information). But I think this PR is an improvement on the status quo. It doesn't need to handle the auto-import case. But we shouldn't close astral-sh/ty#2654 yet.
This makes the completion rank deprecated functions and classes lower than non deprecated ones. It relies on the `@deprecated` decorator on the definition. Fixes astral-sh/ty#2654
6e101b8 to
376e270
Compare
Contributor
Author
|
Thanks for letting me know I'll look into the auto import case tomorrow and send another PR. |
carljm
added a commit
to Hugo-Polloli/ruff
that referenced
this pull request
Feb 9, 2026
* main: (45 commits) [ty] Fix wrong inlay hints for overloaded function arguments (astral-sh#23179) [ty] Respect `@no_type_check` when combined with other decorators (astral-sh#23177) [ty] Use type context when inferring constructor argument types (astral-sh#23139) [`airflow`] Add ruff rules to catch deprecated attribute access from context key for Airflow 3.0 (`AIR301`) (astral-sh#22850) Support formatting `pycon` markdown code blocks (astral-sh#23112) Markdown formatting in LSP (astral-sh#23063) Instruct Claude to use comments more sparingly (astral-sh#23181) [`flake8-gettext`] Fix false negatives for plural argument of ngettext (`INT001`, `INT002`, `INT003`) (astral-sh#21078) [ty] Invoking goto-def on parentheses of a class constructor call takes you too constructor method [ty] Make goto definition on class constructor always go to class definition [ty] Assign lower completions ranking to deprecated functions and classes (astral-sh#23089) [ty] Fix parameter references across files via keyword args (astral-sh#23012) [ty] Exclude enclosing class for base completions (astral-sh#23141) [`pyupgrade`] Fix syntax error on string with newline escape and comment (`UP037`) (astral-sh#22968) [ty] Improve documentation for `expect_single_definition` method (astral-sh#23175) [ty] Configure check mode for all projects Add `home-assistant` to ecosystem projects (astral-sh#23132) Add tabbed shell completion documentation (astral-sh#23169) Bump typing conformance-suite pin (astral-sh#23174) [ty] Fix invalid diagnostic location for a sub-call to a specialized ParamSpec (astral-sh#23036) ...
BurntSushi
pushed a commit
that referenced
this pull request
Feb 11, 2026
…23188) <!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary Follow up to #23089 this PR assigns lower completion ranking to deprecated names in auto import suggestions. The implementation relies on finding a decorator named `deprecated` in the source code ton consider that name deprecated. Fixes astral-sh/ty#2654 for real :) <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan Added another test case for this. I could not find an Here's how the behavior changed: Before: abstractc<CURSOR> ``` AbstractAsyncContextManager (module: contextlib) AbstractBasicAuthHandler (module: urllib.request) AbstractChildWatcher (module: asyncio) AbstractContextManager (module: contextlib) AbstractEventLoopPolicy (module: asyncio) abstractclassmethod (module: abc) abstractstaticmethod (module: abc) ``` After: ``` AbstractAsyncContextManager (module: contextlib) AbstractBasicAuthHandler (module: urllib.request) AbstractContextManager (module: contextlib) (*, 3/7) AbstractEventLoopPolicy (module: asyncio) AbstractChildWatcher (module: asyncio) abstractclassmethod (module: abc) abstractstaticmethod (module: abc) ``` <!-- How was it tested? -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This makes the completion rank deprecated functions and classes lower than non deprecated ones. It relies on the
@deprecateddecorator on the definition.I'm new to this subsystem. Let me know if something should be done differently.
Fixes astral-sh/ty#2654
Test Plan
Added completion eval test.