-
-
Notifications
You must be signed in to change notification settings - Fork 488
Add support for mypy v1.16 #2703
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
Conversation
@sobolevn Hopefully this covers the remaining changes required... 🤞🏻 |
scripts/stubtest/allowlist.txt
Outdated
# Django incorrectly decorates this with `@classmethod`. | ||
django.test.selenium.SeleniumTestCase.__init_subclass__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__init_subclass__
shouldn't be decorated with @classmethod
even though it is one - it works implicitly. This is something that should be fixed in Django, but perhaps mypy is also unnecessarily picky here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is a stubtest
bug. Can you please fix it upstread? I will be happy to review and merge your changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. So I did a little digging and this isn't an issue in stubtest. While the explicit @classmethod
is not required, it is not causing the issue - a lazy assumption I made - it's actually that there is the following in typeshed:
The issue is that Django's SeleniumTestCase
eventually subclasses TestCase
but the latter accepts *args
while the former doesn't. So this is another issue that should be fixed in Django. I'll update the comment to more accurately reflect that.
main:4: note: Expected: | ||
main:4: note: def __iter__(self) -> Iterator[Union[Tuple[Any, Any], Tuple[str, Iterable[Tuple[Any, Any]]]]] | ||
main:4: note: Got: | ||
main:4: note: def __iter__(self) -> Iterator[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is annoying and perhaps a new bug in mypy v1.16? It doubles this note for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like so. Please, report upsteam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reported in python/mypy#19240
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THANKS A LOT! I am travelling right now, so I didn't have time to finish it. Amazing work.
One major question: it looks like there are some unrelated changed from the prev commit with uv
scripts/stubtest/allowlist.txt
Outdated
# Django incorrectly decorates this with `@classmethod`. | ||
django.test.selenium.SeleniumTestCase.__init_subclass__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is a stubtest
bug. Can you please fix it upstread? I will be happy to review and merge your changes.
main:4: note: Expected: | ||
main:4: note: def __iter__(self) -> Iterator[Union[Tuple[Any, Any], Tuple[str, Iterable[Tuple[Any, Any]]]]] | ||
main:4: note: Got: | ||
main:4: note: def __iter__(self) -> Iterator[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks like so. Please, report upsteam.
No problem! 😄
Sorry for the confusion - it's because your original branch was behind master and I was targeting this at your original pull request, so needed to merge that in. I'll change this pull request to be a replacement to yours instead of updating that one. |
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
These were not grouped with the other cases of this issue under the following heading in the allowlist: ``` Ignore @cached_property error "cannot reconcile @Property on stub with runtime object" ``` This fixes the following errors: ``` note: unused allowlist entry django.contrib.gis.db.backends.oracle.features.DatabaseFeatures.django_test_skips note: unused allowlist entry django.contrib.gis.db.models.Lookup.output_field note: unused allowlist entry django.db.backends.mysql.base.DatabaseWrapper.data_type_check_constraints note: unused allowlist entry django.db.backends.mysql.base.DatabaseWrapper.display_name note: unused allowlist entry django.db.backends.mysql.base.DatabaseWrapper.mysql_is_mariadb note: unused allowlist entry django.db.backends.mysql.base.DatabaseWrapper.mysql_server_data note: unused allowlist entry django.db.backends.mysql.base.DatabaseWrapper.mysql_server_info note: unused allowlist entry django.db.backends.mysql.base.DatabaseWrapper.mysql_version note: unused allowlist entry django.db.backends.mysql.base.DatabaseWrapper.sql_mode note: unused allowlist entry django.db.models.Lookup.output_field note: unused allowlist entry django.db.models.lookups.Lookup.output_field note: unused allowlist entry django.db.models.sql.where.WhereNode.output_field ```
These are cached properties that override a plain attribute and so stubtest complains with the following: ``` error: django.contrib.gis.db.backends.oracle.features.DatabaseFeatures.django_test_skips variable differs from runtime type functools.cached_property[Any] Stub: in file /home/nick/Sources/_external/django-stubs/django-stubs/contrib/gis/db/backends/oracle/features.pyi:145 builtins.dict[builtins.str, builtins.set[builtins.str]] Runtime: <django.utils.functional.cached_property object at 0x7f628c1d8f50> error: django.db.backends.oracle.features.DatabaseFeatures.django_test_skips variable differs from runtime type functools.cached_property[Any] Stub: in file /home/nick/Sources/_external/django-stubs/django-stubs/db/backends/oracle/features.pyi:145 builtins.dict[builtins.str, builtins.set[builtins.str]] Runtime: <django.utils.functional.cached_property object at 0x7f628c1c5910> error: django.db.backends.oracle.features.DatabaseFeatures.supports_frame_exclusion variable differs from runtime type functools.cached_property[Any] Stub: in file /home/nick/Sources/_external/django-stubs/django-stubs/db/backends/oracle/features.pyi:102 builtins.bool Runtime: <django.utils.functional.cached_property object at 0x7f628c1c5b20> ``` There are many others of these that need looking at properly, so skip them for now...
In the case of `Jinja2DivFormRenderer.__init__` - it will be gone come Django 6.0 anyway when we can just remove this ignore.
Bisected to python/mypy#18847 Some of these look valid, others might be due to bugs, e.g. duplicate note output that might need to be fixed in mypy?
Bisected to python/mypy#18876 It looks like this fixed a genuine problem! \o/
It seems that `Sequence[Sequence[str]] | Sequence[str]` simplifies to `Sequence[Sequence[str]]` so we can remove this complexity. This more simple annotation is also used for related values in `django-stubs/db/backends/base/schema.pyi`.
@sobolevn have updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! I will make a new release once I get back home.
Co-authored-by: sobolevn <mail@sobolevn.me>
I have made things!
Finishes off necessary changes to upgrade to mypy v1.16
Related issues
Closes #2694, fixes #2696