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

Inconsistent results after 0.960 -> 0.971 migration #13422

Closed
sobolevn opened this issue Aug 15, 2022 · 8 comments
Closed

Inconsistent results after 0.960 -> 0.971 migration #13422

sobolevn opened this issue Aug 15, 2022 · 8 comments
Labels
bug mypy got something wrong

Comments

@sobolevn
Copy link
Member

sobolevn commented Aug 15, 2022

I am trying to migrate our huge code base from mypy 0.960 to 0.971, but odd things are happening.

For example, our CI fails with:

Run mypy --strict mypy_django_plugin
mypy_django_plugin/django/context.py:61: error: Unused "type: ignore" comment
mypy_django_plugin/django/context.py:62: error: Unused "type: ignore" comment
mypy_django_plugin/django/context.py:87: error: Untyped decorator makes function "model_modules" untyped
mypy_django_plugin/django/context.py:113: error: Returning Any from function declared to return "Optional[Type[Any]]"
mypy_django_plugin/django/context.py:233: error: Untyped decorator makes function "all_registered_model_classes" untyped
mypy_django_plugin/django/context.py:245: error: Untyped decorator makes function "all_registered_model_class_fullnames" untyped
mypy_django_plugin/django/context.py:251: error: Returning Any from function declared to return "str"
mypy_django_plugin/django/context.py:255: error: Returning Any from function declared to return "bool"
mypy_django_plugin/django/context.py:268: error: Returning Any from function declared to return "bool"
mypy_django_plugin/django/context.py:325: error: Unused "type: ignore" comment
mypy_django_plugin/django/context.py:335: error: Returning Any from function declared to return "Optional[Type[Any]]"

Link: https://github.com/typeddjango/django-stubs/runs/7838309248?check_suite_focus=true

Locally it works as expected (python and mypy versions do match):

(.venv) ~/Documents/github/django-stubs  fix-ci ✗                                 
» python --version
Python 3.9.9

(.venv) ~/Documents/github/django-stubs  fix-ci ✗                                    
» mypy --version                  
mypy 0.971 (compiled: yes)

(.venv) ~/Documents/github/django-stubs  fix-ci ✗                                    
» mypy --strict mypy_django_plugin
Success: no issues found in 20 source files

Since we have quite a complex structure, it might be something on our side.
So, what do we do?

We store all stubs for django in django-stubs folder.
At the same level we have mypy_django_plugin that does fancy stuff with ORM / etc.
Our plugin imports a lot of things from django itself (settings, .setup(), etc).

Here's the tricky part: 0.960 recognised these imports and their types.
Right now my local setup with 0.971 does the same thing.

But, 0.971 in our CI does not see our stubs. So, all types are just Anys. This is unexpected!

Link: https://github.com/typeddjango/django-stubs
Original PR: typeddjango/django-stubs#1108

@sobolevn sobolevn added the bug mypy got something wrong label Aug 15, 2022
@sobolevn
Copy link
Member Author

sobolevn commented Aug 15, 2022

Sorry, but I cannot find a reproducer.

@hauntsaninja
Copy link
Collaborator

Can you check if it is fixed with mypy master?
The most problematic change in 0.971 is #11143 , but I fixed known issues with that on master

@sobolevn
Copy link
Member Author

I will take a look!

@hauntsaninja
Copy link
Collaborator

Oh the other thing is if you have editable installs in CI, make sure you're using setuptools < 64.

New setuptools breaks all IDE and static analysis tools. They knew of the issue and did it anyway 🤷

@sobolevn
Copy link
Member Author

🤦

@intgr
Copy link
Contributor

intgr commented Aug 22, 2022

make sure you're using setuptools < 64.

New setuptools breaks all IDE and static analysis tools.

Any upstream discussions about this?

@AlexWaygood
Copy link
Member

make sure you're using setuptools < 64.
New setuptools breaks all IDE and static analysis tools.

Any upstream discussions about this?

pypa/setuptools#3518 (and https://mail.python.org/archives/list/[email protected]/thread/IIVBPYDZR5T5BGPAWFVYS5ZPYDXGVHQN/#OSWHT5VSRGKPSPYD7PQWR2M4OCSL5WO3)

@erictraut
Copy link

Is there anything actionable in this bug report? Was there a repro identified? Did it turn out to be a problem with editable installs?

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

5 participants