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

Fix __new__ and __init__ precedence #18093

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Nov 3, 2024

Fixes #5647

See also #5642

This PR shouldn't be merged as currently. Just opening it to see primer and as a reminder. We need to do something cleverer that handles the full constructor chain.

Copy link
Contributor

github-actions bot commented Nov 3, 2024

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

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/utilities/hashing.py:61: error: Argument 1 to "dumps" of "Serializer" has incompatible type "tuple[tuple[Any, ...], dict[str, Any]]"; expected "D"  [arg-type]
- src/prefect/results.py:1175: note: "_cache_object" of "BaseResult" defined here
- src/prefect/results.py:1371: error: Unexpected keyword argument "storage_block" for "_cache_object" of "BaseResult"  [call-arg]
- src/prefect/results.py:1371: error: Unexpected keyword argument "serializer" for "_cache_object" of "BaseResult"  [call-arg]
- src/prefect/logging/formatters.py:65: error: Argument 1 to "dumps" of "Serializer" has incompatible type "dict[str, Any]"; expected "D"  [arg-type]

rclip (https://github.com/yurijmikhalevich/rclip)
+ rclip/main.py:101: error: Need type annotation for "pbar"  [var-annotated]

beartype (https://github.com/beartype/beartype)
+ beartype/_check/error/errget.py:579: error: Unused "type: ignore" comment  [unused-ignore]

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/datatypes.py:94: error: Unused "type: ignore" comment  [unused-ignore]

mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ bson/dbref.py:98: error: Need type annotation for "doc"  [var-annotated]

trio (https://github.com/python-trio/trio)
+ src/trio/_tests/test_testing_raisesgroup.py:108: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_testing_raisesgroup.py:122: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_testing_raisesgroup.py:133: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_testing_raisesgroup.py:211: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_testing_raisesgroup.py:213: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/test_testing_raisesgroup.py:216: error: Need type annotation for "rg"  [var-annotated]
+ src/trio/_tests/test_testing_raisesgroup.py:223: error: Need type annotation for "exc"  [var-annotated]
+ src/trio/_tests/test_testing_raisesgroup.py:230: error: Need type annotation for "rg"  [var-annotated]
+ src/trio/_tests/test_testing_raisesgroup.py:372: error: Need type annotation for "excinfo"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:32: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:51: error: Need type annotation for "e"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:53: error: Expression is of type "BaseExceptionGroup[Any]", not "BaseExceptionGroup[ValueError]"  [assert-type]
+ src/trio/_tests/type_tests/raisesgroup.py:60: error: Expression is of type "BaseExceptionGroup[Never]", not "BaseExceptionGroup[ValueError]"  [assert-type]
+ src/trio/_tests/type_tests/raisesgroup.py:71: error: Expression is of type "BaseExceptionGroup[Never]", not "BaseExceptionGroup[ValueError]"  [assert-type]
+ src/trio/_tests/type_tests/raisesgroup.py:118: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:121: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:125: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:128: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:132: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:133: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:155: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:158: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:162: error: Need type annotation for "e"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:165: error: Expression is of type "BaseExceptionGroup[Any]", not "BaseExceptionGroup[ValueError]"  [assert-type]
+ src/trio/_tests/type_tests/raisesgroup.py:169: error: Need type annotation for "excinfo"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:180: error: Expression is of type "BaseExceptionGroup[Any]", not "BaseExceptionGroup[RaisesGroup[ValueError]]"  [assert-type]
+ src/trio/_tests/type_tests/raisesgroup.py:187: error: Expression is of type "Union[Any, BaseExceptionGroup[Any]]", not "Union[RaisesGroup[ValueError], BaseExceptionGroup[RaisesGroup[ValueError]]]"  [assert-type]
+ src/trio/_tests/type_tests/raisesgroup.py:201: error: Expression is of type "BaseExceptionGroup[Never]", not "BaseExceptionGroup[RaisesGroup[ValueError]]"  [assert-type]
+ src/trio/_tests/type_tests/raisesgroup.py:205: error: Need type annotation for "a"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:206: error: Need type annotation for "b"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:207: error: Need type annotation for "c"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:218: error: Need type annotation for "a"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:219: error: Need type annotation for "b"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:220: error: Need type annotation for "c"  [var-annotated]
+ src/trio/_tests/type_tests/raisesgroup.py:232: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:234: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:236: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:238: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_tests/type_tests/raisesgroup.py:245: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_tests/test_run.py:458: error: Need type annotation for "excinfo"  [var-annotated]
+ src/trio/_core/_tests/test_run.py:806: error: Need type annotation for "group"  [var-annotated]

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.

Prefer __new__ over __init__ for determining callable type of a class
1 participant