Skip to content
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

Eliminated some differences between the treatment of type and `Type… #6551

Merged
merged 1 commit into from
Nov 26, 2023

Conversation

erictraut
Copy link
Collaborator

…`. These should be treated the same under all circumstances. This addresses #6252.

…`. These should be treated the same under all circumstances. This addresses #6252.
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

spack (https://github.com/spack/spack)
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/patch.py:148:59 - error: Cannot access member "namespace" for type "type*"
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/patch.py:148:59 - error: Cannot access member "namespace" for type "type[Any]*"
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/patch.py:148:74 - error: Cannot access member "name" for type "type*"
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/patch.py:148:74 - error: Cannot access member "name" for type "type[Any]*"
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/repo.py:1130:48 - error: Cannot access member "name" for type "type"
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/repo.py:1130:48 - error: Cannot access member "name" for type "type[Any]"
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/repo.py:1128:45 - error: Cannot access member "name" for type "type"
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/repo.py:1128:45 - error: Cannot access member "name" for type "type[Any]"
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/repo.py:1226:74 - error: Cannot access member "virtual" for type "type"
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/repo.py:1226:74 - error: Cannot access member "virtual" for type "type[Any]"

pydantic (https://github.com/samuelcolvin/pydantic)
+   /tmp/mypy_primer/projects/pydantic/pydantic/_internal/_dataclasses.py:280:22 - error: Cannot access member "__dataclass_fields__" for type "type[Any]"
+     Member "__dataclass_fields__" is unknown (reportGeneralTypeIssues)
- 52 errors, 0 warnings, 0 informations 
+ 53 errors, 0 warnings, 0 informations 

steam.py (https://github.com/Gobot1234/steam.py)
+   /tmp/mypy_primer/projects/steam.py/steam/_const.py:77:9 - error: Type of parameter "__multi_dict" is partially unknown
+     Parameter type is "type[Unknown]" (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/steam.py/steam/_const.py:91:9 - error: Type of parameter "__mapper" is partially unknown
+     Parameter type is "type[Unknown]" (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/steam.py/steam/_const.py:101:9 - error: Type of parameter "__mapper" is partially unknown
+     Parameter type is "type[Unknown]" (reportUnknownParameterType)
-   /tmp/mypy_primer/projects/steam.py/steam/ext/commands/commands.py:561:24 - error: Type of "__class__" is partially unknown
-     Type of "__class__" is "type[BasicConverter[Any]] | type[function] | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/steam.py/steam/ext/commands/commands.py:561:24 - error: Type of "__name__" is partially unknown
-     Type of "__name__" is "str | Unknown" (reportUnknownMemberType)
- 8391 errors, 23 warnings, 0 informations 
+ 8392 errors, 23 warnings, 0 informations 

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+   /tmp/mypy_primer/projects/Tanjun/docs_src/usage.py:61:6 - warning: Type of "with_listener" is partially unknown
+     Type of "with_listener" is "(*event_types: type[Unknown]) -> ((_ListenerCallbackSigT@with_listener) -> _ListenerCallbackSigT@with_listener)" (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/__init__.py:249:23 - warning: Type of "with_channel_slash_option" is partially unknown
+     Type of "with_channel_slash_option" is "(name: str | Mapping[str, str], description: str | Mapping[str, str], /, *, types: Collection[type[Unknown] | int] | None = None, default: Any = tanjun.NO_DEFAULT, key: str | None = None, pass_as_kwarg: bool = True) -> ((_SlashCommandT@with_channel_slash_option) -> _SlashCommandT@with_channel_slash_option)" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/abc.py:3321:9 - error: Return type, "Mapping[type[Unknown], Collection[(Any, ...) -> Coroutine[Any, Any, None]]]", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/abc.py:3585:16 - error: Type of parameter "event_types" is partially unknown
+     Parameter type is "type[Unknown]" (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/abc.py:3979:9 - error: Return type, "Mapping[type[Unknown], Collection[(Any, ...) -> Coroutine[Any, Any, None]]]", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/abc.py:4524:16 - error: Type of parameter "event_types" is partially unknown
+     Parameter type is "type[Unknown]" (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:276:5 - warning: Type of "_ChannelTypeIsh" is partially unknown
+     Type of "_ChannelTypeIsh" is "type[type[Unknown]] | type[int]" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:415:9 - error: Type of parameter "channel_types" is partially unknown
+     Parameter type is "Sequence[type[Unknown] | int]" (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:457:32 - warning: Type of "_channel_types" is partially unknown
+     Type of "_channel_types" is "Sequence[type[Unknown] | int]" (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:457:55 - warning: Type of "channel_types" is partially unknown
+     Type of "channel_types" is "Sequence[type[Unknown] | int]" (reportUnknownMemberType)
-     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
+     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type[Unknown] | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
-     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
+     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type[Unknown] | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:601:5 - error: Type of parameter "channel_types" is partially unknown
+     Parameter type is "Sequence[type[Unknown] | int]" (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:617:5 - error: Type of parameter "channel_types" is partially unknown
+     Parameter type is "Sequence[type[Unknown] | int]" (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/Tanjun/tanjun/annotations.py:632:5 - error: Type of parameter "channel_types" is partially unknown
+     Parameter type is "Sequence[type[Unknown] | int]" (reportUnknownParameterType)
-     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
+     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type[Unknown] | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
-     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
+     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type[Unknown] | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)
-     Type of "new" is "(option_type: type[_T@new], /, *, channel_types: Sequence[type | int] = (), choices: Mapping[str, int | float | str] | None = None, default: Any = tanjun.NO_DEFAULT, description: str = "", empty_value: Any = tanjun.NO_DEFAULT, greedy: bool | None = None, message_names: Sequence[str] = (), min_length: int | None = None, max_length: int | None = None, min_value: int | float | None = None, max_value: int | float | None = None, positional: bool | None = None, slash_name: str = "", snowflake_converter: ((str) -> Unknown) | None = None, str_converters: ((str, ...) -> (Coroutine[Any, Any, Any] | Any)) | Sequence[(str, ...) -> (Coroutine[Any, Any, Any] | Any)] = ()) -> _T@new" (reportUnknownMemberType)

... (truncated 336 lines) ...

antidote (https://github.com/Finistere/antidote)
+   /tmp/mypy_primer/projects/antidote/src/antidote/lib/interface_ext/_interface.py:611:9 - error: Type of "dependency" is partially unknown
+     Type of "dependency" is "LazyValue[Unknown]" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/antidote/src/antidote/lib/interface_ext/_interface.py:618:42 - error: Argument type is partially unknown
+     Argument corresponds to parameter "dependency" in function "set_default"
+     Argument type is "LazyValue[object] | LazyValue[Unknown]" (reportUnknownArgumentType)
- 711 errors, 31 warnings, 0 informations 
+ 713 errors, 31 warnings, 0 informations 

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/funcs.py:81:34 - error: Argument of type "type | ((...) -> Any) | _Wrapper" cannot be assigned to parameter "__object" of type "_Wrapper" in function "append"
+     Type "type | ((...) -> Any) | _Wrapper" cannot be assigned to type "_Wrapper" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/funcs.py:92:23 - error: Argument of type "type | ((...) -> Any)" cannot be assigned to parameter of type "(...) -> Any"
+     Type "type | ((...) -> Any)" cannot be assigned to type "(...) -> Any" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/funcs.py:99:35 - error: Argument of type "type | ((...) -> Any)" cannot be assigned to parameter "__func" of type "(...) -> _T@partial" in function "__new__"
+     Type "type | ((...) -> Any)" cannot be assigned to type "(...) -> _T@partial" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/_utils/coerce.py:115:29 - error: Argument of type "type[Any]* | _T@coerce_sequences" cannot be assigned to parameter "obj" of type "_IntrospectableCallable" in function "signature"
+     Type "type[Any]* | ((...) -> Unknown)" cannot be assigned to type "_IntrospectableCallable" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/_utils/coerce.py:181:12 - error: Argument of type "type[Any]* | _T@coerce_sequences" cannot be assigned to parameter "wrapped" of type "(**_PWrapped@wraps) -> _RWrapped@wraps" in function "wraps"
+     Type "type[Any]* | ((...) -> Unknown)" cannot be assigned to type "(**_PWrapped@wraps) -> _RWrapped@wraps" (reportGeneralTypeIssues)
- 144 errors, 0 warnings, 174 informations 
+ 149 errors, 0 warnings, 174 informations 

discord.py (https://github.com/Rapptz/discord.py)
-     Type "tuple[type] | tuple[type, ...]" cannot be assigned to type "Tuple[type]"
+     Type "tuple[Type[Any]] | tuple[Type[Any], ...]" cannot be assigned to type "Tuple[Type[Any]]"
-       "tuple[type, ...]" is incompatible with "Tuple[type]"
+       "tuple[Type[Any], ...]" is incompatible with "Tuple[Type[Any]]"

pandera (https://github.com/pandera-dev/pandera)
-   /tmp/mypy_primer/projects/pandera/pandera/backends/pyspark/decorators.py:26:61 - error: Expression of type "None" cannot be assigned to parameter of type "List[type]"
+   /tmp/mypy_primer/projects/pandera/pandera/backends/pyspark/decorators.py:26:61 - error: Expression of type "None" cannot be assigned to parameter of type "List[Type[Unknown]]"
-     "None" is incompatible with "List[type]" (reportGeneralTypeIssues)
+     "None" is incompatible with "List[Type[Unknown]]" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/pandera/pandera/backends/pyspark/decorators.py:47:34 - error: Cannot access member "typeName" for type "type"
+   /tmp/mypy_primer/projects/pandera/pandera/backends/pyspark/decorators.py:47:34 - error: Cannot access member "typeName" for type "Type[Unknown]"
-   /tmp/mypy_primer/projects/pandera/pandera/backends/pyspark/decorators.py:67:27 - error: Cannot access member "typeName" for type "type"
+   /tmp/mypy_primer/projects/pandera/pandera/backends/pyspark/decorators.py:67:27 - error: Cannot access member "typeName" for type "Type[Unknown]"
-   /tmp/mypy_primer/projects/pandera/pandera/engines/engine.py:199:20 - error: Expression of type "type*" cannot be assigned to return type "type[_DataType@register_dtype]"
-     Type "type*" cannot be assigned to type "type[_DataType@register_dtype]" (reportGeneralTypeIssues)
-     "None" is incompatible with "type" (reportGeneralTypeIssues)
+     "None" is incompatible with "Type[Unknown]" (reportGeneralTypeIssues)
- 1208 errors, 10 warnings, 0 informations 
+ 1207 errors, 10 warnings, 0 informations 

dd-trace-py (https://github.com/DataDog/dd-trace-py)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/contrib/aws_lambda/patch.py:241:14 - error: Argument of type "Unknown | type | Any" cannot be assigned to parameter "f" of type "FunctionType" in function "wrap"
-     Type "Unknown | type | Any" cannot be assigned to type "FunctionType"
-       "type" is incompatible with "FunctionType" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/contrib/aws_lambda/patch.py:264:16 - error: Argument of type "Unknown | type | Any" cannot be assigned to parameter "wf" of type "WrappedFunction" in function "unwrap"
-     Type "Unknown | type | Any" cannot be assigned to type "WrappedFunction"
-       "type" is incompatible with protocol "WrappedFunction"
-         "__dd_wrapped__" is not present
-         "__dd_wrappers__" is not present (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/tests/utils.py:1256:14 - error: Cannot assign member "pytestmark" for type "type"
+   /tmp/mypy_primer/projects/dd-trace-py/tests/utils.py:1256:14 - error: Cannot assign member "pytestmark" for type "type[Any]"
-   /tmp/mypy_primer/projects/dd-trace-py/tests/utils.py:1258:10 - error: Cannot access member "pytestmark" for type "type"
+   /tmp/mypy_primer/projects/dd-trace-py/tests/utils.py:1258:10 - error: Cannot access member "pytestmark" for type "type[Any]"
- 9459 errors, 464 warnings, 0 informations 
+ 9457 errors, 464 warnings, 0 informations 

@erictraut erictraut merged commit f5ff92a into main Nov 26, 2023
12 checks passed
@erictraut erictraut deleted the issue6252-2 branch November 26, 2023 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant