mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 05:20:49 -05:00
[ty] Rank unimported symbols from typing higher
This addresses a number of minor annoyances where users really want imports from `typing` most of the time. For example: https://github.com/astral-sh/ty/issues/1274#issuecomment-3345884227
This commit is contained in:
committed by
Andrew Gallant
parent
56862f8241
commit
f1bd5f1941
@@ -19,7 +19,7 @@ import-keyword-completion,main.py,0,1
|
||||
internal-typeshed-hidden,main.py,0,2
|
||||
local-over-auto-import,main.py,0,1
|
||||
none-completion,main.py,0,1
|
||||
numpy-array,main.py,0,159
|
||||
numpy-array,main.py,0,160
|
||||
numpy-array,main.py,1,1
|
||||
object-attr-instance-methods,main.py,0,1
|
||||
object-attr-instance-methods,main.py,1,1
|
||||
@@ -30,10 +30,10 @@ scope-prioritize-closer,main.py,0,2
|
||||
scope-simple-long-identifier,main.py,0,1
|
||||
tighter-over-looser-scope,main.py,0,3
|
||||
tstring-completions,main.py,0,1
|
||||
ty-extensions-lower-stdlib,main.py,0,9
|
||||
type-var-typing-over-ast,main.py,0,3
|
||||
type-var-typing-over-ast,main.py,1,253
|
||||
typing-gets-priority,main.py,0,31
|
||||
typing-gets-priority,main.py,1,3
|
||||
typing-gets-priority,main.py,2,3
|
||||
typing-gets-priority,main.py,3,96
|
||||
ty-extensions-lower-stdlib,main.py,0,1
|
||||
type-var-typing-over-ast,main.py,0,1
|
||||
type-var-typing-over-ast,main.py,1,14
|
||||
typing-gets-priority,main.py,0,1
|
||||
typing-gets-priority,main.py,1,1
|
||||
typing-gets-priority,main.py,2,1
|
||||
typing-gets-priority,main.py,3,3
|
||||
|
||||
|
@@ -1033,6 +1033,9 @@ struct Relevance {
|
||||
/// completion evaluation framework should be more representative
|
||||
/// of real world conditions.
|
||||
keyword: Sort,
|
||||
/// In some instances, a symbol is from a very commonly used module
|
||||
/// that we want to boost over other symbols.
|
||||
special_module: Sort,
|
||||
/// Sorts based on whether the symbol comes from the `builtins`
|
||||
/// module. i.e., Python's initial basis. We usually sort these
|
||||
/// lower to give priority to symbols in a tighter scope.
|
||||
@@ -1064,6 +1067,16 @@ impl Relevance {
|
||||
} else {
|
||||
Sort::Even
|
||||
},
|
||||
special_module: c
|
||||
.module_name
|
||||
.and_then(|name| {
|
||||
if name.as_str() == "typing" {
|
||||
Some(Sort::Higher)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or(Sort::Even),
|
||||
builtin: if c.builtin { Sort::Lower } else { Sort::Even },
|
||||
name_kind: NameKind::classify(&c.name),
|
||||
type_check_only: if c.is_type_check_only {
|
||||
|
||||
Reference in New Issue
Block a user