-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve fuzzy matching for auto-complete suggestions #656
Conversation
doesn't allow skipping as many sections of characters in the string matching When the user types `sleep`, it will no longer give `SimpleNamespace` as an auto-import suggestion. `SimpleNamespace` `^ ^^ ^ ^` When the user types `aaaaa`, it will no longer give `AbstractAsyncContextManager` as a suggestion. And you can see an example changed in the unit tests: `time.gm` only suggests `time.gmtime` and no longer suggests `time.clock_gettime` or `time.clock_gettime_ns`
This can improve the situation for #655 |
Diff from mypy_primer, showing the effect of this PR on open source code: sympy (https://github.com/sympy/sympy)
- /tmp/mypy_primer/projects/sympy/sympy/sets/ordinals.py:18:13 - error: Type of "a" is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/sympy/sympy/sets/ordinals.py:18:17 - error: Type of "convert" is partially unknown
- Type of "convert" is "(integer_value: Unknown) -> Unknown" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/sympy/sympy/sets/sets.py:2500:24 - error: Return type, "Unknown | Basic | ImageSet | FiniteSet", is partially unknown (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/sympy/sympy/sets/sets.py:2500:24 - error: Return type is unknown (reportUnknownVariableType)
- /tmp/mypy_primer/projects/sympy/sympy/sets/tests/test_sets.py:1008:51 - error: Operator "&" not supported for types "_NotImplementedType | LessThan | Unknown | Equality | Relational | Unequality" and "_NotImplementedType | LessThan | Unknown | Equality | Relational | Unequality"
- Operator "&" not supported for types "LessThan" and "LessThan"
- Operator "&" not supported for types "LessThan" and "Equality"
- Operator "&" not supported for types "LessThan" and "Relational"
- Operator "&" not supported for types "LessThan" and "Unequality"
- Operator "&" not supported for types "Equality" and "LessThan"
- Operator "&" not supported for types "Equality" and "Equality"
- Operator "&" not supported for types "Equality" and "Relational"
- Operator "&" not supported for types "Equality" and "Unequality"
- ... (reportOperatorIssue)
- Type of "expr" is "Unknown | Order | Any | Self@Expr" (reportUnknownVariableType)
+ Type of "expr" is "Unknown | Order | Any | Pow | Abs" (reportUnknownVariableType)
- Type of "expand" is "((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any | Self@Expr)) | Unknown" (reportUnknownMemberType)
+ Type of "expand" is "((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any | Pow)) | ((deep: bool = True, modulus: Unknown | None = None, power_base: bool = True, power_exp: bool = True, mul: bool = True, log: bool = True, multinomial: bool = True, basic: bool = True, **hints: Unknown) -> (Unknown | Order | Any | Abs)) | Unknown" (reportUnknownMemberType)
- Type of "_expr" is "Any | Unknown | Order | Self@Expr" (reportUnknownVariableType)
+ Type of "_expr" is "Any | Unknown | Order | Pow | Abs" (reportUnknownVariableType)
- Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Self@Sum | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | None))" (reportUnknownMemberType)
+ Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Sum | Order | Any | Piecewise | Basic | None))" (reportUnknownMemberType)
- Type of "e" is "_NotImplementedType | StrictLessThan | Unknown | Equality | Relational | Unequality" (reportUnknownVariableType)
+ Type of "e" is "_NotImplementedType | Unknown" (reportUnknownVariableType)
- Type of "ivl" is "Unknown | Any" (reportUnknownVariableType)
+ Type of "ivl" is "Any | Unknown" (reportUnknownVariableType)
- Type of "as_set" is "Any | (() -> Unknown) | Unknown" (reportUnknownMemberType)
+ Type of "as_set" is "Any | Unknown" (reportUnknownMemberType)
+ /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:501:5 - error: Type of "eqs" is partially unknown
+ Type of "eqs" is "list[Unknown]" (reportUnknownVariableType)
- Argument type is "Unknown | Any | _NotImplementedType" (reportUnknownArgumentType)
+ Argument type is "Unknown | _NotImplementedType" (reportUnknownArgumentType)
- Type of "eqs" is "list[Unknown | Any]" (reportUnknownVariableType)
+ Type of "eqs" is "list[Unknown]" (reportUnknownVariableType)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:505:16 - error: Argument type is partially unknown
+ /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:505:16 - error: Argument type is unknown
- Argument corresponds to parameter "iterable" in function "__init__"
+ Argument corresponds to parameter "iterable" in function "__init__" (reportUnknownArgumentType)
- Argument type is "Unknown | Any" (reportUnknownArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:717:18 - error: Argument type is unknown
+ Argument corresponds to parameter "f" in function "solve" (reportUnknownArgumentType)
- /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:1768:5 - error: Type of "eqs" is partially unknown
+ /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:1768:5 - error: Type of "eqs" is unknown (reportUnknownVariableType)
- Type of "eqs" is "Unknown | Any" (reportUnknownVariableType)
+ /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:1769:18 - error: Argument type is unknown
+ Argument corresponds to parameter "f" in function "solve" (reportUnknownArgumentType)
+ /tmp/mypy_primer/projects/sympy/sympy/solvers/tests/test_solvers.py:1770:18 - error: Argument type is unknown
+ Argument corresponds to parameter "f" in function "solve" (reportUnknownArgumentType)
- Type of "variance" is "(X: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (VarianceMatrix | Variance | Unknown | Any | CentralMoment)" (reportUnknownVariableType)
+ Type of "variance" is "(X: Unknown, condition: Unknown | None = None, **kwargs: Unknown) -> (VarianceMatrix | Variance | Unknown | CentralMoment)" (reportUnknownVariableType)
- Type of "moment" is "(X: Unknown, n: Unknown, c: int = 0, condition: Unknown | None = None, *, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | Moment)" (reportUnknownVariableType)
+ Type of "moment" is "(X: Unknown, n: Unknown, c: int = 0, condition: Unknown | None = None, *, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Moment)" (reportUnknownVariableType)
- Type of "cmoment" is "(X: Unknown, n: Unknown, condition: Unknown | None = None, *, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | Any | CentralMoment)" (reportUnknownVariableType)
+ Type of "cmoment" is "(X: Unknown, n: Unknown, condition: Unknown | None = None, *, evaluate: bool = True, **kwargs: Unknown) -> (Unknown | CentralMoment)" (reportUnknownVariableType)
- Type of "summation" is "(f: Unknown, ...) -> (Equality | Relational | Unequality | Unknown)" (reportUnknownVariableType)
+ Type of "summation" is "(f: Unknown, ...) -> (tuple[Unknown, ...] | Unknown | Self@Sum | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | None)" (reportUnknownVariableType)
- Type of "summation" is "(f: Unknown, ...) -> (Equality | Relational | Unequality | Unknown)" (reportUnknownVariableType)
+ Type of "summation" is "(f: Unknown, ...) -> (tuple[Unknown, ...] | Unknown | Self@Sum | Order | Any | Piecewise | Basic | Equality | Relational | Unequality | Sum | None)" (reportUnknownVariableType)
- Type of "term1" is "tuple[Unknown, ...] | Unknown | Product | Basic | Order | Any | Equality | Relational | Unequality" (reportUnknownVariableType)
+ Type of "term1" is "tuple[Unknown, ...] | Unknown | Product | Basic | Equality | Order | Relational | Unequality | Any" (reportUnknownVariableType)
- Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Product | Basic | Order | Any))" (reportUnknownMemberType)
+ Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Product | Basic | Equality | Order | Relational | Unequality | Any))" (reportUnknownMemberType)
- Type of "term2" is "tuple[Unknown, ...] | Unknown | Product | Basic | Order | Any | Equality | Relational | Unequality" (reportUnknownVariableType)
+ Type of "term2" is "tuple[Unknown, ...] | Unknown | Product | Basic | Equality | Order | Relational | Unequality | Any" (reportUnknownVariableType)
- Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Product | Basic | Order | Any))" (reportUnknownMemberType)
+ Type of "doit" is "((**hints: Unknown) -> Equality) | Unknown | ((**hints: Unknown) -> Relational) | ((**hints: Unknown) -> Unequality) | ((**hints: Unknown) -> (tuple[Unknown, ...] | Unknown | Product | Basic | Equality | Order | Relational | Unequality | Any))" (reportUnknownMemberType)
- /tmp/mypy_primer/projects/sympy/sympy/stats/random_matrix_models.py:110:36 - error: Operator "*" not supported for types "type[__class_UndefinedFunction] | Unknown" and "tuple[Unknown, ...] | Unknown | Product | Basic | Order | Any | Equality | Relational | Unequality"
+ /tmp/mypy_primer/projects/sympy/sympy/stats/random_matrix_models.py:110:36 - error: Operator "*" not supported for types "type[__class_UndefinedFunction] | Unknown" and "tuple[Unknown, ...] | Unknown | Product | Basic | Equality | Order | Relational | Unequality | Any"
... (truncated 378 lines) ...
|
For that particular example, something strange is going on. After I type Sometimes |
sounds like a pain to debug. i'll just merge this change as is because i still think it's a huge improvement. thanks again for the contribution |
doesn't allow skipping as many sections of characters in the string matching
When the user types
sleep
, it will no longer giveSimpleNamespace
as a suggestion.SimpleNamespace
^ ^^ ^ ^
When the user types
aaaaa
, it will no longer giveAbstractAsyncContextManager
as a suggestion.And you can see an example changed in the unit tests:
time.gm
only suggeststime.gmtime
and no longer suggeststime.clock_gettime
ortime.clock_gettime_ns
added unit tests for the changed function