microsoft / pyright

Static Type Checker for Python
Other
13.37k stars 1.46k forks source link

Partial solution for 8691 #8754

Closed erictraut closed 2 months ago

github-actions[bot] commented 2 months ago

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

pydantic (https://github.com/pydantic/pydantic)
+   /tmp/mypy_primer/projects/pydantic/pydantic/_internal/_generate_schema.py:1592:45 - error: Object of type "AliasGenerator" is not callable
+     Attribute "__call__" is unknown (reportCallIssue)
- 265 errors, 47 warnings, 0 informations 
+ 266 errors, 47 warnings, 0 informations 

pip (https://github.com/pypa/pip)
+   /tmp/mypy_primer/projects/pip/src/pip/_vendor/typing_extensions.py:758:17 - error: Cannot assign to attribute "__non_callable_proto_members__" for class "<subclass of type[Generic] and _ProtocolMeta>"
+     Attribute "__non_callable_proto_members__" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/pip/src/pip/_vendor/typing_extensions.py:769:29 - error: Cannot access attribute "__non_callable_proto_members__" for class "<subclass of type[Generic] and _ProtocolMeta>"
+     Attribute "__non_callable_proto_members__" is unknown (reportAttributeAccessIssue)
- 1835 errors, 42 warnings, 0 informations 
+ 1837 errors, 42 warnings, 0 informations 

core (https://github.com/home-assistant/core)
+   /tmp/mypy_primer/projects/core/homeassistant/config_entries.py:924:54 - error: Cannot access attribute "VERSION" for class "function"
+     Attribute "VERSION" is unknown (reportFunctionMemberAccess)
+   /tmp/mypy_primer/projects/core/homeassistant/config_entries.py:925:65 - error: Cannot access attribute "MINOR_VERSION" for class "function"
+     Attribute "MINOR_VERSION" is unknown (reportFunctionMemberAccess)
+   /tmp/mypy_primer/projects/core/homeassistant/components/http/__init__.py:395:41 - error: Cannot access attribute "__name__" for class "property"
+     Attribute "__name__" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/core/homeassistant/components/http/__init__.py:399:41 - error: Cannot access attribute "__name__" for class "property"
+     Attribute "__name__" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/core/homeassistant/components/http/__init__.py:402:9 - error: Argument missing for parameter "router" (reportCallIssue)
- 23816 errors, 353 warnings, 0 informations 
+ 23821 errors, 353 warnings, 0 informations 

kornia (https://github.com/kornia/kornia)
+   /tmp/mypy_primer/projects/kornia/kornia/utils/helpers.py:327:72 - error: Argument of type "DataclassInstance | type[DataclassInstance]" cannot be assigned to parameter "obj" of type "DataclassInstance" in function "asdict"
+     Type "DataclassInstance | type[DataclassInstance]" is incompatible with type "DataclassInstance"
+       "__dataclass_fields__" is defined as a ClassVar in protocol (reportArgumentType)
+   /tmp/mypy_primer/projects/kornia/kornia/utils/helpers.py:349:62 - error: Argument of type "type[Any] | str | Any" cannot be assigned to parameter "dataclass_type" of type "type[T@dict_to_dataclass]" in function "dict_to_dataclass"
+     Type "type[Any] | str | Any" is incompatible with type "type[T@dict_to_dataclass]" (reportArgumentType)
- 5579 errors, 9 warnings, 0 informations 
+ 5581 errors, 9 warnings, 0 informations 

pytest (https://github.com/pytest-dev/pytest)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/python_api.py:948:53 - error: Expression of type "tuple[<subclass of type[BaseException]* and type>* | <subclass of tuple[type[E@raises], ...] and type>]" is incompatible with declared type "tuple[type[E@raises], ...]"
+     Type "<subclass of type[BaseException]* and type>* | <subclass of tuple[type[E@raises], ...] and type>" is incompatible with type "type[E@raises]" (reportAssignmentType)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/python_api.py:950:31 - error: Expression of type "type[BaseException]* | tuple[type[E@raises], ...]" is incompatible with declared type "tuple[type[E@raises], ...]"
+     Type "type[BaseException]* | tuple[type[E@raises], ...]" is incompatible with type "tuple[type[E@raises], ...]"
+       "type[type]" is incompatible with "type[tuple[type[E@raises], ...]]" (reportAssignmentType)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/python_api.py:973:16 - error: "<subclass of type[BaseException]* and type>*" is not iterable
+     "__iter__" method not defined (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/python_api.py:973:16 - error: "<subclass of type[BaseException]* and type>* | <subclass of tuple[type[E@raises], ...] and type> | type[BaseException]* | tuple[type[E@raises], ...]" is not a valid exception class (reportGeneralTypeIssues)
+     Attribute "__dataclass_params__" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/pytest/src/_pytest/_io/pprint.py:116:24 - error: Cannot access attribute "__dataclass_params__" for class "type[DataclassInstance]"
- 774 errors, 39 warnings, 0 informations 
+ 779 errors, 39 warnings, 0 informations 

bokeh (https://github.com/bokeh/bokeh)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/bases.py:372:33 - error: Argument of type "HasProps | type[HasProps]" cannot be assigned to parameter of type "HasProps"
+     Type "HasProps | type[HasProps]" is incompatible with type "HasProps"
+       "type[MetaHasProps]" is incompatible with "type[HasProps]" (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/bases.py:380:35 - error: Argument of type "HasProps | type[HasProps]" cannot be assigned to parameter of type "HasProps"
+     Type "HasProps | type[HasProps]" is incompatible with type "HasProps"
+       "type[MetaHasProps]" is incompatible with "type[HasProps]" (reportArgumentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/bases.py:479:30 - error: Expression of type "str" is incompatible with declared type "TypeOrInst[Property[Any]]"
+     Type "str" is incompatible with type "TypeOrInst[Property[Any]]"
+       Type "str" is incompatible with type "type[Property[Any]]"
+       "str" is incompatible with "Property[Any]" (reportAssignmentType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/bases.py:481:27 - error: Cannot access attribute "_help" for class "type[Property[Any]]"
+     Attribute "_help" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/bases.py:484:20 - error: Expression of type "TypeOrInst[Property[Any]] | type[Property[Any]]" is incompatible with return type "Property[Any]"
+     Type "TypeOrInst[Property[Any]] | type[Property[Any]]" is incompatible with type "Property[Any]"
+       "type[type]" is incompatible with "type[Property[Any]]" (reportReturnType)
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/include.py:64:27 - error: "Never" is not iterable (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/instance.py:99:29 - error: Expression of type "type[object]* | type" is incompatible with declared type "type[Serializable]"
-     Type "type[object]* | type" is incompatible with type "type[Serializable]"
-       "type[object]*" is incompatible with "type[Serializable]"
-       Type "type[object]*" is incompatible with type "type[Serializable]" (reportAssignmentType)
-   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/instance.py:106:29 - error: Expression of type "type[T@Object]" is incompatible with declared type "type[Serializable]"
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/instance.py:106:29 - error: Expression of type "object* | type[T@Object]" is incompatible with declared type "type[Serializable]"
-     "type[object]*" is incompatible with "type[Serializable]"
+     Type "object* | type[object]*" is incompatible with type "type[Serializable]"
-     Type "type[T@Object]" is incompatible with type "type[Serializable]" (reportAssignmentType)
+       Type "object*" is incompatible with type "type[Serializable]" (reportAssignmentType)
-   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/instance.py:110:16 - error: Expression of type "type[Serializable]" is incompatible with return type "type[T@Object]"
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/core/property/instance.py:110:16 - error: Expression of type "type* | type | type[Serializable]" is incompatible with return type "type[T@Object]"
-     Type "type[Serializable]" is incompatible with type "type[T@Object]" (reportReturnType)
+     Type "type* | type | type[Serializable]" is incompatible with type "type[T@Object]" (reportReturnType)
-   /tmp/mypy_primer/projects/bokeh/src/bokeh/document/document.py:726:24 - error: Expression of type "dict[str, type[Model]]" is incompatible with declared type "SelectorType | type[Model]"
-     Type "dict[str, type[Model]]" is incompatible with type "SelectorType | type[Model]"
-       "dict[str, type[Model]]" is incompatible with "dict[str | type[_Operator], Any]"
-         Type parameter "_KT@dict" is invariant, but "str" is not the same as "str | type[_Operator]"
-       Type "dict[str, type[Model]]" is incompatible with type "type[Model]" (reportAssignmentType)
-   /tmp/mypy_primer/projects/bokeh/src/bokeh/document/document.py:727:32 - error: Argument of type "SelectorType | type[Model]" cannot be assigned to parameter "selector" of type "SelectorType" in function "select"
+   /tmp/mypy_primer/projects/bokeh/src/bokeh/document/document.py:727:32 - error: Argument of type "SelectorType | type[Model] | <subclass of dict[str | type[_Operator], Any] and type> | <subclass of type[Model] and type>" cannot be assigned to parameter "selector" of type "SelectorType" in function "select"
-     Type "SelectorType | type[Model]" is incompatible with type "SelectorType"
+     Type "SelectorType | type[Model] | <subclass of dict[str | type[_Operator], Any] and type> | <subclass of type[Model] and type>" is incompatible with type "SelectorType"
-       "type[MetaHasProps]" is incompatible with "type[dict[str | type[_Operator], Any]]" (reportArgumentType)
+       "<subclass of type[Model] and type>" is incompatible with "dict[str | type[_Operator], Any]" (reportArgumentType)
- 3517 errors, 305 warnings, 0 informations 
+ 3521 errors, 305 warnings, 0 informations 

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:334:19 - error: Argument of type "Command | type[Command]" cannot be assigned to parameter "a" of type "PlaybookEntry | Iterable[PlaybookEntry]" in function "eq" (reportArgumentType)
-   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:346:25 - error: Argument of type "type[Command]" cannot be assigned to parameter "key" of type "Command" in function "__getitem__"
+   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:346:25 - error: Argument of type "type[Command] | type[type]" cannot be assigned to parameter "key" of type "Command" in function "__getitem__"
+     Type "type[Command] | type[type]" is incompatible with type "Command"
-     "type[type]" is incompatible with "type[Command]" (reportArgumentType)
+       "type[type]" is incompatible with "type[Command]" (reportArgumentType)
-   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:348:30 - error: Argument of type "StartHook | Command" cannot be assigned to parameter "command" of type "StartHook" in function "__init__"
+   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:348:30 - error: Argument of type "StartHook | Command | type[Command]" cannot be assigned to parameter "command" of type "StartHook" in function "__init__"
-     Type "StartHook | Command" is incompatible with type "StartHook"
+     Type "StartHook | Command | type[Command]" is incompatible with type "StartHook"
-   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:378:16 - error: Expression of type "T@_Placeholder | object* | None" is incompatible with return type "T@_Placeholder"
+   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:378:16 - error: Expression of type "T@_Placeholder | None" is incompatible with return type "T@_Placeholder"
-     Type "T@_Placeholder | object* | None" is incompatible with type "T@_Placeholder" (reportReturnType)
+     Type "T@_Placeholder | None" is incompatible with type "T@_Placeholder" (reportReturnType)
-   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:411:16 - error: Expression of type "AnyStr@_AnyStrPlaceholder | object* | None" is incompatible with return type "AnyStr@_AnyStrPlaceholder"
+   /tmp/mypy_primer/projects/mitmproxy/test/mitmproxy/proxy/tutils.py:411:16 - error: Expression of type "AnyStr@_AnyStrPlaceholder | None" is incompatible with return type "AnyStr@_AnyStrPlaceholder"
-     Type "AnyStr@_AnyStrPlaceholder | object* | None" is incompatible with type "AnyStr@_AnyStrPlaceholder" (reportReturnType)
+     Type "AnyStr@_AnyStrPlaceholder | None" is incompatible with type "AnyStr@_AnyStrPlaceholder" (reportReturnType)
- 2499 errors, 331 warnings, 0 informations 
+ 2500 errors, 331 warnings, 0 informations 

setuptools (https://github.com/pypa/setuptools)
+   /tmp/mypy_primer/projects/setuptools/setuptools/_vendor/typing_extensions.py:758:17 - error: Cannot assign to attribute "__non_callable_proto_members__" for class "<subclass of type[Generic] and _ProtocolMeta>"
+     Attribute "__non_callable_proto_members__" is unknown (reportAttributeAccessIssue)
+   /tmp/mypy_primer/projects/setuptools/setuptools/_vendor/typing_extensions.py:769:29 - error: Cannot access attribute "__non_callable_proto_members__" for class "<subclass of type[Generic] and _ProtocolMeta>"
+     Attribute "__non_callable_proto_members__" is unknown (reportAttributeAccessIssue)
- 2620 errors, 65 warnings, 0 informations 
+ 2622 errors, 65 warnings, 0 informations 

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/structured_configs/_implementations.py:2587:48 - error: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
+   /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/wrapper/_implementations.py:944:20 - error: Return type, "type[BuildsWithSig[Unknown, ...]]", is partially unknown (reportUnknownVariableType)
- 179 errors, 15 warnings, 183 informations 
+ 181 errors, 15 warnings, 183 informations 

trio (https://github.com/python-trio/trio)
-   /tmp/mypy_primer/projects/trio/src/trio/testing/_raises_group.py:444:44 - error: Unnecessary issubclass call; "type[BaseException]*" is always a subclass of "BaseException" (reportUnnecessaryIsInstance)
- 3868 errors, 53 warnings, 0 informations 
+ 3867 errors, 53 warnings, 0 informations 

prefect (https://github.com/PrefectHQ/prefect)
+   /tmp/mypy_primer/projects/prefect/src/prefect/flow_engine.py:497:47 - error: Argument missing for parameter "self" (reportCallIssue)
-   /tmp/mypy_primer/projects/prefect/src/prefect/utilities/collections.py:409:29 - error: Cannot access attribute "model_fields_set" for class "type[DataclassInstance]"
-     Attribute "model_fields_set" is unknown (reportAttributeAccessIssue)
-     Attribute "model_fields" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/prefect/src/prefect/utilities/collections.py:409:57 - error: Cannot access attribute "model_fields" for class "type[DataclassInstance]"
-   /tmp/mypy_primer/projects/prefect/src/prefect/utilities/collections.py:427:38 - error: Cannot access attribute "model_fields_set" for class "type[DataclassInstance]"
-     Attribute "model_fields_set" is unknown (reportAttributeAccessIssue)
-     Attribute "__private_attributes__" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/prefect/src/prefect/utilities/collections.py:429:42 - error: Cannot access attribute "__private_attributes__" for class "type[DataclassInstance]"
- 8938 errors, 266 warnings, 0 informations 
+ 8935 errors, 266 warnings, 0 informations