-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[match-case] fix matching against typing.Callable
and Protocol
types.
#19471
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
Open
randolf-scholz
wants to merge
9
commits into
python:master
Choose a base branch
from
randolf-scholz:fix_match_callable
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+129
−3
Conversation
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
…eckable test should be performed elsewhere.
…on and anonymous `Callable`
Diff from mypy_primer, showing the effect of this PR on open source code: strawberry (https://github.com/strawberry-graphql/strawberry)
+ strawberry/relay/types.py:849: error: Need type annotation for "v" [var-annotated]
+ strawberry/relay/types.py:849: note: Error code "var-annotated" not covered by "type: ignore" comment
+ strawberry/relay/types.py:854: error: Argument 1 to "enumerate" has incompatible type "AsyncIterator[NodeType] | AsyncIterable[NodeType]"; expected "Iterable[Never]" [arg-type]
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/flows.py:1239: error: Argument 1 to "BlockStorageAdapter" has incompatible type "Union[ReadableDeploymentStorage, RunnerStorage]"; expected "Union[ReadableDeploymentStorage, WritableDeploymentStorage]" [arg-type]
+ src/prefect/flows.py:1353: error: Argument 1 to "BlockStorageAdapter" has incompatible type "Union[ReadableDeploymentStorage, RunnerStorage]"; expected "Union[ReadableDeploymentStorage, WritableDeploymentStorage]" [arg-type]
+ src/prefect/tasks.py:945: error: Incompatible return value type (got "Coroutine[Any, Any, TaskRun]", expected "TaskRun") [return-value]
+ src/prefect/tasks.py:945: note: Maybe you forgot to use "await"?
meson (https://github.com/mesonbuild/meson)
+ mesonbuild/compilers/mixins/clike.py:411:29: error: List item 0 has incompatible type "list[Dependency]"; expected "Dependency" [list-item]
mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/http.py:607: error: Unused "type: ignore" comment [unused-ignore]
xarray (https://github.com/pydata/xarray)
+ xarray/core/dataset.py: note: In member "drop_vars" of class "Dataset":
+ xarray/core/dataset.py:5796: error: Argument 1 to "set" has incompatible type "Iterable[Hashable]"; expected "Iterable[Iterable[Hashable]]" [arg-type]
+ xarray/core/dataset.py:5798: error: Argument 1 to "_assert_all_in_dataset" of "Dataset" has incompatible type "set[Iterable[Hashable]]"; expected "Iterable[Hashable]" [arg-type]
+ xarray/core/dataset.py:5803: error: No overload variant of "get" of "dict" matches argument types "Iterable[Hashable]", "None" [call-overload]
+ xarray/core/dataset.py:5803: note: Possible overload variants:
+ xarray/core/dataset.py:5803: note: def get(self, Hashable, None = ..., /) -> Index | None
+ xarray/core/dataset.py:5803: note: def get(self, Hashable, Index, /) -> Index
+ xarray/core/dataset.py:5803: note: def [_T] get(self, Hashable, _T, /) -> Index | _T
+ xarray/core/dataset.py:5806: error: Argument 1 to "set" has incompatible type "set[Iterable[Hashable]]"; expected "Iterable[Hashable]" [arg-type]
+ xarray/core/dataset.py:5809: error: Argument 1 to "set" has incompatible type "set[Hashable]"; expected "Iterable[Iterable[Hashable]]" [arg-type]
+ xarray/core/dataset.py:5816: error: Argument 2 to "assert_no_index_corrupted" has incompatible type "set[Iterable[Hashable]]"; expected "set[Hashable]" [arg-type]
+ xarray/core/dataset.py: note: In member "drop_dims" of class "Dataset":
+ xarray/core/dataset.py:6102: error: Argument 1 to <set> has incompatible type "str | Iterable[Hashable]"; expected "Hashable" [arg-type]
+ xarray/core/dataset.py: note: At top level:
+ xarray/core/datatree.py: note: In member "drop_nodes" of class "DataTree":
+ xarray/core/datatree.py:1133: error: Argument 1 to <set> has incompatible type "str | Iterable[str]"; expected "str" [arg-type]
+ xarray/backends/api.py: note: In function "to_netcdf":
+ xarray/backends/api.py:1973: error: List item 0 has incompatible type "Iterable[Hashable]"; expected "Hashable" [list-item]
+ xarray/backends/api.py: note: At top level:
+ xarray/computation/fit.py: note: In function "curvefit":
+ xarray/computation/fit.py:407: error: List item 0 has incompatible type "str | DataArray | Iterable[str | DataArray]"; expected "str | DataArray" [list-item]
graphql-core (https://github.com/graphql-python/graphql-core)
+ tests/execution/test_subscribe.py:292: error: Unused "type: ignore" comment [unused-ignore]
websockets (https://github.com/aaugustin/websockets)
+ src/websockets/legacy/server.py:368: error: Incompatible return value type (got "Awaitable[tuple[HTTPStatus | int, Headers | Mapping[str, str] | Iterable[tuple[str, str]] | SupportsKeysAndGetItem, bytes] | None]", expected "tuple[HTTPStatus | int, Headers | Mapping[str, str] | Iterable[tuple[str, str]] | SupportsKeysAndGetItem, bytes] | None") [return-value]
+ src/websockets/legacy/server.py:368: note: Maybe you forgot to use "await"?
+ src/websockets/legacy/server.py:591: error: Incompatible types in assignment (expression has type "Coroutine[Any, Any, tuple[HTTPStatus | int, Headers | Mapping[str, str] | Iterable[tuple[str, str]] | SupportsKeysAndGetItem, bytes] | None]", variable has type "tuple[HTTPStatus | int, Headers | Mapping[str, str] | Iterable[tuple[str, str]] | SupportsKeysAndGetItem, bytes] | None") [assignment]
+ src/websockets/legacy/server.py:591: note: Maybe you forgot to use "await"?
|
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.
(Explain how this PR changes mypy.)
collection.abc.Callable
raises error [misc] #14014AnyCallable
Protocol differs fromcallable()
check #19470testMatchClassPatternCallable
,testMatchClassPatternProtocol
andtestMatchClassPatternCallbackProtocol
testOverloadOnProtocol
I added an extra if-branch that checks for
typing.Callable
invisit_class_pattern
, and an extra if-branch to handle structural types in theconditional_types
function.