-
-
Notifications
You must be signed in to change notification settings - Fork 459
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
Improve Field.formfield()
, GeometryField.formfield()
methods
#1724
Conversation
e8ebf7e
to
f650d65
Compare
f650d65
to
45ae19a
Compare
@sobolevn Ready for review. |
Thanks! This was already partially added in #1739, I have merged your changes. |
@@ -108,7 +108,9 @@ class GeometryField(BaseSpatialField[_ST, _GT]): | |||
validators: Iterable[_ValidatorCallable] = ..., | |||
error_messages: _ErrorMessagesMapping | None = ..., | |||
) -> None: ... | |||
def formfield(self, **kwargs: Any) -> Any: ... # type: ignore[override] | |||
def formfield( # type: ignore[override] | |||
self, form_class: type[forms.GeometryField] | None = ..., geom_type: str = ..., srid: Any = ..., **kwargs: Any |
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.
Since these are handled from **kwargs
, you should typehint them as keyword-only parameters. That should get rid of the allowlist ignores too.
self, form_class: type[forms.GeometryField] | None = ..., geom_type: str = ..., srid: Any = ..., **kwargs: Any | |
self, *, form_class: type[GeometryField] | None = ..., geom_type: str = ..., srid: Any = ..., **kwargs: Any |
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.
@intgr Technically, these are not keyword-only arguments in the upstream Field.formfield
method: https://github.com/django/django/blob/stable/4.2.x/django/db/models/fields/__init__.py#L1037
However, since the subclasses (CharField
, etc.) only accept keyword arguments and we don't want to reimplement this for every subclass, I think it's fine to be slightly more strict than Django might actually allow. 👍
It'll probably be safer for users to be required to use keyword arguments too.
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.
The *
keyword-only change only affects the GeometryField
method, not Field
. So it should be accurate AFAICT. (https://github.com/django/django/blob/stable/4.2.x/django/contrib/gis/db/models/fields.py#L303)
self, form_class: type[forms.GeometryField] | None = ..., geom_type: str = ..., srid: Any = ..., **kwargs: Any | ||
) -> forms.GeometryField: ... |
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.
No need to qualify these types, they are defined in this very file.
self, form_class: type[forms.GeometryField] | None = ..., geom_type: str = ..., srid: Any = ..., **kwargs: Any | |
) -> forms.GeometryField: ... | |
self, form_class: type[GeometryField] | None = ..., geom_type: str = ..., srid: Any = ..., **kwargs: Any | |
) -> GeometryField: ... |
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.
@intgr Likewise, these are not the same types.
forms.GeometryField
is a form field. The local GeometryField
is a model field.
@@ -206,9 +206,9 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]): | |||
def formfield( | |||
self, | |||
form_class: type[forms.Field] | None = ..., |
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.
form_class: type[forms.Field] | None = ..., | |
form_class: type[Field] | None = ..., |
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.
@intgr No, these are different fields!
forms.Field
is a form field. The local Field
is a model field.
This change now breaks the annotation correctness. I'll open a supplemental PR to fix it now.
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.
Oops, sorry for messing that up. And thanks for responding so quickly.
Sadly this screw-up is now part of the django-stubs 4.2.5 release. I'll probably wait a few days to see if any other bugs turn up, and make another hotfix release.
Field.formfield()
, GeometryField.formfield()
methods
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [django-stubs](https://github.com/typeddjango/django-stubs) ([changelog](https://github.com/typeddjango/django-stubs/releases)) | dev | patch | `4.2.3` -> `4.2.7` | --- ### Release Notes <details> <summary>typeddjango/django-stubs (django-stubs)</summary> ### [`v4.2.7`](https://github.com/typeddjango/django-stubs/releases/tag/4.2.7) [Compare Source](https://github.com/typeddjango/django-stubs/compare/4.2.6...4.2.7) #### Headline changes - **mypy 1.7:** Recommended mypy version updated to 1.7.x - Improved type inference for `ManyToManyField` and `Model.<manytomany>.through` - If you previously imported `RelatedManager` or `ManyRelatedManager`, update those to django-stubs-ext: `from django_stubs_ext.db.models.manager import ManyRelatedManager, RelatedManager` - It's now allowed to override Django's `@cached_property` properties with class variables or `@property` properties. - Even though Django 5.0 was released yesterday, this version does not yet include any changes specific to Django 5.0. #### Plugin improvements - Improved `ManyToManyDescriptor` and fixed `Model.<manytomany>.through` typing by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1805](https://github.com/typeddjango/django-stubs/pull/1805) - Fixed `Self`-typed custom queryset methods to be compatible with `QuerySet` by [@​moranabadie](https://github.com/moranabadie) in [https://github.com/typeddjango/django-stubs/pull/1852](https://github.com/typeddjango/django-stubs/pull/1852) #### django-stubs-ext - django-stubs-ext: Export `RelatedManager`, `ManyRelatedManager` stub-only classes by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1834](https://github.com/typeddjango/django-stubs/pull/1834) - Updated `TypedModelMeta` `ordering` attribute to allow `OrderBy` objects by [@​HansAarneLiblik](https://github.com/HansAarneLiblik) in [https://github.com/typeddjango/django-stubs/pull/1847](https://github.com/typeddjango/django-stubs/pull/1847) #### Stubs fixes - Added missing `search_help_text=` parameter to `ChangeList.__init__()` by [@​quinox](https://github.com/quinox) in [https://github.com/typeddjango/django-stubs/pull/1801](https://github.com/typeddjango/django-stubs/pull/1801) - Allow additional types for SQL parameters in `migrations.RunSQL()` by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1803](https://github.com/typeddjango/django-stubs/pull/1803) - Allow custom Form class in `SuccessMessageMixin.form_valid()` by [@​SukiCZ](https://github.com/SukiCZ) in [https://github.com/typeddjango/django-stubs/pull/1812](https://github.com/typeddjango/django-stubs/pull/1812) - Fixed `db_comment=` parameter position for `django.db.models.Field.__init__()` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1815](https://github.com/typeddjango/django-stubs/pull/1815) - Added missing `RelatedField.__init__()` method and removed `ForeignObject.__init__(db_constraint=)` parameter in Field constructors by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1816](https://github.com/typeddjango/django-stubs/pull/1816) - Fixed argument types of `assertNumQueries()` and `assertQuerySetEqual()` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1823](https://github.com/typeddjango/django-stubs/pull/1823) - Fixed `get_deleted_objects()` return from `list[Model]` -> `list[str]` by [@​golgor](https://github.com/golgor) in [https://github.com/typeddjango/django-stubs/pull/1825](https://github.com/typeddjango/django-stubs/pull/1825) - Removed incorrect `django.db.models` re-exports by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1835](https://github.com/typeddjango/django-stubs/pull/1835) - Fixed `TemplateResponse.cookies` attribute and `SimpleCookie` type by [@​apollo13](https://github.com/apollo13) in [https://github.com/typeddjango/django-stubs/pull/1702](https://github.com/typeddjango/django-stubs/pull/1702) #### Stubs improvements - Added stubs for `django.contrib.postgres.expressions` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1765](https://github.com/typeddjango/django-stubs/pull/1765) - Improved hints of `django.contrib.gis.gdal.libgdal` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1811](https://github.com/typeddjango/django-stubs/pull/1811) - Simulate `@deconstructible` as a mixin class by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1818](https://github.com/typeddjango/django-stubs/pull/1818) - Improved types for `django.db.models.enums.*` modules by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1819](https://github.com/typeddjango/django-stubs/pull/1819) - Added `BaseExpression.contains_subquery()` method (update to Django 4.2.7) by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1827](https://github.com/typeddjango/django-stubs/pull/1827) - Improved types for multiple methods of `QuerySet` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1822](https://github.com/typeddjango/django-stubs/pull/1822) - Improved `Collector` and `NestedObjects` attributes, methods by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1826](https://github.com/typeddjango/django-stubs/pull/1826) - Added `django.db.models.functions.MD5()` database function by [@​kevinmarsh](https://github.com/kevinmarsh) in [https://github.com/typeddjango/django-stubs/pull/1830](https://github.com/typeddjango/django-stubs/pull/1830) - Constrained multiple `BaseModelAdmin` attributes to be either list or tuple by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1832](https://github.com/typeddjango/django-stubs/pull/1832) - Constrained multiple `BaseModelAdmin` methods to return either list or tuple by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1833](https://github.com/typeddjango/django-stubs/pull/1833) - Accurately infer `capfirst()` `None` return by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1842](https://github.com/typeddjango/django-stubs/pull/1842) - Various improvements in `django.core.management.commands` modules by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1829](https://github.com/typeddjango/django-stubs/pull/1829) - Added `Model._do_update()` method signature by [@​pfouque](https://github.com/pfouque) in [https://github.com/typeddjango/django-stubs/pull/1854](https://github.com/typeddjango/django-stubs/pull/1854) ##### Stubs improvements: @​cached_property - Reuse `functools.cached_property` definition instead of defining our own by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1771](https://github.com/typeddjango/django-stubs/pull/1771) - Updated `@property` attributes to `@cached_property` part 1 by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1761](https://github.com/typeddjango/django-stubs/pull/1761) - Updated `@property` attributes to `@cached_property` part 2 by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1768](https://github.com/typeddjango/django-stubs/pull/1768) - Updated Expression classes `output_field` to `@cached_property` or `ClassVar` and improves type by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1769](https://github.com/typeddjango/django-stubs/pull/1769) #### Housekeeping - Moved plugin generated `<Model>_RelatedManager` entries to allowlist by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1806](https://github.com/typeddjango/django-stubs/pull/1806) - Moved `RelatedManager` to `django.db.models.fields.related_descriptors` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1814](https://github.com/typeddjango/django-stubs/pull/1814) - Restored `RelatedManager`, `ManyRelatedManager` to inherit from `Manager` not `BaseManager` by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1843](https://github.com/typeddjango/django-stubs/pull/1843) - Upgraded to mypy 1.7.0 by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1837](https://github.com/typeddjango/django-stubs/pull/1837) - Unify plugin check for model type info by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1853](https://github.com/typeddjango/django-stubs/pull/1853) - Version 4.2.7 release (django-stubs, django-stubs-ext) by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1856](https://github.com/typeddjango/django-stubs/pull/1856) #### New Contributors - [@​SukiCZ](https://github.com/SukiCZ) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1812](https://github.com/typeddjango/django-stubs/pull/1812) - [@​golgor](https://github.com/golgor) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1825](https://github.com/typeddjango/django-stubs/pull/1825) - [@​HansAarneLiblik](https://github.com/HansAarneLiblik) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1847](https://github.com/typeddjango/django-stubs/pull/1847) - [@​apollo13](https://github.com/apollo13) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1702](https://github.com/typeddjango/django-stubs/pull/1702) - [@​pfouque](https://github.com/pfouque) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1854](https://github.com/typeddjango/django-stubs/pull/1854) **Full Changelog**: typeddjango/django-stubs@4.2.6...4.2.7 ### [`v4.2.6`](https://github.com/typeddjango/django-stubs/releases/tag/4.2.6) [Compare Source](https://github.com/typeddjango/django-stubs/compare/4.2.5...4.2.6) #### Headline changes - Fixed several bugs in version 4.2.5. Thanks to everyone for contributing fixes on a short order! - Removed direct mypy dependency. If you are using mypy, please add an explicit `mypy` dev dependency to your project, or install django-stubs with the extra `django-stubs[compatible-mypy]`. Mypy remains **the only supported type checker**. Improvements for other type checkers may be considered in the future, pull requests welcome. See [#​1628](https://github.com/typeddjango/django-stubs/issues/1628) for details. #### Plugin fixes - Fixed `as_manager()` and `from_queryset()` when combined with `Self` types ([#​1788](https://github.com/typeddjango/django-stubs/issues/1788)) by [@​moranabadie](https://github.com/moranabadie) in [https://github.com/typeddjango/django-stubs/pull/1789](https://github.com/typeddjango/django-stubs/pull/1789) - Fix IndexError crash when using `from_queryset()` of custom Manager subclass by [@​moranabadie](https://github.com/moranabadie) in [https://github.com/typeddjango/django-stubs/pull/1786](https://github.com/typeddjango/django-stubs/pull/1786) - Revert "Use `parse_bool` implementation from mypy" by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1792](https://github.com/typeddjango/django-stubs/pull/1792) (Turns out this was not necessary and will be reverted) #### Stubs fixes - Fixed `Field.formfield()`, `GeometryField.formfield()` method arguments by [@​brianhelba](https://github.com/brianhelba) in [https://github.com/typeddjango/django-stubs/pull/1778](https://github.com/typeddjango/django-stubs/pull/1778) #### Stubs improvements - Various improvements in `django.core.management` modules by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1787](https://github.com/typeddjango/django-stubs/pull/1787) - Various improvments in `django.db.backend.base` modules by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1791](https://github.com/typeddjango/django-stubs/pull/1791) #### Housekeeping - Drop hard dependency on mypy by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1782](https://github.com/typeddjango/django-stubs/pull/1782) - Version 4.2.6 release (django-stubs only) by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1794](https://github.com/typeddjango/django-stubs/pull/1794) **Full Changelog**: typeddjango/django-stubs@4.2.5...4.2.6 ### [`v4.2.5`](https://github.com/typeddjango/django-stubs/releases/tag/4.2.5) [Compare Source](https://github.com/typeddjango/django-stubs/compare/4.2.4...4.2.5) #### Headline changes - **mypy 1.6:** Recommended mypy version updated to 1.6.x - Next django-stubs version (4.2.6) will remove direct mypy dependency. If you are using mypy, please add an explicit `mypy` dev dependency to your project, or install django-stubs with the extra `django-stubs[compatible-mypy]`. Mypy remains **the only supported type checker**. Improvements for other type checkers may be considered in the future, pull requests welcome. See [#​1628](https://github.com/typeddjango/django-stubs/issues/1628) for details. - Officially added Python 3.12 support #### Stubs fixes - Made `default_storage` produce a `Storage` object by [@​brianhelba](https://github.com/brianhelba) in [https://github.com/typeddjango/django-stubs/pull/1665](https://github.com/typeddjango/django-stubs/pull/1665) - Fixed wrong type hints for `SyndicationFeed` methods by [@​WhyNotHugo](https://github.com/WhyNotHugo) in [https://github.com/typeddjango/django-stubs/pull/1705](https://github.com/typeddjango/django-stubs/pull/1705) - Fixed variance of `Migration.operations` attribute by [@​asottile](https://github.com/asottile) in [https://github.com/typeddjango/django-stubs/pull/1707](https://github.com/typeddjango/django-stubs/pull/1707) - Fixed variance of all `Migration` list attributes by [@​brianhelba](https://github.com/brianhelba) in [https://github.com/typeddjango/django-stubs/pull/1710](https://github.com/typeddjango/django-stubs/pull/1710) - Adjust `bases=` parameter in `CreateModel` migration op to allow for mixins by [@​asottile](https://github.com/asottile) in [https://github.com/typeddjango/django-stubs/pull/1708](https://github.com/typeddjango/django-stubs/pull/1708) - Fixed `_Composable` protocol for compatibility with `psycopg2-stubs` change by [@​andersk](https://github.com/andersk) in [https://github.com/typeddjango/django-stubs/pull/1714](https://github.com/typeddjango/django-stubs/pull/1714) - Various fixes and improvements in `django.views` modules by [@​GabDug](https://github.com/GabDug) in [https://github.com/typeddjango/django-stubs/pull/1716](https://github.com/typeddjango/django-stubs/pull/1716) - Removed `null` and `validators` arguments from `ManyToManyField.__init__` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1720](https://github.com/typeddjango/django-stubs/pull/1720) - Various fixes and improvements in `django.test` modules by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1752](https://github.com/typeddjango/django-stubs/pull/1752) - Fixed `BaseModelForm`, `ErrorList`, `ErrorDict` constructor `renderer=` parameter by [@​GabDug](https://github.com/GabDug) in [https://github.com/typeddjango/django-stubs/pull/1690](https://github.com/typeddjango/django-stubs/pull/1690) #### Stubs improvements - Annotated return value of all `deconstruct` methods by [@​brianhelba](https://github.com/brianhelba) in [https://github.com/typeddjango/django-stubs/pull/1695](https://github.com/typeddjango/django-stubs/pull/1695) - Added missing arguments to `SQLCompiler` methods by [@​ashm-tech](https://github.com/ashm-tech) in [https://github.com/typeddjango/django-stubs/pull/1689](https://github.com/typeddjango/django-stubs/pull/1689) - Added missing `max_length` attribute to `forms.FileField` by [@​GabDug](https://github.com/GabDug) in [https://github.com/typeddjango/django-stubs/pull/1715](https://github.com/typeddjango/django-stubs/pull/1715) - Added missing type arguments to various generic classes by [@​GabDug](https://github.com/GabDug) in [https://github.com/typeddjango/django-stubs/pull/1717](https://github.com/typeddjango/django-stubs/pull/1717) - Added missing `Layer.num_feat` attribute (GeoDjango) by [@​niconoe](https://github.com/niconoe) in [https://github.com/typeddjango/django-stubs/pull/1722](https://github.com/typeddjango/django-stubs/pull/1722) - Specify `AbstractBaseUser.REQUIRED_FIELDS` as `ClassVar` by [@​WhyNotHugo](https://github.com/WhyNotHugo) in [https://github.com/typeddjango/django-stubs/pull/1737](https://github.com/typeddjango/django-stubs/pull/1737) - Improve `fields.Field.formfield()` method by [@​WhyNotHugo](https://github.com/WhyNotHugo) in [https://github.com/typeddjango/django-stubs/pull/1739](https://github.com/typeddjango/django-stubs/pull/1739) - Added `ModelStateFieldsCacheDescriptor.__get__` method by [@​asottile](https://github.com/asottile) in [https://github.com/typeddjango/django-stubs/pull/1743](https://github.com/typeddjango/django-stubs/pull/1743) - Update `Model._meta` to `ClassVar[Options[Self]]` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1732](https://github.com/typeddjango/django-stubs/pull/1732) - Improved `django.test.signals` types by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1751](https://github.com/typeddjango/django-stubs/pull/1751) - Updated Django to 4.2.6 and updated stubs by [@​sobolevn](https://github.com/sobolevn) in [https://github.com/typeddjango/django-stubs/pull/1757](https://github.com/typeddjango/django-stubs/pull/1757) - Require 1 callable argument for `@cached_property` decorated method by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1766](https://github.com/typeddjango/django-stubs/pull/1766) - Allow `psycopg2.sql.SQL` in `QuerySet.raw()` by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1767](https://github.com/typeddjango/django-stubs/pull/1767) - Added missing stubs in `django.middleware.csrf` module by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1770](https://github.com/typeddjango/django-stubs/pull/1770) - Various improvements in `django.core.cache` modules by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1774](https://github.com/typeddjango/django-stubs/pull/1774) - Improved `Field.formfield()`, `GeometryField.formfield()` methods by [@​brianhelba](https://github.com/brianhelba) in [https://github.com/typeddjango/django-stubs/pull/1724](https://github.com/typeddjango/django-stubs/pull/1724) - Fixed query `F.resolve_expression()` return type by [@​schinckel](https://github.com/schinckel) in [https://github.com/typeddjango/django-stubs/pull/1659](https://github.com/typeddjango/django-stubs/pull/1659) #### Plugin improvements - Resolve dynamic `Manager` methods through manager MRO by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1701](https://github.com/typeddjango/django-stubs/pull/1701) - Use `functools.cached_property` instead of Django's in mypy plugin by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1721](https://github.com/typeddjango/django-stubs/pull/1721) - Improved hints for `ReverseOneToOneDescriptor` and start using it by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1733](https://github.com/typeddjango/django-stubs/pull/1733) - Add better support for `ManyToManyField`'s `through` model by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1719](https://github.com/typeddjango/django-stubs/pull/1719) - Resolve any `settings.AUTH_USER_MODEL` used as `to=` in relation by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1746](https://github.com/typeddjango/django-stubs/pull/1746) - Added missing `_default_manager` symbol to generated `through` model by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1745](https://github.com/typeddjango/django-stubs/pull/1745) #### Plugin crash fixes - Gracefully handle unwanted types when creating fallback managers by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1728](https://github.com/typeddjango/django-stubs/pull/1728) Fixes some `AssertionError` crashes. - Handle mismatching types in queryset method resolving gracefully by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1727](https://github.com/typeddjango/django-stubs/pull/1727) Fixes some `AssertionError` crashes. - Fixed crash on bad arguments for model relationship fields by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1735](https://github.com/typeddjango/django-stubs/pull/1735) Fixes some `ValueError` crashes. #### Documentation - Fixed link to `django_stubs_ext` by [@​tony](https://github.com/tony) in [https://github.com/typeddjango/django-stubs/pull/1747](https://github.com/typeddjango/django-stubs/pull/1747) & [https://github.com/typeddjango/django-stubs/pull/1748](https://github.com/typeddjango/django-stubs/pull/1748) - Add version 4.2.4 to version compatibility table by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1758](https://github.com/typeddjango/django-stubs/pull/1758) #### Housekeeping - Removed a bunch of unused code by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1687](https://github.com/typeddjango/django-stubs/pull/1687) - Removed redefinition of inherited `deconstruct` methods. by [@​brianhelba](https://github.com/brianhelba) in [https://github.com/typeddjango/django-stubs/pull/1693](https://github.com/typeddjango/django-stubs/pull/1693) & [https://github.com/typeddjango/django-stubs/pull/1694](https://github.com/typeddjango/django-stubs/pull/1694) - Use `parse_bool` implementation from mypy by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1703](https://github.com/typeddjango/django-stubs/pull/1703) - Specify error codes in `# type: ignore` comments for plugin code by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1726](https://github.com/typeddjango/django-stubs/pull/1726) - Specify error codes in `# type: ignore` comments in stubs files by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1734](https://github.com/typeddjango/django-stubs/pull/1734) - CI: Enable testing with Python 3.12 by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1759](https://github.com/typeddjango/django-stubs/pull/1759) - Bump mypy from 1.5.1 to 1.6.0 by [@​dependabot](https://github.com/dependabot) in [https://github.com/typeddjango/django-stubs/pull/1764](https://github.com/typeddjango/django-stubs/pull/1764) - Tests: Add mypy error codes to typecheck by [@​UnknownPlatypus](https://github.com/UnknownPlatypus) in [https://github.com/typeddjango/django-stubs/pull/1773](https://github.com/typeddjango/django-stubs/pull/1773) - chore: Migrate from flake8 to ruff by [@​GabDug](https://github.com/GabDug) in [https://github.com/typeddjango/django-stubs/pull/1718](https://github.com/typeddjango/django-stubs/pull/1718) - Update black version by [@​sobolevn](https://github.com/sobolevn) in [https://github.com/typeddjango/django-stubs/pull/1776](https://github.com/typeddjango/django-stubs/pull/1776) - Added test to verify that `Manager.from_queryset()` handles invalid argument types by [@​flaeppe](https://github.com/flaeppe) in [https://github.com/typeddjango/django-stubs/pull/1731](https://github.com/typeddjango/django-stubs/pull/1731) - Version 4.2.5 release (django-stubs, django-stubs-ext) by [@​intgr](https://github.com/intgr) in [https://github.com/typeddjango/django-stubs/pull/1777](https://github.com/typeddjango/django-stubs/pull/1777) #### New Contributors - [@​ashm-tech](https://github.com/ashm-tech) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1689](https://github.com/typeddjango/django-stubs/pull/1689) - [@​WhyNotHugo](https://github.com/WhyNotHugo) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1705](https://github.com/typeddjango/django-stubs/pull/1705) - [@​niconoe](https://github.com/niconoe) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1722](https://github.com/typeddjango/django-stubs/pull/1722) - [@​schinckel](https://github.com/schinckel) made their first contribution in [https://github.com/typeddjango/django-stubs/pull/1659](https://github.com/typeddjango/django-stubs/pull/1659) **Full Changelog**: typeddjango/django-stubs@4.2.4...4.2.5 ### [`v4.2.4`](https://github.com/typeddjango/django-stubs/releases/tag/4.2.4) [Compare Source](https://github.com/typeddjango/django-stubs/compare/4.2.3...4.2.4) Most important changes: - This version add Mypy `1.5.*` support and update `[compatible-mypy]` extra to use `1.5.*`. - We also update our stubs to be compatible with Django `4.2.5` (and all prior versions of `4.2`). - `django_stubs_ext/` folder was renamed to be just `ext/`, it should not affect users (unless you install it from git) - We no longer assume the `objects` attribute to be present on generic Model classes. As per the [django documentation](https://docs.djangoproject.com/en/4.2/topics/db/managers/#django.db.models.Model.\_default_manager), code working with generic models should use the `_default_manager` attribute instead. This time there is no corresponding release of `django-stubs-ext`. #### Plugin changes - We now forbid to instantiate abstract models [https://github.com/typeddjango/django-stubs/pull/1663](https://github.com/typeddjango/django-stubs/pull/1663) [@​flaeppe](https://github.com/flaeppe) - Manager attributes are now `ClassVar`s [https://github.com/typeddjango/django-stubs/pull/1672](https://github.com/typeddjango/django-stubs/pull/1672) [@​flaeppe](https://github.com/flaeppe) Thanks a lot to all contributors and maintainers! 🎉 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy42NC4yIiwidXBkYXRlZEluVmVyIjoiMzcuNjQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: descope[bot] <descope[bot]@users.noreply.github.com>
No description provided.