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

Fixed a bug that results in noncompliance with the typing spec when a… #9910

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

erictraut
Copy link
Collaborator

__new__ method has an explicit Any return type annotation. In this case, type checkers should assume that the return type of __new__ is not a subtype of the containing class and should therefore ignore the __init__ method. This addresses #9909.

… `__new__` method has an explicit `Any` return type annotation. In this case, type checkers should assume that the return type of `__new__` is _not_ a subtype of the containing class and should therefore ignore the `__init__` method. This addresses #9909.
Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
- /tmp/mypy_primer/projects/sympy/sympy/physics/quantum/circuitplot.py
-   /tmp/mypy_primer/projects/sympy/sympy/physics/quantum/circuitplot.py:367:20 - error: No overloads for "__init__" match the provided arguments
-     Argument types: (Unknown, Unknown) (reportCallIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/physics/quantum/circuitplot.py:369:48 - error: Expected 0 positional arguments (reportCallIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/physics/quantum/tests/test_circuitplot.py:18:12 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/physics/quantum/tests/test_circuitplot.py:18:16 - error: Argument of type "__class_CreateOneQubitGate" cannot be assigned to parameter "object" of type "ReadableBuffer" in function "__new__"
-     "__class_CreateOneQubitGate" is incompatible with protocol "Buffer"
-       "__buffer__" is not present (reportArgumentType)
-   /tmp/mypy_primer/projects/sympy/sympy/physics/quantum/tests/test_circuitplot.py:18:22 - error: Expected 0 positional arguments (reportCallIssue)
- 33107 errors, 73 warnings, 0 informations 
+ 33102 errors, 73 warnings, 0 informations 

core (https://github.com/home-assistant/core)
-   /tmp/mypy_primer/projects/core/homeassistant/helpers/entity_registry.py:91:39 - error: Argument of type "enumerate[Unknown]" cannot be assigned to parameter "iterable" of type "Iterable[list[bytes]]" in function "__init__"
-     "enumerate[Unknown]" is incompatible with protocol "Iterable[list[bytes]]"
-       "__iter__" is an incompatible type
-         Type "() -> enumerate[Unknown]" is not assignable to type "() -> Iterator[_T_co@Iterable]"
-           Function return type "enumerate[Unknown]" is incompatible with type "Iterator[_T_co@Iterable]"
-             "enumerate[Unknown]" is incompatible with protocol "Iterator[_T_co@Iterable]" (reportArgumentType)
- 65799 errors, 293 warnings, 0 informations 
+ 65798 errors, 293 warnings, 0 informations 

antidote (https://github.com/Finistere/antidote)
+   /tmp/mypy_primer/projects/antidote/src/antidote/__init__.py:141:34 - warning: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 744 errors, 77 warnings, 0 informations 
+ 744 errors, 78 warnings, 0 informations 

spark (https://github.com/apache/spark)
-   /tmp/mypy_primer/projects/spark/python/pyspark/sql/tests/test_observation.py:49:13 - error: Object of type "Dict[str, Any]" is not callable
-     Attribute "__call__" is unknown (reportCallIssue)
-   /tmp/mypy_primer/projects/spark/python/pyspark/sql/tests/test_observation.py:94:25 - error: Argument of type "Literal[123]" cannot be assigned to parameter "name" of type "str | None" in function "__init__"
-     Type "Literal[123]" is not assignable to type "str | None"
-       "Literal[123]" is not assignable to "str"
-       "Literal[123]" is not assignable to "None" (reportArgumentType)
- 26077 errors, 327 warnings, 0 informations 
+ 26075 errors, 327 warnings, 0 informations 

tornado (https://github.com/tornadoweb/tornado)
+   /tmp/mypy_primer/projects/tornado/tornado/test/ioloop_test.py:466:26 - error: "add_callback" is not a known attribute of "None" (reportOptionalMemberAccess)
+   /tmp/mypy_primer/projects/tornado/tornado/test/ioloop_test.py:467:26 - error: "start" is not a known attribute of "None" (reportOptionalMemberAccess)
- 312 errors, 66 warnings, 0 informations 
+ 314 errors, 66 warnings, 0 informations 

@erictraut erictraut merged commit 0622bb8 into main Feb 13, 2025
18 checks passed
@erictraut erictraut deleted the issue-9909 branch February 13, 2025 18:16
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