Releases: typeddjango/django-stubs
5.0.0
Announcements
QuerySet
class no longer derives fromCollection
. If you run into errors likeincompatible type "_QuerySet[User, User]"; expected "Collection[User]"
, please read this announcement.
Headline changes
- Remove incorrect
Collection
base class and__contains__
method fromQuerySet
by @fidoriel in #1925 - Pyright joins the workflow in an advisory capacity by @jorenham in #2019
- feat: Allow setting django_settings_module from env by @armanckeser in #2021
- Add
ManyRelatedManager.through
attribute and generic type parameter by @flaeppe in #2026
What's Changed
- Make
StrPromise
not inherit fromSequence[str]
by @intgr in #1841 - Update and prepare for Django 5.0 by @intgr in #1859
- Ensure mypy plugin processes inherited many to many fields by @flaeppe in #1864
- Include ModelBase subclasses in plugin base class hook condition by @flaeppe in #1863
- [5.0] Added many new a-prefixed asynchronous methods by @bigfootjon in #1741
- Remove section regarding custom queryset methods from README by @flaeppe in #1865
- Fix type of
AppConfig.models_module
by @Viicos in #1866 - Allow
None
in settingsMIGRATION_MODULES
dict values by @asottile in #1871 - Add type hints for
JSONField.from_db_value
by @flaeppe in #1879 - Fix/pyright unknown by @dephiros in #1873
- Fix type hints of
converters
inurls.resolvers
by @Viicos in #1892 - Update mypy to 1.8.0 by @sobolevn in #1885
- Add
@type_check_only
to all Protocols and known stubs-only classes by @intgr in #1894 - Fix types for UniqueConstraint instantiation by @flaeppe in #1880
- Add
ModuleType
as a possible type toURLResolver.urlconf_name
by @Viicos in #1891 - Fix type hint of
URLPattern.default_args
by @Viicos in #1895 - Update ruff and silence
PYI046
by @sobolevn in #1907 - Use PEP 570 syntax by @Viicos in #1908
- Fix readme settings example by @Viicos in #1910
- Fix type hint of
EmailBackend.ssl_keyfile
andEmailBackend.ssl_certfile
by @Viicos in #1911 - Add type of
django.VERSION
by @Viicos in #1916 - Added
CommandParser
tocommands.__init__
by @jamesbraza in #1927 - [5.0] add
assume_scheme
to forms.URLField by @asottile in #1929 - Fix return type of
BaseModelAdmin.formfield_for_dbfield
by @Viicos in #1934 - Revert
pre-commit==3.6.1
by @sobolevn in #1936 - Fix type hint of
Response.set_cookie.max_age
by @Viicos in #1941 - 5.0: Add ChoicesType by @q0w in #1942
- Add through_defaults for RelatedManager methods by @mfosterw in #1943
- Update type hints of
core.signing
by @Viicos in #1945 - [5.0] Update
core.validators
by @Viicos in #1947 - [5.0] Update
core.paginator
by @Viicos in #1946 - Generic
forms.ModelChoiceField
by @UnknownPlatypus in #1889 - Support processing of other relations and fields when one is broken by @flaeppe in #1877
- Allowing
set
inmodel_to_dict
'sexclude
by @jamesbraza in #1952 - [5.0] Add django.db.models.GeneratedField by @palfrey in #1944
- Fix type hint of
BaseEngine.template_dirs
by @Viicos in #1954 - Update type hints of contrib.auth.hashers by @yhay81 in #1955
- deps: Upgrade pre-commit for newer versions of python by @delfick in #1961
- 5.0: Add auth.middleware.auser by @q0w in #1966
- 5.0: Add ModelAdmin.show_facets by @q0w in #1967
- ruff: Fix config warnings by @q0w in #1964
- 5.0: Add BaseConstraint.violation_error_code by @q0w in #1969
- 5.0: Add Signal.asend and Signal.asend_robust by @q0w in #1965
- 5.0: Add QuerySet.(a)update_or_create new create_defaults arg by @q0w in #1970
- 5.0: Add AdminSite.get_log_entries by @q0w in #1963
- 5.0: Add gis ClosestPoint by @q0w in #1968
- 5.0: Rename save_existing arg instance to obj by @q0w in #1971
- 5.0: Remove admin.helpers.checkbox by @q0w in #1972
- 5.0: Change annotation_select_mask from set[str] to list[str] by @q0w in #1973
- fixup: Pass violation_error_code to init by @q0w in #1975
- Avoid returning None from get_field_related_model_cls by @SingingTree in #1956
- 5.0: Pass positional args name and violation_error_message to BaseConstraint by @q0w in #1974
- 5.0: Remove pytz support by @q0w in #1980
- 5.0: Remove global setting USE_L10N by @q0w in #1979
- 5.0: Remove OSMGeoAdmin, GeoModelAdmin by @q0w in #1981
- 5.0: Remove extra_tests arg for DiscoverRunner.build_suite/run_tests by @q0w in #1978
- 5.0: Remove django.utils baseconv and datetime_safe modules by @q0w in #1977
- 5.0: Add request arg to ModelAdmin.lookup_allowed by @q0w in #1976
- Add URL converter protocol type by @adamchainz in #1984
- Fix type annotation for RegisterLookupMixin.class_lookups by @avoronov-box in #1962
- Update django to 5.0.3 by @sobolevn in #1990
- Remove some deprecated Django 3.x APIs by @sobolevn in #1991
- Fix BaseModelAdmin.view_on_site annotation by @cuu508 in #1993
- Allow immutable
extra_context
onTemplateView
s by @samueljsb in #1994 - Add BoundField.html() by @pelme in #1999
- Allow timedelta type for session.set_expiry() argument by @mlazar-endear in #2001
- Bump
pytest-mypy-plugins
to 3.1.1 by @sobolevn in #2003 - Update mypy, add a bit more metadata by @sobolevn in #1997
- 5.0: Update
django.contrib.auth
by @ngnpope in #2009 - 5.0: Update
django.conf
by @ngnpope in #2008 - 5.0: Update
django.views
by @ngnpope in #2007 - 5.0: Update
django.test
by @ngnpope in #2005 - 5.0: Update
django.utils
by @ngnpope in #2006 - Specify d.c.serializers.base.DeserializedObject.object type by @j00bar in #2010
- Clean the cache on each run of
stubtest
by @sobolevn in #2015 - Keep abstract Django models internally in the plugin by @flaeppe in #2017
- Add GitHub actions release workflow by @flaeppe in #1950
- Adding missing
Q
methods:check()
,flatten()
by @Alexerson in #1899 - Improve types in
utils.termcolors
by @Viicos in #1901 - Set the calculated metaclass when creating type info in the plugin by @flaeppe in https://github.c...
4.2.7
Headline changes
- mypy 1.7: Recommended mypy version updated to 1.7.x
- Improved type inference for
ManyToManyField
andModel.<manytomany>.through
- If you previously imported
RelatedManager
orManyRelatedManager
, 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 fixedModel.<manytomany>.through
typing by @flaeppe in #1805 - Fixed
Self
-typed custom queryset methods to be compatible withQuerySet
by @moranabadie in #1852
django-stubs-ext
- django-stubs-ext: Export
RelatedManager
,ManyRelatedManager
stub-only classes by @intgr in #1834 - Updated
TypedModelMeta
ordering
attribute to allowOrderBy
objects by @HansAarneLiblik in #1847
Stubs fixes
- Added missing
search_help_text=
parameter toChangeList.__init__()
by @quinox in #1801 - Allow additional types for SQL parameters in
migrations.RunSQL()
by @UnknownPlatypus in #1803 - Allow custom Form class in
SuccessMessageMixin.form_valid()
by @SukiCZ in #1812 - Fixed
db_comment=
parameter position fordjango.db.models.Field.__init__()
by @flaeppe in #1815 - Added missing
RelatedField.__init__()
method and removedForeignObject.__init__(db_constraint=)
parameter in Field constructors by @flaeppe in #1816 - Fixed argument types of
assertNumQueries()
andassertQuerySetEqual()
by @flaeppe in #1823 - Fixed
get_deleted_objects()
return fromlist[Model]
->list[str]
by @golgor in #1825 - Removed incorrect
django.db.models
re-exports by @intgr in #1835 - Fixed
TemplateResponse.cookies
attribute andSimpleCookie
type by @apollo13 in #1702
Stubs improvements
- Added stubs for
django.contrib.postgres.expressions
by @flaeppe in #1765 - Improved hints of
django.contrib.gis.gdal.libgdal
by @flaeppe in #1811 - Simulate
@deconstructible
as a mixin class by @flaeppe in #1818 - Improved types for
django.db.models.enums.*
modules by @flaeppe in #1819 - Added
BaseExpression.contains_subquery()
method (update to Django 4.2.7) by @intgr in #1827 - Improved types for multiple methods of
QuerySet
by @flaeppe in #1822 - Improved
Collector
andNestedObjects
attributes, methods by @intgr in #1826 - Added
django.db.models.functions.MD5()
database function by @kevinmarsh in #1830 - Constrained multiple
BaseModelAdmin
attributes to be either list or tuple by @flaeppe in #1832 - Constrained multiple
BaseModelAdmin
methods to return either list or tuple by @flaeppe in #1833 - Accurately infer
capfirst()
None
return by @intgr in #1842 - Various improvements in
django.core.management.commands
modules by @UnknownPlatypus in #1829 - Added
Model._do_update()
method signature by @pfouque in #1854
Stubs improvements: @cached_property
- Reuse
functools.cached_property
definition instead of defining our own by @intgr in #1771 - Updated
@property
attributes to@cached_property
part 1 by @UnknownPlatypus in #1761 - Updated
@property
attributes to@cached_property
part 2 by @UnknownPlatypus in #1768 - Updated Expression classes
output_field
to@cached_property
orClassVar
and improves type by @UnknownPlatypus in #1769
Housekeeping
- Moved plugin generated
<Model>_RelatedManager
entries to allowlist by @flaeppe in #1806 - Moved
RelatedManager
todjango.db.models.fields.related_descriptors
by @flaeppe in #1814 - Restored
RelatedManager
,ManyRelatedManager
to inherit fromManager
notBaseManager
by @intgr in #1843 - Upgraded to mypy 1.7.0 by @intgr in #1837
- Unify plugin check for model type info by @flaeppe in #1853
- Version 4.2.7 release (django-stubs, django-stubs-ext) by @intgr in #1856
New Contributors
- @SukiCZ made their first contribution in #1812
- @golgor made their first contribution in #1825
- @HansAarneLiblik made their first contribution in #1847
- @apollo13 made their first contribution in #1702
- @pfouque made their first contribution in #1854
Full Changelog: 4.2.6...4.2.7
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 extradjango-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 for details.
Plugin fixes
- Fixed
as_manager()
andfrom_queryset()
when combined withSelf
types (#1788) by @moranabadie in #1789 - Fix IndexError crash when using
from_queryset()
of custom Manager subclass by @moranabadie in #1786 - Revert "Use
parse_bool
implementation from mypy" by @intgr in #1792
(Turns out this was not necessary and will be reverted)
Stubs fixes
- Fixed
Field.formfield()
,GeometryField.formfield()
method arguments by @brianhelba in #1778
Stubs improvements
- Various improvements in
django.core.management
modules by @UnknownPlatypus in #1787 - Various improvments in
django.db.backend.base
modules by @UnknownPlatypus in #1791
Housekeeping
- Drop hard dependency on mypy by @intgr in #1782
- Version 4.2.6 release (django-stubs only) by @intgr in #1794
Full Changelog: 4.2.5...4.2.6
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 extradjango-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 for details.
-
Officially added Python 3.12 support
Stubs fixes
- Made
default_storage
produce aStorage
object by @brianhelba in #1665 - Fixed wrong type hints for
SyndicationFeed
methods by @WhyNotHugo in #1705 - Fixed variance of
Migration.operations
attribute by @asottile in #1707 - Fixed variance of all
Migration
list attributes by @brianhelba in #1710 - Adjust
bases=
parameter inCreateModel
migration op to allow for mixins by @asottile in #1708 - Fixed
_Composable
protocol for compatibility withpsycopg2-stubs
change by @andersk in #1714 - Various fixes and improvements in
django.views
modules by @GabDug in #1716 - Removed
null
andvalidators
arguments fromManyToManyField.__init__
by @flaeppe in #1720 - Various fixes and improvements in
django.test
modules by @UnknownPlatypus in #1752 - Fixed
BaseModelForm
,ErrorList
,ErrorDict
constructorrenderer=
parameter by @GabDug in #1690
Stubs improvements
- Annotated return value of all
deconstruct
methods by @brianhelba in #1695 - Added missing arguments to
SQLCompiler
methods by @ashm-tech in #1689 - Added missing
max_length
attribute toforms.FileField
by @GabDug in #1715 - Added missing type arguments to various generic classes by @GabDug in #1717
- Added missing
Layer.num_feat
attribute (GeoDjango) by @niconoe in #1722 - Specify
AbstractBaseUser.REQUIRED_FIELDS
asClassVar
by @WhyNotHugo in #1737 - Improve
fields.Field.formfield()
method by @WhyNotHugo in #1739 - Added
ModelStateFieldsCacheDescriptor.__get__
method by @asottile in #1743 - Update
Model._meta
toClassVar[Options[Self]]
by @flaeppe in #1732 - Improved
django.test.signals
types by @UnknownPlatypus in #1751 - Updated Django to 4.2.6 and updated stubs by @sobolevn in #1757
- Require 1 callable argument for
@cached_property
decorated method by @flaeppe in #1766 - Allow
psycopg2.sql.SQL
inQuerySet.raw()
by @flaeppe in #1767 - Added missing stubs in
django.middleware.csrf
module by @UnknownPlatypus in #1770 - Various improvements in
django.core.cache
modules by @UnknownPlatypus in #1774 - Improved
Field.formfield()
,GeometryField.formfield()
methods by @brianhelba in #1724 - Fixed query
F.resolve_expression()
return type by @schinckel in #1659
Plugin improvements
- Resolve dynamic
Manager
methods through manager MRO by @flaeppe in #1701 - Use
functools.cached_property
instead of Django's in mypy plugin by @flaeppe in #1721 - Improved hints for
ReverseOneToOneDescriptor
and start using it by @flaeppe in #1733 - Add better support for
ManyToManyField
'sthrough
model by @flaeppe in #1719 - Resolve any
settings.AUTH_USER_MODEL
used asto=
in relation by @flaeppe in #1746 - Added missing
_default_manager
symbol to generatedthrough
model by @flaeppe in #1745
Plugin crash fixes
- Gracefully handle unwanted types when creating fallback managers by @flaeppe in #1728
Fixes someAssertionError
crashes. - Handle mismatching types in queryset method resolving gracefully by @flaeppe in #1727
Fixes someAssertionError
crashes. - Fixed crash on bad arguments for model relationship fields by @flaeppe in #1735
Fixes someValueError
crashes.
Documentation
- Fixed link to
django_stubs_ext
by @tony in #1747 & #1748 - Add version 4.2.4 to version compatibility table by @intgr in #1758
Housekeeping
- Removed a bunch of unused code by @flaeppe in #1687
- Removed redefinition of inherited
deconstruct
methods. by @brianhelba in #1693 & #1694 - Use
parse_bool
implementation from mypy by @flaeppe in #1703 - Specify error codes in
# type: ignore
comments for plugin code by @flaeppe in #1726 - Specify error codes in
# type: ignore
comments in stubs files by @UnknownPlatypus in #1734 - CI: Enable testing with Python 3.12 by @intgr in #1759
- Bump mypy from 1.5.1 to 1.6.0 by @dependabot in #1764
- Tests: Add mypy error codes to typecheck by @UnknownPlatypus in #1773
- chore: Migrate from flake8 to ruff by @GabDug in #1718
- Update black version by @sobolevn in #1776
- Added test to verify that
Manager.from_queryset()
handles invalid argument types by @flaeppe in #1731 - Version 4.2.5 release (django-stubs, django-stubs-ext) by @intgr in #1777
New Contributors
- @ashm-tech made their first contribution in #1689
- @WhyNotHugo made their first contribution in #1705
- @niconoe made their first contribution in #1722
- @schinckel made their first contribution in #1659
Full Changelog: 4.2.4...4.2.5
4.2.4
Most important changes:
- This version add Mypy
1.5.*
support and update[compatible-mypy]
extra to use1.5.*
. - We also update our stubs to be compatible with Django
4.2.5
(and all prior versions of4.2
). django_stubs_ext/
folder was renamed to be justext/
, 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, 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 #1663 @flaeppe
- Manager attributes are now
ClassVar
s #1672 @flaeppe
Thanks a lot to all contributors and maintainers! ๐
4.2.3
This version fixes two regressions in previons django-stubs
release and also a few other fixes and improvements. Special thanks to @GabDug for contributing regression fixes on a short order.
This time there is no corresponding release of django-stubs-ext
.
Stubs fixes
- Fixed type error when subclassing
AppConfig
and assigning string todefault_auto_field
by @GabDug in #1596 - Fixed type error when subclassing
MiddlewareMixin.__call__()
and usingreturn self.get_response()
by @GabDug in #1595 - Allow
None
asredirect_field_name
value for@user_passes_test
and@login_required
decorators by @JoeHitchen in #1600
Plugin fixes
- Fixed long-standing issue with
Date(Time)Field
when using mypy settingdisallow_any_explicit
by @sobolevn in #1599
Stubs changes
- Added
BigIntegerField.MAX_BIGINT
attribute by @asottile in #1598 - Improved Jinja2 types and updated
pytest-mypy-plugins
by @sobolevn in #1601
CI/Testing
Housekeeping
- Converted
_typeshed.Self
usages totyping_extensions.Self
(PEP 673) by @intgr in #1591 - Version 4.2.3 release (django-stubs only) by @intgr in #1604
New Contributors
- @JoeHitchen made their first contribution in #1600
Full Changelog: 4.2.2...4.2.3
4.2.2
Headline changes
-
mypy 1.4: Recommended mypy version updated to 1.4.x
-
Support for
django-split-settings
,django-configurations
and other Django settings addons withstrict_settings = false
option, see README for details -
We have now adopted mypy's stubtest to automatically find discrepancies between Django and django-stubs.
If you want to contribute to django-stubs but are not sure where to start, have a look at stubtest's TODO list file, which lists the many issues discovered by stubtest.
Django 4.2 changes
- Applied Django 4.2 deprecations by @Alexerson in #1523
- Updated global settings and
AppConfig
class to match Django 4.2 by @Alexerson in #1524 - Added types for new 'system checks' in Django 4.2 by @Alexerson in #1526
- Added
ManifestStaticFilesStorage
new parameters by @Alexerson in #1528 - Added new methods to
Sitemap
class by @Alexerson in #1527 - Added new
headers=
parameter to(Async)RequestFactory
and(Async)Client
classes by @Alexerson in #1529 - GDAL-related GeoDjango updates in Django 4.2 by @Alexerson in #1525
- Added ORM
^
and~
operator support, JSON lookup classes, Postgres lookup classes,ModelForm
changes,json_script
template filter parameters by @Alexerson in #1536 - Added and updated
db.backends
DatabaseIntrospection
andDatabaseOperations
classes by @GabDug in #1571
Stubs additions
- Added
QuerySet._result_cache
attribute and_fetch_all()
method by @adamchainz in #1505 - Added
ModelAdmin.search_help_text
attribute by @adamchainz in #1546 - Added email console handler
EmailBackend.write_message()
method by @adamchainz in #1547 - Added
ModelAdmin.get_formset_kwargs()
method by @adamchainz in #1545 - Added
Signal._live_receivers()
method by @adamchainz in #1551 - Added
SQLCompiler._order_by_pairs()
method by @adamchainz in #1586 - Added
memcache_key_warnings()
function by @rvanlaar in #1562
Stubs fixes
- Fixed
create_model_instance
incorrect data argument type by @namper in #1521 - Marked
RequestSite.{save,delete}
methods asNoReturn
since they always raise by @sobolevn in #1530 - Updated
SafeExceptionReporterFilter
attributes and removed obsoleteCLEANSED_SUBSTITUTE
by @mthuurne in #1540 - Changed
AppConfig.default_auto_field
to attribute instead of method by @mthuurne in #1541 - Fixed
default_error_messages
attribute type of baseField
andGenericIPAddressField
classes by @asottile in #1538 - Improved spatialite
DatabaseWrapper
attributes by @filbasi in #1544 - Improved types for Signal
dispatch.dispatcher
by @GabDug in #1567 - Accept
str
field names forWindow.order_by()
, allowNone
forasc/desc
arguments by @GabDug in #1574 - Updated many
django.utils.*
types from stubtest by @GabDug in #1575 - Updated many
db.migrations.operations
types from stubtest by @GabDug in #1583 - Added
StepValueValidator
, fixed argument forSRIDCacheEntry
/EmailValidator
, improvedurls.resolvers
types by @GabDug in #1589
Plugin changes
- Fixed
ForeignKey
queryset filters on un-swapped models by @UnknownPlatypus in #1495 - Add
strict_settings
option, allow runtime fallbacks for custom settings by @sobolevn in #1557 - Automatically reset mypy cache when plugin settings change by @sobolevn in #1578
- Fixed unhandled exception
KeyError: 'model_bases'
and related errors by @intgr in #1563
django-stubs-ext
CI/testing
- CI: Replace isort with Ruff import sorting by @intgr in #1507
- CI: Auto-remove unused imports using Ruff by @intgr in #1508
- CI: Enable Ruff pyupgrade fixes by @intgr in #1509
- CI: Run django-stubs-ext tests in full build matrix by @intgr in #1552
- Remove typecheck test and clean things up by @sobolevn in #1556
- Add stubtest with lots of errors (currently) by @sobolevn in #1560
Housekeeping
- Removed unsupported Django versions from package classifiers by @intgr in #1553
- Removed try-except around import of
ArrayField
by @sobolevn in #1558 - Removed usage of
mypy_extensions
by @sobolevn in #1566 - Upgrade to Mypy 1.4.0 by @christianbundy in #1572
- Chore: set Black Python target to 3.8+ explicitely by @GabDug in #1573
- Update
flake8
plugins by @sobolevn in #1579 - CI: Run tests and pre-commit using newest Python version by @intgr in #1582
- Removed duplicate "import all" test file by @adamchainz in #1587
- Update compatible-mypy to 1.4.x by @intgr in #1588
- Version 4.2.2 release (django-stubs, django-stubs-ext) by @intgr in #1590
New Contributors
- @namper made their first contribution in #1521
- @filbasi made their first contribution in #1544
- @GabDug made their first contribution in #1567
- @rvanlaar made their first contribution in #1562
Full Changelog: 4.2.1...4.2.2
4.2.1
Headline changes
- mypy 1.3.0: Recommended mypy version updated to 1.3.0
- Compatibility: Support for Python 3.7 and Django 4.0 have been dropped.
- New logo: django-stubs has a new logo: https://raw.githubusercontent.com/typeddjango/django-stubs/4.2.1/logo.svg
Django 4.2 additions
- Added support for
db_comment=
argument on Model fields by @andrlik in #1492 - Improve
core.files.storages
types for Django 4.2 by @Alexerson in #1488 - Allow using async
StreamingHttpResponse
by @Alexerson in #1484 - Added
robust
parameter totransaction.on_commit()
by @realsuayip in #1469
Other stubs additions
- Added set/get typing for spatial Model fields by @martinlehoux in #1487
- Made
django.conf
constantsLiteral
s by @sobolevn in #1470 - Added
TypedModelMeta
for typing Model inner Meta class. This feature was deferred from the previous version due to a bug. by @intgr in #1375, #1456
Stubs fixes
- Fixed return types of many decorators (
cache_page
,cache_control
,sensitive_variables
,sensitive_post_parameters
,condition
,etag
,last_modified
) by @Kostia-K in #1465 - Fixed
ManyToManyRawIdWidget
to acceptManyToManyRel
argument by @RyanWalker277 in #1447 - Fixed
classonlymethod
decorator declaration by @adamchainz in #1494 - Fixed type of field attribute descriptors on Model classes (not instance) by @intgr in #1491
- Added missing argument default to
admin.sites.get_app_list()
by @AkaZecik in #1497 - Updated name of
lookup_needs_distinct()
function by @AkaZecik in #1498 - Fixed
_make_token_with_timestamp()
argumentsecret
type by @christianbundy in #1462 - Fixed
send_mass_email()
argument type to allowNone
by @dlesbre in #1516 - Made
UserCreationForm
generic by @monosans in #1518 - Added
SessionBase
methods, improvedSessionStore.get_model_class()
return type by @realsuayip in #1517
Other fixes
Housekeeping
- Added new logo by @adamchainz in #1499, #1500, #1501, #1502
- Dropped Python 3.7 compatibility by @intgr in #1459
- Dropped Django 4.0 compatibility by @intgr in #1468
- Update compatible-mypy & CI to mypy 1.3.0 by @intgr in #1496
- CI: Check and fix missing
__init__.py
with flake8-no-pep420 by @intgr in #1461 - Tweaked package license metadata and rename files by @intgr in #1463
- Version 4.2.1 release (django-stubs, django-stubs-ext) by @intgr in #1520
New Contributors
- @Kostia-K made their first contribution in #1465
- @andrlik made their first contribution in #1492
- @AkaZecik made their first contribution in #1497
- @asottile made their first contribution in #1503
- @Alexerson made their first contribution in #1488
- @dlesbre made their first contribution in #1516
Full Changelog: 4.2.0...4.2.1
4.2.0
Headline changes
- New version scheme: django-stubs will now use the same major.minor version number as Django.
Our Django support policy remains the same: Older versions are still partially supported, and we will continue supporting them as long as it's not a maintenance burden. - Django 4.2: This release adds initial support for some new features in 4.2.
There is still work to do, feel free to open issues or submit pull requests! - mypy 1.2.0: Recommended mypy version updated to 1.2.0
- Compatibility: This is the last release to support Python version 3.7 and Django 4.0.
Django 4.2 additions
- Added
django.utils.http.content_disposition_header()
function by @alexmv in #1448 - Add stubs for new async
Model
methods by @bigfootjon in #1443
Other stubs additions
- Added
Query.join()
method by @RyanWalker277 in #1404 - Added
Query.where
attribute by @RyanWalker277 in #1407 - Added
Model
methodsdate_error_message()
,get_constraints()
,serializable_value()
,prepare_database_save()
Addedapp_label=
argument toAdminSite.get_app_list()
by @RyanWalker277 in #1413 - Added
BaseConstraint.default_violation_error_message
attribute by @RyanWalker277 in #1419 - Added
BaseUserCreationForm
class by @monosans in #1424 - Improve
Form
,FormSet
,BoundField
,ErrorDict
andErrorList
rendering types.
AddedIntegerField.step_size
attribute and argument by @monosans in #1427 - Added type
JSONObject.__init__()
constructor by @realsuayip in #1430 - Added
RenameIndex
migration from Django 4.1 by @karamanolev in #1438 - Added
STORAGES
setting by @federicobond in #1439
Stubs fixes
- Allow lazy translation strings for constraint
violation_error_message
arguments, attributes by @realsuayip in #1418 - Allow setting
SECRET_KEY
to be str or bytes, addSECRET_KEY_FALLBACKS
, updatePasswordResetTokenGenerator
by @christianbundy in #1411 - Allow passing
BaseExpression
toUniqueConstraint.expressions
by @realsuayip in #1420 - Allow middlewares to return
StreamingReponse
by @rik in #1421 - Removed
Manager.delete()
method which is not accessible onManager
by @mschoettle in #1431 - Allow lazy translation strings in email contexts by @realsuayip in #1442
- Fixed
aiterator()
method ofQuerySet
andBaseManager
by @kjagiello in #1449 - Syndication
Feed
items do not need to beModel
instances by @bigfootjon in #1444
Mypy plugin fixes
- Allow custom
Manager
andQuerySet
classes to be inner class ofModel
by @federicobond in #1392 - Fixed handling of
ForeignKey
in abstract models when usingto=
with a string reference by @Kircheneer in #1436 - Handle repeated field lookups in calls to
QuerySet.values_list()
by @leamingrad in #1441 - Handle
Model
relations created withForeignObject
/ForeignObjectRel
by @Photonios in #1451
Other improvements
Tests & CI
- Add tests for
QuerySet.select_related
returning queryset type by @flaeppe in #1400 - Add test for overriding User model manager by @flaeppe in #1401
- CI: Add Django 4.2 to typecheck and update other Django versions by @intgr in #1455
- CI: Stop testing with Python 3.7 by @intgr in #1453
- Run CI with Django 4.2 and declare support in package metadata by @intgr in #1452
Dependencies
- Sync pre-commit and requirements by @sobolevn in #1417
- Update compatible-mypy & CI to mypy 1.2.0 by @intgr in #1429
- Bump isort to 5.12.0 by @leamingrad in #1440
- Version 4.2.0 release (django-stubs, django-stubs-ext) by @intgr in #1458
Deferred for next release
- Added
decorators.AsyncGetResponseCallable
Protocol, but is not yet used anywhere by @RyanWalker277 in #1425 - Added
BaseModelMeta
for typing Model inner Meta class by @intgr in #1375 - Rename
BaseModelMeta
toTypedModelMeta
and document it by @intgr in #1456
New Contributors
- @realsuayip made their first contribution in #1418
- @monosans made their first contribution in #1424
- @karamanolev made their first contribution in #1438
- @Kircheneer made their first contribution in #1436
- @kjagiello made their first contribution in #1449
- @alexmv made their first contribution in #1448
- @bigfootjon made their first contribution in #1443
Full Changelog: 1.16.0...4.2.0
1.16.0
What's Changed
This release updates recommended mypy version to 1.1.x.
Stubs fixes
- Annotate
BaseCreateView.object
attribute asModel | None
by @RyanWalker277 in #1377 - Fixed
ListFilter.expected_parameters()
return type by @pheki in #1373 - Fixed type of
AdminSite.site_url
to allowNone
by @LincolnPuzey in #1379 - Fixed
@vary_on_headers()
decorator to preserve decorated function type by @RyanWalker277 in #1370
Stubs additions
- Added argument
validate_constraints=
toModel.full_clean()
method by @lklivingstone in #1385 - Added
Model.validate_constraints()
method by @OvervCW in #1388
Housekeeping
- Update recommended mypy & CI to 1.1.1, update MultiValueDict by @intgr in #1391
- Release script: Also clean build directories before a build by @intgr in #1378
- Version 1.16.0 release by @intgr in #1396
New Contributors
- @pheki made their first contribution in #1373
- @LincolnPuzey made their first contribution in #1379
- @lklivingstone made their first contribution in #1385
- @OvervCW made their first contribution in #1388
Full Changelog: 1.15.0...1.16.0