-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Don't add incorrect subdiagnostic for unresolved reference #18487
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
[ty] Don't add incorrect subdiagnostic for unresolved reference #18487
Conversation
…change message for classmethod
|
carljm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
|
I've cleaned this up a bit, but i'm getting panics because of the decorator expression inference. Im not sure what order and function i should call to infer the type of the decorator expression. |
|
A core invariant of our type inference is that each AST node gets a type inferred for it once, in the "inference region" responsible for that node (an inference region can be a scope, a definition, or a standalone expression), and then that type gets merged into the surrounding region as needed, but doesn't get re-inferred willy-nilly. So I don't think it will work well to have the The function decorators should have their type inferred exactly once, in The previous code here that checked for abstract methods and overloads used So the ideal here would be to find the Definition for the function (scopes know the Definition that creates them, so this shouldn't be hard to get from the body scope) and then use |
Co-authored-by: Alex Waygood <[email protected]>
|
i've not yet used |
CodSpeed Instrumentation Performance ReportMerging #18487 will not alter performanceComparing Summary
|
…ence * main: (71 commits) Bump 0.12.0 (astral-sh#18724) Revert "[ty] Offer "Did you mean...?" suggestions for unresolved `from` imports and unresolved attributes (astral-sh#18705)" (astral-sh#18721) [`flake8-return`] Stabilize only add `return None` at the end when fixing `implicit-return` (`RET503`) (astral-sh#18516) [`pyupgrade`] Stabilize `non-pep695-generic-function` (`UP047`) (astral-sh#18524) [`pyupgrade`] Stabilize `non-pep695-generic-class` (`UP046`) (astral-sh#18519) [`pandas-vet`] Deprecate `pandas-df-variable-name` (`PD901`) (astral-sh#18618) [`flake8-bandit`] Remove `suspicious-xmle-tree-usage` (`S320`) (astral-sh#18617) Stabilize `dataclass-enum` (`RUF049`) (astral-sh#18570) Stabilize `unnecessary-dict-index-lookup` (`PLR1733`) (astral-sh#18571) Remove rust-toolchain.toml from sdist (astral-sh#17925) Stabilize `starmap-zip` (`RUF058`) (astral-sh#18525) [`flake8-logging`] Stabilize `exc-info-outside-except-handler` (`LOG014`) (astral-sh#18517) [`pyupgrade`] Stabilize `non-pep604-annotation-optional` (`UP045`) and preview behavior for `non-pep604-annotation-union` (`UP007`) (astral-sh#18505) Stabilize `pytest-warns-too-broad` (`PT030`) (astral-sh#18568) Stabilize `for-loop-writes` (`FURB122`) (astral-sh#18565) Stabilize `pytest-warns-with-multiple-statements` (`PT031`) (astral-sh#18569) Stabilize `pytest-parameter-with-default-argument` (`PT028`) (astral-sh#18566) Stabilize `nan-comparison` (`PLW0177`) (astral-sh#18559) Stabilize `check-and-remove-from-set` (`FURB132`) (astral-sh#18560) Stabilize `unnecessary-round` (`RUF057`) (astral-sh#18563) ...
|
There's a surprisingly large mypy_primer diff on this PR right now |
|
Yeah, the mypy primer diff definitely seems to indicate something unexpected is happening here. Don't have time to investigate it further right now, will have to come back to this later. |
|
Moving this to draft for now, feel free to move it back to review whenever you think it's ready for another round of review. |
AlexWaygood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is great. It looks like the primer hits have all gone now that #18809 has landed on main, so I think this is good to go now!
86935ad to
452b39d
Compare
452b39d to
ba648f9
Compare
* main: [ty] Add builtins to completions derived from scope (#18982) [ty] Don't add incorrect subdiagnostic for unresolved reference (#18487) [ty] Simplify `KnownClass::check_call()` and `KnownFunction::check_call()` (#18981) [ty] Add micro-benchmark for #711 (#18979) [`flake8-annotations`] Make `ANN401` example error out-of-the-box (#18974) [`flake8-async`] Make `ASYNC110` example error out-of-the-box (#18975) [pandas]: Fix issue on `non pandas` dataframe `in-place` usage (PD002) (#18963) [`pylint`] Fix `PLC0415` example (#18970) [ty] Add environment variable to dump Salsa memory usage stats (#18928) [`pylint`] Fix `PLW0108` autofix introducing a syntax error when the lambda's body contains an assignment expression (#18678) Bump 0.12.1 (#18969) [`FastAPI`] Add fix safety section to `FAST002` (#18940) [ty] Add regression test for leading tab mis-alignment in diagnostic rendering (#18965) [ty] Resolve python environment in `Options::to_program_settings` (#18960) [`ruff`] Fix false positives and negatives in `RUF010` (#18690) [ty] Fix rendering of long lines that are indented with tabs [ty] Add regression test for diagnostic rendering panic [ty] Move venv and conda env discovery to `SearchPath::from_settings` (#18938)
Summary
Don't add subdiagnostic in staticmethod, and change message for classmethod
Resolves astral-sh/ty#584 (partially i think)
Test Plan
Add test and update snapshot