-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Improve yaml/constructor.pyi
types
#12404
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When updating mypy to 1.11.0 in typeddjango/django-stubs#2269 I noticed this: ``` ______________________________ import_all_modules ______________________________ /home/runner/work/django-stubs/django-stubs/tests/typecheck/test_import_all.yml:2: E pytest_mypy_plugins.utils.TypecheckAssertionError: Output is not expected: E Actual: E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:87: error: Signature of "find_python_module" incompatible with supertype "FullConstructor" [override] (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:87: note: Superclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:87: note: def find_python_module(self, name: Any, mark: Any, unsafe: Any = ...) -> Any (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:87: note: Subclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:87: note: def find_python_module(self, name: Any, mark: Any) -> Any (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:88: error: Signature of "find_python_name" incompatible with supertype "FullConstructor" [override] (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:88: note: Superclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:88: note: def find_python_name(self, name: Any, mark: Any, unsafe: Any = ...) -> Any (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:88: note: Subclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:88: note: def find_python_name(self, name: Any, mark: Any) -> Any (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:89: error: Signature of "make_python_instance" incompatible with supertype "FullConstructor" [override] (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:89: note: Superclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:89: note: def make_python_instance(self, suffix: Any, node: Any, args: Any = ..., kwds: Any = ..., newobj: Any = ..., unsafe: Any = ...) -> Any (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:89: note: Subclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:89: note: def make_python_instance(self, suffix: Any, node: Any, args: Any = ..., kwds: Any = ..., newobj: Any = ...) -> Any (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:90: error: Signature of "set_python_instance_state" incompatible with supertype "FullConstructor" [override] (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:90: note: Superclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:90: note: def set_python_instance_state(self, instance: Any, state: Any, unsafe: bool = ...) -> None (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:90: note: Subclass: (diff) E ../../opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/yaml-stubs/constructor.pyi:90: note: def set_python_instance_state(self, instance: Any, state: Any) -> Any (diff) E Expected: E (empty) =========================== short test summary info ============================ ``` This happens because `UnsafeConstructor` has unsafe method overrides and new mypy detects this. So, I added just some simple annotations so it can detect it now as well.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
srittau
approved these changes
Jul 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When updating mypy to 1.11.0 in typeddjango/django-stubs#2269 I noticed this:
This happens because
UnsafeConstructor
has unsafe method overrides and new mypy detects this.So, I added just some simple annotations so it can detect it now as well.