-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Constrain memoryview type var to allowed types #13683
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
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
|
I haven't fully thought this through but #13519 partially made me think that making memoryview generic with a default was a mistake. |
|
I was thinking about that, but I think changing the default to |
|
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:802: 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]
core (https://github.com/home-assistant/core)
- ...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
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
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
arviz (https://github.com/arviz-devs/arviz)
- arviz/data/inference_data.py:500: note: def to_netcdf(self, path: None = ..., mode: Literal['w', 'a'] = ..., format: Literal['NETCDF4', 'NETCDF4_CLASSIC', 'NETCDF3_64BIT', 'NETCDF3_CLASSIC'] | None = ..., group: str | None = ..., engine: Literal['netcdf4', 'scipy', 'h5netcdf'] | None = ..., encoding: Mapping[Any, Mapping[str, Any]] | None = ..., unlimited_dims: Iterable[Hashable] | None = ..., compute: bool = ..., invalid_netcdf: bool = ..., auto_complex: bool | None = ...) -> memoryview[int]
+ arviz/data/inference_data.py:500: note: def to_netcdf(self, path: None = ..., mode: Literal['w', 'a'] = ..., format: Literal['NETCDF4', 'NETCDF4_CLASSIC', 'NETCDF3_64BIT', 'NETCDF3_CLASSIC'] | None = ..., group: str | None = ..., engine: Literal['netcdf4', 'scipy', 'h5netcdf'] | None = ..., encoding: Mapping[Any, Mapping[str, Any]] | None = ..., unlimited_dims: Iterable[Hashable] | None = ..., compute: bool = ..., invalid_netcdf: bool = ..., auto_complex: bool | None = ...) -> memoryview[Any]
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
|
No description provided.