Skip to content

Update mypy to 1.11.0#2269

Merged
sobolevn merged 6 commits into
masterfrom
mypy-1.11
Jul 25, 2024
Merged

Update mypy to 1.11.0#2269
sobolevn merged 6 commits into
masterfrom
mypy-1.11

Conversation

@sobolevn

Copy link
Copy Markdown
Member

Closes #2267

sobolevn added a commit to python/typeshed that referenced this pull request Jul 22, 2024
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.
@sobolevn

Copy link
Copy Markdown
Member Author

Blocked by python/typeshed#12404

@flaeppe

flaeppe commented Jul 23, 2024

Copy link
Copy Markdown
Member

Could perhaps this breakage bring an argument to include django-stubs in mypy_primer? I think it would be possible since hauntsaninja/mypy_primer@83721d5, ref hauntsaninja/mypy_primer#8

@sobolevn

Copy link
Copy Markdown
Member Author

cc @hauntsaninja
What's your opinion?

@hauntsaninja

Copy link
Copy Markdown
Contributor

Yeah, PR welcome!

@sobolevn

Copy link
Copy Markdown
Member Author

hauntsaninja/mypy_primer#124

@sobolevn sobolevn merged commit 5fbe861 into master Jul 25, 2024
@sobolevn sobolevn deleted the mypy-1.11 branch July 25, 2024 06:05
@lordoffreaks

Copy link
Copy Markdown

Hi! Thanks a lot for the work!

I can see 5.0.3 created in the repo but can't see it in https://pypi.org/project/django-stubs/ or in https://github.com/typeddjango/django-stubs/releases ... is there anything I can do to move it there?

Thanks!

@sobolevn

Copy link
Copy Markdown
Member Author

It is not created, I just added it to the docs, so we won't forget.

@flaeppe maybe we should make a new release?

@flaeppe

flaeppe commented Jul 25, 2024

Copy link
Copy Markdown
Member

Sounds good, I've opened #2274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants