-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Infer parameter specializations of explicitly implemented generic protocols #18054
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
Conversation
* main: disable jemalloc on android (#18033) [ty] Fix incorrect type of `src.root` in documentation (#18040) [ty] Refine message for why a rule is enabled (#18038) [ty] Remove brackets around option names (#18037) Update pre-commit dependencies (#18025) Update docker/build-push-action action to v6.16.0 (#18030) Update docker/login-action action to v3.4.0 (#18031) Update taiki-e/install-action digest to 83254c5 (#18022) Update cargo-bins/cargo-binstall action to v1.12.4 (#18023) Update Rust crate ctrlc to v3.4.7 (#18027) Update Rust crate clap to v4.5.38 (#18026) Update Rust crate jiff to v0.2.13 (#18029) Update Rust crate getrandom to v0.3.3 (#18028) Update dependency ruff to v0.11.9 (#18024) [`pylint`] add fix safety section (`PLW1514`) (#17932) python_stdlib: update for 3.14 (#18014) [`ruff`] add fix safety section (`RUF033`) (#17760) [`pylint`] add fix safety section (`PLC0414`) (#17802)
|
|
Are the primer results here as expected? It looks like there are a bunch of diagnostics being added here |
…eep-dish * origin/main: [ty] Infer parameter specializations of generic aliases (#18021) [ty] Understand homogeneous tuple annotations (#17998) [ty] Induct into instances and subclasses when finding and applying generics (#18052) [ty] Allow classes to inherit from `type[Any]` or `type[Unknown]` (#18060) [ty] Allow a class to inherit from an intersection if the intersection contains a dynamic type and the intersection is not disjoint from `type` (#18055) [ty] Narrowing for `hasattr()` (#18053) Update reference documentation for `--python-version` (#18056) [`flake8-bugbear`] Ignore `B028` if `skip_file_prefixes` is present (#18047) [`airflow`] Apply try-catch guard to all AIR3 rules (`AIR3`) (#17887) [`pylint`] add fix safety section (`PLW3301`) (#17878) Update `--python` to accept paths to executables in virtual environments (#17954) [`pylint`] add fix safety section (`PLE4703`) (#17824) [`ruff`] Implement a recursive check for `RUF060` (#17976) [`flake8-use-pathlib`] `PTH*` suppress diagnostic for all `os.*` functions that have the `dir_fd` parameter (#17968) [`refurb`] Mark autofix as safe only for number literals in `FURB116` (#17692) [`flake8-simplify`] Fix `SIM905` autofix for `rsplit` creating a reversed list literal (#18045) Avoid initializing progress bars early (#18049)
|
Looking at the ecosystem results. There are several new diagnostics that are instances of astral-sh/ty#336 (comment), where typevar invariance means that we don't consider e.g. I think this one is a true positive: paasta (https://github.com/yelp/paasta)
+ error[invalid-argument-type] paasta_tools/utils.py:1032:17: Argument to bound method `append` is incorrect: Expected `DockerVolume`, found `dict[Unknown, Unknown]` |
…eep-dish * origin/main: [ty] __file__ is always a string inside a Python module (#18071) [ty] Recognize submodules in self-referential imports (#18005) [ty] Add a note to the diagnostic if a new builtin is used on an old Python version (#18068) [ty] Add tests for `else` branches of `hasattr()` narrowing (#18067) [ty] Improve diagnostics for `assert_type` and `assert_never` (#18050) [ty] contribution guide (#18061) [ty] Implement `DataClassInstance` protocol for dataclasses. (#18018) [ruff_python_ast] Fix redundant visitation of test expressions in elif clause statements (#18064)
dcreager
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.
Surely, surely I will pay attention to the comment next time if my name is attached to it in the blame! (Narrator: he will not)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…c protocols (astral-sh#18054) Follows on from (and depends on) astral-sh#18021. This updates our function specialization inference to infer type mappings from parameters that are generic protocols. For now, this only works when the argument _explicitly_ implements the protocol by listing it as a base class. (We end up using exactly the same logic as for generic classes in astral-sh#18021.) For this to work with classes that _implicitly_ implement the protocol, we will have to check the types of the protocol members (which we are not currently doing), so that we can infer the specialization of the protocol that the class implements. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Follows on from (and depends on) #18021.
This updates our function specialization inference to infer type mappings from parameters that are generic protocols.
For now, this only works when the argument explicitly implements the protocol by listing it as a base class. (We end up using exactly the same logic as for generic classes in #18021.) For this to work with classes that implicitly implement the protocol, we will have to check the types of the protocol members (which we are not currently doing), so that we can infer the specialization of the protocol that the class implements.