Constrain memoryview type var to allowed types#13683
Open
srittau wants to merge 6 commits intopython:mainfrom
Open
Constrain memoryview type var to allowed types#13683srittau wants to merge 6 commits intopython:mainfrom
srittau wants to merge 6 commits intopython:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Member
|
I haven't fully thought this through but #13519 partially made me think that making memoryview generic with a default was a mistake. |
Collaborator
Author
|
I was thinking about that, but I think changing the default to |
This comment has been minimized.
This comment has been minimized.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: trio (https://github.com/python-trio/trio)
+ src/trio/_abc.py:331: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_highlevel_socket.py:109: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_highlevel_generic.py:94: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_file_io.py:164: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_file_io.py:330: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_ssl.py:737: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_subprocess.py:466: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_subprocess.py:1155: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_subprocess.py:1164: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/testing/_memory_streams.py:44: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/testing/_memory_streams.py:122: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/testing/_memory_streams.py:270: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/testing/_memory_streams.py:499: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/testing/_memory_streams.py:568: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/testing/_check_streams.py:101: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/testing/_check_streams.py:469: error: Explicit "Any" is not allowed [explicit-any]
+ src/trio/_tests/test_ssl.py:801: error: Explicit "Any" is not allowed [explicit-any]
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_implementations.py:1155: error: No overload variant of "builds" of "BuildsFn" matches argument types "type[DataclassInstance]", "dict[str, int | float | Path | DataClass_ | type[DataClass_] | ListConfig | DictConfig | Enum | Sequence[HydraSupportedType] | Mapping[Any, HydraSupportedType] | None]", "bool | None", "Literal['none', 'partial', 'all', 'object'] | None", "DataclassOptions" [call-overload]
+ src/hydra_zen/structured_configs/_implementations.py:1155: error: No overload variant of "builds" of "BuildsFn" matches argument types "type[DataclassInstance]", "dict[str, int | float | memoryview[Any] | Path | DataClass_ | <6 more items> | None]", "bool | None", "Literal['none', 'partial', 'all', 'object'] | None", "DataclassOptions" [call-overload]
- src/hydra_zen/structured_configs/_implementations.py:2712: error: Incompatible types in assignment (expression has type "tuple[int | float | Path | DataClass_ | type[DataClass_] | ListConfig | DictConfig | Enum | Sequence[HydraSupportedType] | Mapping[Any, HydraSupportedType] | None, ...]", variable has type "list[Importable | Callable[P, R] | type[Builds[Importable]] | type[BuildsWithSig[Importable, Any]] | type[BuildsWithSig[type[R], P]] | Any]") [assignment]
+ src/hydra_zen/structured_configs/_implementations.py:2712: error: Incompatible types in assignment (expression has type "tuple[int | float | memoryview[Any] | Path | DataClass_ | <6 more items> | None, ...]", variable has type "list[Importable | Callable[P, R] | type[Builds[Importable]] | type[BuildsWithSig[Importable, Any]] | type[BuildsWithSig[type[R], P]] | Any]") [assignment]
apprise (https://github.com/caronc/apprise)
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "IRCMessage" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "IRCMessage" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "IRCAction" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "IRCAction" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "IRCContext" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "IRCContext" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "IRCContext" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "IRCContext" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "XMPPConfig" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "XMPPConfig" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "IRCContext" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "IRCContext" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "IRCAction" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "IRCAction" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "XMPPConfig" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "XMPPConfig" defined here
aioredis (https://github.com/aio-libs/aioredis)
- aioredis/connection.py:933: error: Unsupported right operand type for in ("bytes | memoryview[int] | int") [operator]
+ aioredis/connection.py:933: error: Unsupported right operand type for in ("bytes | memoryview[Any] | int") [operator]
- aioredis/connection.py:934: error: Item "memoryview[int]" of "bytes | memoryview[int] | int" has no attribute "split" [union-attr]
+ aioredis/connection.py:934: error: Item "memoryview[Any]" of "bytes | memoryview[Any] | int" has no attribute "split" [union-attr]
- aioredis/connection.py:934: error: Item "int" of "bytes | memoryview[int] | int" has no attribute "split" [union-attr]
+ aioredis/connection.py:934: error: Item "int" of "bytes | memoryview[Any] | int" has no attribute "split" [union-attr]
- aioredis/client.py:4114: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview[int], Any | None]", variable has type "dict[bytes | str | memoryview[int], Callable[[dict[str, str]], Awaitable[None]]]") [assignment]
+ aioredis/client.py:4114: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview[Any], Any | None]", variable has type "dict[bytes | str | memoryview[Any], Callable[[dict[str, str]], Awaitable[None]]]") [assignment]
- aioredis/client.py:4158: error: Argument 1 to "update" of "MutableMapping" has incompatible type "dict[bytes | str | memoryview[int], Any | None]"; expected "SupportsKeysAndGetItem[bytes | str | memoryview[int], Callable[[dict[str, str]], Awaitable[None]]]" [arg-type]
+ aioredis/client.py:4158: error: Argument 1 to "update" of "MutableMapping" has incompatible type "dict[bytes | str | memoryview[Any], Any | None]"; expected "SupportsKeysAndGetItem[bytes | str | memoryview[Any], Callable[[dict[str, str]], Awaitable[None]]]" [arg-type]
- aioredis/client.py:4172: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview[int], Callable[[dict[str, str]], Awaitable[None]]]", variable has type "dict[Any, Any | None]") [assignment]
+ aioredis/client.py:4172: error: Incompatible types in assignment (expression has type "dict[bytes | str | memoryview[Any], Callable[[dict[str, str]], Awaitable[None]]]", variable has type "dict[Any, Any | None]") [assignment]
zulip (https://github.com/zulip/zulip)
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "SubTest" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "SubTest" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "SubmessageFixture" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "SubmessageFixture" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "FileFixture" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "FileFixture" defined here
ibis (https://github.com/ibis-project/ibis)
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "Any" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "Any" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:118: note: "__init__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:119: note: "__init__" of "object" defined here
prefect (https://github.com/PrefectHQ/prefect)
- ...typeshed_to_test/stdlib/builtins.pyi:140: note: "__init_subclass__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:141: note: "__init_subclass__" of "object" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:140: note: "__init_subclass__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:141: note: "__init_subclass__" of "object" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:140: note: "__init_subclass__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:141: note: "__init_subclass__" of "object" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:140: note: "__init_subclass__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:141: note: "__init_subclass__" of "object" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:140: note: "__init_subclass__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:141: note: "__init_subclass__" of "object" defined here
strawberry (https://github.com/strawberry-graphql/strawberry)
- ...typeshed_to_test/stdlib/builtins.pyi:140: note: "__init_subclass__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:141: note: "__init_subclass__" of "object" defined here
- ...typeshed_to_test/stdlib/builtins.pyi:140: note: "__init_subclass__" of "object" defined here
+ ...typeshed_to_test/stdlib/builtins.pyi:141: note: "__init_subclass__" of "object" defined here
|
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.
No description provided.