-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Unwrap type[Union[...]]
when solving typevar constraints
#18266
base: master
Are you sure you want to change the base?
Unwrap type[Union[...]]
when solving typevar constraints
#18266
Conversation
This comment has been minimized.
This comment has been minimized.
Primer diff is fine, it was a false positive. |
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 for the PR! I had a few comments but looks good overall.
Diff from mypy_primer, showing the effect of this PR on open source code: Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/annotations.py:1064: error: Incompatible return value type (got "object", expected "User | Role | Snowflake | _T") [return-value]
colour (https://github.com/colour-science/colour)
+ colour/geometry/section.py:88: error: Need type annotation for "edge_list" [var-annotated]
- colour/geometry/section.py:90: error: Item "float" of "float | list[float] | list[list[float]] | list[list[list[Any]]]" has no attribute "pop" [union-attr]
- colour/geometry/section.py:91: error: Value of type "Any | float | list[float] | list[list[Any]]" is not indexable [index]
- colour/geometry/section.py:93: error: Argument 1 to "len" has incompatible type "float | list[float] | list[list[float]] | list[list[list[Any]]]"; expected "Sized" [arg-type]
- colour/geometry/section.py:100: error: Item "float" of "float | list[float] | list[list[float]] | list[list[list[Any]]]" has no attribute "pop" [union-attr]
- colour/geometry/section.py:101: error: Value of type "Any | float | list[float] | list[list[Any]]" is not indexable [index]
- colour/geometry/section.py:103: error: Item "float" of "float | list[float] | list[list[float]] | list[list[list[Any]]]" has no attribute "pop" [union-attr]
- colour/geometry/section.py:104: error: Value of type "Any | float | list[float] | list[list[Any]]" is not indexable [index]
+ colour/io/fichet2021.py:682: error: Need type annotation for "chromaticities" (hint: "chromaticities: list[<type>] = ...") [var-annotated]
|
Hm, and this new diff is weird. I'll try to figure out the reason for the |
Closes #18265, closes #12115.
type[A | B]
is internally represented astype[A] | type[B]
, and this causes problems for a typevar solver. Prevent using meet in such cases by unwrapingtype[...]
if both sides have such shape.