Repository navigation
Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: cattrs (https://github.com/python-attrs/cattrs)
- src/cattrs/converters.py:250: error: Argument 1 to "register_func_list" of "MultiStrategyDispatch" has incompatible type "list[tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Callable[[Any], Any]], str] | tuple[Callable[[Any], bool], Callable[[Any], str]] | tuple[Callable[[Any], Any], Callable[[Any], Any]] | tuple[Callable[[Any], Any], Callable[[Any], dict[str, Any]]] | tuple[Callable[[Any], bool], Callable[[type[Enum], BaseConverter], Callable[[Enum], Any]], str] | <7 more items>]"; expected "list[tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]" [arg-type]
- src/cattrs/converters.py:292: error: Argument 1 to "register_func_list" of "MultiStrategyDispatch" has incompatible type "list[tuple[Callable[[Any], Any], Callable[[Mapping[str, Any], type[T]], T]] | tuple[Callable[[Any], bool], Callable[[type[Enum], BaseConverter], Callable[[Any, type[Enum]], Enum]], str] | tuple[Callable[[Any], Any | bool], Callable[[Any], Callable[[Any, type[T]], T]], bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Callable[[Any, Any], Any]], str] | tuple[Callable[[Any], bool], Callable[[Any, bool], Callable[[Any, type[T]], type[T] | None]], bool] | <14 more items>]"; expected "list[tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]" [arg-type]
- src/cattrs/converters.py:470: error: Argument 1 to "register_func_list" of "MultiStrategyDispatch" has incompatible type "list[tuple[Any, Any, str] | tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]"; expected "list[tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]" [arg-type]
- src/cattrs/converters.py:482: error: List item 0 has incompatible type "tuple[Any, Any, str | bool]"; expected "tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]" [list-item]
+ src/cattrs/converters.py:482: error: List item 0 has incompatible type "tuple[Any, Any, Literal['extended', True]]"; expected "tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]" [list-item]
- src/cattrs/converters.py:611: error: Argument 1 to "register_func_list" of "MultiStrategyDispatch" has incompatible type "list[tuple[Any, Any, str] | tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]"; expected "list[tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]" [arg-type]
- src/cattrs/converters.py:622: error: List item 0 has incompatible type "tuple[Any, Any, str | bool]"; expected "tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]" [list-item]
+ src/cattrs/converters.py:622: error: List item 0 has incompatible type "tuple[Any, Any, Literal['extended', True]]"; expected "tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]" [list-item]
- src/cattrs/preconf/orjson.py:90: error: Argument 1 to "register_func_list" of "MultiStrategyDispatch" has incompatible type "list[tuple[Callable[[Any], bool], partial[Callable[[Any], Any]], str] | tuple[Callable[[Any], bool], Callable[[Any, Any], Any], bool] | tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]"; expected "list[tuple[Callable[[Any], bool], Any] | tuple[Callable[[Any], bool], Any, bool] | tuple[Callable[[Any], bool], Callable[[Any, BaseConverter], Any], Literal['extended']]]" [arg-type]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #22514.
ExpressionChecker.visit_tuple_exprnow combines the expected types at each position when multiple fixed-length tuple types in a union match the expression’s length. This preserves the enum literal context for each element, so mypy accepts lists of enum literal tuples where aSequenceof that tuple union is expected.Added
testTupleUnionContextInSequenceand updatedtestLiteralAndInstanceSubtyping.Verification
ruff check,ruff format --check, andmypy --config-file mypy_self_check.inipassedd