Skip to content

Releases: typeddjango/django-stubs

4.2.4

05 Sep 08:22
0288263
Compare
Choose a tag to compare

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, 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

Thanks a lot to all contributors and maintainers! 🎉

4.2.3

29 Jun 17:10
2ea83a7
Compare
Choose a tag to compare

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 to default_auto_field by @GabDug in #1596
  • Fixed type error when subclassing MiddlewareMixin.__call__() and using return self.get_response() by @GabDug in #1595
  • Allow None as redirect_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 setting disallow_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

  • Run tests in multiple shards and all Python versions by @sobolevn in #1603

Housekeeping

  • Converted _typeshed.Self usages to typing_extensions.Self (PEP 673) by @intgr in #1591
  • Version 4.2.3 release (django-stubs only) by @intgr in #1604

New Contributors

Full Changelog: 4.2.2...4.2.3

4.2.2

27 Jun 17:51
5806511
Compare
Choose a tag to compare

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 with strict_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 and DatabaseOperations classes by @GabDug in #1571

Stubs additions

Stubs fixes

  • Fixed create_model_instance incorrect data argument type by @namper in #1521
  • Marked RequestSite.{save,delete} methods as NoReturn since they always raise by @sobolevn in #1530
  • Updated SafeExceptionReporterFilter attributes and removed obsolete CLEANSED_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 base Field and GenericIPAddressField 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 for Window.order_by(), allow None for asc/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 for SRIDCacheEntry/EmailValidator, improved urls.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

  • Added TypedDatabaseRouter as database router base class by @intgr in #1522

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

New Contributors

Full Changelog: 4.2.1...4.2.2

4.2.1

02 Jun 14:16
21e541f
Compare
Choose a tag to compare

Headline changes

Django 4.2 additions

Other stubs additions

  • Added set/get typing for spatial Model fields by @martinlehoux in #1487
  • Made django.conf constants Literals 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
    • Fixed missing __init__.py in django_stubs_ext.db by @monosans in #1460

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 accept ManyToManyRel 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() argument secret type by @christianbundy in #1462
  • Fixed send_mass_email() argument type to allow None by @dlesbre in #1516
  • Made UserCreationForm generic by @monosans in #1518
  • Added SessionBase methods, improved SessionStore.get_model_class() return type by @realsuayip in #1517

Other fixes

Housekeeping

New Contributors

Full Changelog: 4.2.0...4.2.1

4.2.0

27 Apr 12:45
87f48b3
Compare
Choose a tag to compare

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 methods date_error_message(), get_constraints(), serializable_value(), prepare_database_save()
    Added app_label= argument to AdminSite.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 and ErrorList rendering types.
    Added IntegerField.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, add SECRET_KEY_FALLBACKS, update PasswordResetTokenGenerator by @christianbundy in #1411
  • Allow passing BaseExpression to UniqueConstraint.expressions by @realsuayip in #1420
  • Allow middlewares to return StreamingReponse by @rik in #1421
  • Removed Manager.delete() method which is not accessible on Manager by @mschoettle in #1431
  • Allow lazy translation strings in email contexts by @realsuayip in #1442
  • Fixed aiterator() method of QuerySet and BaseManager by @kjagiello in #1449
  • Syndication Feed items do not need to be Model instances by @bigfootjon in #1444

Mypy plugin fixes

  • Allow custom Manager and QuerySet classes to be inner class of Model by @federicobond in #1392
  • Fixed handling of ForeignKey in abstract models when using to= 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 with ForeignObject/ForeignObjectRel by @Photonios in #1451

Other improvements

  • Don't require tomli dependency on Python>=3.11 by @monosans in #1423

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

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 to TypedModelMeta and document it by @intgr in #1456

New Contributors

Full Changelog: 1.16.0...4.2.0

1.16.0

16 Mar 14:26
6a850f6
Compare
Choose a tag to compare

What's Changed

This release updates recommended mypy version to 1.1.x.

Stubs fixes

Stubs additions

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

Full Changelog: 1.15.0...1.16.0

django-stubs-ext 0.8.0

15 Mar 17:22
dd92489
Compare
Choose a tag to compare

What's Changed

  • Make BaseConnectionHandler generic in monkeypatching by @adambirds in #1349
  • Introduce QuerySetAny type for QuerySet isinstance checks by @PIG208 in #1199
  • Remove unintentional re-exports by @intgr in #1309

Housekeeping

  • Prepare django-stubs-ext 0.8.0 release by @intgr in #1395

1.15.0

22 Feb 10:51
74c39d5
Compare
Choose a tag to compare

This release updates recommended mypy version to 1.0.x. No changes in Django version compatibility.

Some re-exports that were unintentional have been removed. If you get errors like error: Module "django.core.cache" has no attribute "ConnectionProxy" (for any import path), you probably need to change the module you are importing e.g. ConnectionProxy from. These re-exports were never intentional and are not stable across Django versions.

In addition to code contributions, I'd like to thank @ngnpope, @sobolevn, @ljodal, @christianbundy, @mschoettle for helping out with reviews.

What's Changed

Fixes

Django 4.2 compatibility

Documentation

  • Use supported version in typecheck_tests command in Contributing guide by @adamantike in #1251

Housekeeping

Dependencies

New Contributors

Full Changelog: 1.14.0...1.15.0

1.14.0

26 Jan 10:44
5338769
Compare
Choose a tag to compare

What's Changed

This release updates recommended mypy version to 0.991 and fixes a few regressions in the last release. No changes in Django version compatibility.

In addition to code contributions, I'd like to thank @flaeppe, @ngnpope and @sobolevn who helped out with reviews.

Fixes for regressions from last version

  • Fix some errors in GeoDjango stubs by @ciscorn in #1335
    • Fixes "OGRGeometry" has no attribute "__iter__" (not iterable) #1333
    • Fixes error: "bytes" has no attribute "tobytes" #1336
  • Allow returning Response from admin @action callbacks by @christianbundy in #1331
    • Fixes Recent change to admin action decorators bans return values #1330
  • Allow int, bool for data argument in test.client.Client.get() by @nils-van-zuijlen in #1345
    • Fixes Recent changes to test.client.Client.get() do not accept valid data types #1327

Mypy plugin fixes

  • Fix crash when filtering on implicit pk field on abstract model by @flaeppe in #1328
  • Suppress FieldDoesNotExist raised from attribute on class definition by @flaeppe in #1329
  • Fix crash when FK references unknown 'app_label' by @flaeppe in #1342

Enhancements

Housekeeping, dependencies

New Contributors

Full Changelog: 1.13.2...1.14.0

1.13.2

21 Jan 12:37
7d50e5b
Compare
Choose a tag to compare

What's Changed

Mypy plugin fixes

  • Avoid index errors that cause Mypy to raise Internal Error by @jimmylai in #1317

Strings/translations

  • Enhance support for gettext_lazy in AdminSite and ModelAdmin by @rclement in #1296
  • Support lazy strings for form errors and ValidationError by @mschoettle in #1319
  • Add support for send_mail subject using gettext_lazy by @mschoettle in #1304
  • Add FAQ entry regarding StrPromise to README by @mschoettle in #1320

GeoDjango

Decorators

  • Fix @classproperty decorator by @intgr in #1287
  • Improve types of django.contrib.admin.decorators by @flaeppe in #1267
  • Improve ModelAdmin and decorator hints and attributes, add tests by @intgr in #1292
  • Improve system check registry hints by @intgr in #1249
  • Fix override_settings decorator typing by @martinlehoux in #1322

Other type stubs changes

Housekeeping

CI

Dependency updates

New Contributors

Full Changelog: 1.13.1...1.13.2