250 Commits

Author SHA1 Message Date
Dave Halter
fd057010f6 Model.objects should be a ClassVar
Model.objects is only available on classes and while we cannot force this, without ClassVar it's kind of only available on instances.

I have noticed this when I was writing a Jedi plugin that makes django-stubs work properly.
2020-06-11 23:21:10 +02:00
Nikita Sobolev
3d2534ea8d Closes #392 2020-06-08 10:55:30 +03:00
Kacper
54f5f63e71 Issue 379 (#391)
* pytest-mypy-plugins package newer version

* Revert "pytest-mypy-plugins package newer version"

This reverts commit 871347a86577a5dad867bc751689bbc06d2bcae0.

* update tests ignores for django

* Revert "update tests ignores for django"

This reverts commit 93fc66e311af62cf8cf5b79a72ab723bf3cf060a.

* tests for python 3.8 WIP - initial commit

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>
2020-06-06 14:28:28 +03:00
Kacper
4c5723d368 WIP Issue 388 (#390)
* updated mypy dependency

* update readme

* readme update v2

* pytest-mypy-plugins newer version

* updated pytest_mypy_plugins name

* update ignored errors for typechecking django test suite

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>
2020-06-06 11:35:51 +03:00
Alexander Viklund
7e0e43135d BaseForm.prefix may be None (#389) 2020-06-04 21:24:42 +03:00
Kacper
e05b84e32d Issue 378 (#387)
* proper redirect return type annotations made with Literal

* Mapping instead of Dict type annotation for context in render() with test

* removed Union and Context

* typo

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>

Add __init__ to OrderedSet (#381)

Issue 382 (#384)

* WIP fix, pushed for testing

* added _ prefix for internal types

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>

Fix parameter types for assertJSONEqual/NotEqual (#385)

Add get_supported_language_variant (#386)

Issue 309 (#383)

* added tags for user models

* type test for HttpRequest.user

* test for User and AnonymousUser tags

* httrequest test fix

* checking python version fix for readibility

* Rewrite version check for readability

* Annotate is_authenticated/is_anonymous with Literal-type

* Add auth in INSTALLED_APPS in test

* Fix wrong type assertion in test

* Fix misconception of how branch-testing works

* Remove user from WSGIRequest

* Change HttpRequest-transformer to set user-type to include AnonymousUser

* Add check for anonymous_user_info=None to appease mypy

* Isort transformers/request

* Remove trailing whitespace

* Remove unused import

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>

* fix formatting and unused import

* reformatted again

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>
2020-06-03 23:46:30 +03:00
Alexander Viklund
71751d3795 Issue 309 (#383)
* added tags for user models

* type test for HttpRequest.user

* test for User and AnonymousUser tags

* httrequest test fix

* checking python version fix for readibility

* Rewrite version check for readability

* Annotate is_authenticated/is_anonymous with Literal-type

* Add auth in INSTALLED_APPS in test

* Fix wrong type assertion in test

* Fix misconception of how branch-testing works

* Remove user from WSGIRequest

* Change HttpRequest-transformer to set user-type to include AnonymousUser

* Add check for anonymous_user_info=None to appease mypy

* Isort transformers/request

* Remove trailing whitespace

* Remove unused import

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>
2020-06-03 20:29:19 +03:00
Alexander Viklund
25f92e8e56 Add get_supported_language_variant (#386) 2020-06-03 20:04:19 +03:00
Alexander Viklund
28d47c7e93 Fix parameter types for assertJSONEqual/NotEqual (#385) 2020-06-03 20:03:59 +03:00
Kacper
197cb4058e Issue 382 (#384)
* WIP fix, pushed for testing

* added _ prefix for internal types

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>
2020-06-03 12:58:03 +03:00
Alexander Viklund
dac2b31fb2 Add __init__ to OrderedSet (#381) 2020-06-02 13:56:11 +03:00
Kacper
8d2600136a Issue 355 (#376)
* Mapping instead of Dict type annotation for context in render() with test

* removed Union and Context

* typo

Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>
2020-06-01 19:41:57 +03:00
Pavel Savchenko
570772f973 Revert "Allow template render to string helper functions to accept Context (#372)" (#377)
This reverts commit 64cbb0f70e.
2020-06-01 14:34:21 +03:00
Anton Agestam
d5c1bfb12a Increase accuracy of ModelAdmin types (#375)
* Increase accuracy of ModelAdmin types

* Add comment for regression test
2020-05-30 00:24:47 +03:00
Pavel Savchenko
64cbb0f70e Allow template render to string helper functions to accept Context (#372)
* Add failing test case for render_to_string

* Allow Context objects in template render functions
2020-05-23 13:47:39 +03:00
Ville Skyttä
6f5a39625e Add release notes project URL (#365)
Background info at https://github.com/pypa/warehouse/pull/7882
2020-05-05 18:38:11 +03:00
Anthony Ricaud
bf604a0398 Add BaseForm._html_output (#364) 2020-04-30 14:36:55 +03:00
Ashish Bansal (mrphantom)
92c8dfc93f Fix wrong BaseCache typings (#363)
django.core.cache.backends.base.BaseCache were invalid. This commit
fixes them in accordance with [0].

[0] 447980e72a/django/core/cache/backends/base.py (L108)
2020-04-24 12:44:55 +03:00
Jorgen Phillips
c10c55052c Add add_to_class method to Model (#361)
* Add add_to_class method to Model

* Fix @classmethod decorator
2020-04-24 01:11:16 +03:00
Sergey Tikhonov
96914e466b Annotate AdminForm.__init__ (#359) 2020-04-16 18:22:21 +03:00
Onyeka Aghanenu
90ed7f332d Fix Modelform auto_id to accept Boolean type. (#356) 2020-04-13 19:04:18 +03:00
Kacper
a801501151 stub for _build_app_dict (#351)
Co-authored-by: Kacper Szmigiel <szmigielkacper@gmai.com>
2020-04-04 20:38:42 +03:00
Sid Mitra
8ea59985df Add RESTRICT and RestrictedError to django.db.models.deletion (#345)
* Add RESTRICT and RestrictedError to django.db.models.deletion

* Add black fomatting changes
2020-04-03 17:02:34 +03:00
Ceesjan Luiten
2964ed53d7 Improve type of BaseForms.files (#350)
This is valid Django, which failed to pass with the old type-defintion:

    class MyForm(Form):
      myparam = MultiFileField(...)

      self.clean(self, *args, **kwargs):
        self.files.getlist('myparam', [])
2020-03-31 10:16:02 +03:00
Stevan Milic
1b9176f994 Add state attribute to Model (#347) (#348)
Add from_db method to Model

Co-authored-by: Stevan Milic <stevan.milic@tradecore.com>
2020-03-30 10:35:40 +03:00
Nikita Sobolev
54d0d018c6 Minor type improvements after linting (#343) 2020-03-19 18:04:51 +03:00
Maxim Kurnikov
1af3a12f2c bump to 1.5.0 2020-03-15 00:59:58 +03:00
Marti Raudsepp
7af89ee6a6 Update to mypy 0.770 (#341) 2020-03-13 16:45:45 +03:00
Marti Raudsepp
afa16bfb74 Make decorator functions transparent to Mypy (#306)
By declaring return type as -> Callable[[_C], _C], Mypy can infer that
the decorated function has also the same arguments and return type as
the original.

View functions are constrained to return HttpResponseBase (or any
subclass of it).

Also added typecheck test coverage to most of the cases.
2020-03-12 00:32:30 +03:00
Marti Raudsepp
f77073157b Fix CI build errors (#339)
* Updated gitpython dependency to fix error:
  ModuleNotFoundError: No module named 'gitdb.utils.compat'
* Updated Django repository git refs because old 3.0.x commit hash gave error:
  stderr: 'fatal: reference is not a tree: 6cb30414bc0f83b49afc4cae76d4af5656effe9a'
* Newer Django version also needs new ignores.
2020-03-12 00:19:51 +03:00
Kevin Marsh
fe3b95c611 Fix input types of humanize functions (#335) 2020-02-27 10:10:53 +03:00
Daniel Hillier
d0f9730c53 Add db.models.fields.Field method stubs for custom Fields (#331)
Add stubs for: pre_save, get_db_prep_value, get_db_prep_save
2020-02-17 10:08:39 +03:00
Leo Shklovskii
0fdd678d65 fix typo in README.md (#328) 2020-02-15 08:28:47 +03:00
Semyon Pupkov
2397065fa6 signing.loads allows use timedelta for max_age (#325)
* signing.loads allows use timedelta

https://github.com/django/django/blob/stable/2.2.x/django/core/signing.py#L191

* fix black
2020-02-14 14:12:58 +03:00
Semyon Pupkov
04023a9f31 Fix readme (#326) 2020-02-13 23:20:58 +03:00
Marti Raudsepp
95e6c94319 Improve test client type stubs (#322)
* Added missing `follow: bool` argument to Client request methods.
* Annotated return types as `HttpResponse` instead of `Any`.
* Made `Client` class inherit from `RequestFactory`, as it does in Django.
* Changed `json()` return type to Any, as it can also be a list.

Wrt (2), these return types were reverted from `HttpResponse` to `Any`
in commit 287c64d6fb. But I suspect that
was simply to silence mypy warnings about "incompatible with supertype
RequestFactory", not because there were any issues with the annotation.

Note that `Client.request()` monkey-patches the `HttpResponse` object
with some additional attributes. Those attributes were already annotated
before, I reordered and added additional comments to make it clear where
they come from.
2020-02-12 18:44:17 +03:00
Brian Helba
d96aee7a8b Fix the type of form.Field.widget (#321)
The `widget` class attribute of `form.Field` expects a `Widget` class, not an instance of `Widget`.

See: https://docs.djangoproject.com/en/3.0/ref/forms/fields/#widget
Also usages at: 3259983f56/django/forms/fields.py (L46)
2020-02-07 12:42:02 +03:00
Nikita Sobolev
2489bb9b04 Adds CONTRIBUTING.md (#319)
* Adds CONTRIBUTING.md

Closes #206 
Refs #274

* Update CONTRIBUTING.md
2020-02-06 15:01:56 +03:00
Nikita Sobolev
3a8f278c88 Update README.md 2020-02-06 11:09:16 +03:00
Nikita Sobolev
85b65b4578 Update README.md 2020-02-06 11:07:23 +03:00
Nikita Sobolev
150e8e862a Update README.md (#317)
* Update README.md

* Update README.md

* Update README.md
2020-02-06 11:03:38 +03:00
Vince Salvino
5b3088a17a Fix cache arg type for django.utils.cache.learn_cache_key() (#316) 2020-02-01 22:03:46 +03:00
Konstantin Alekseev
f89a0fbbaa Cleanup checks framework (#310) 2020-01-30 14:38:23 +03:00
Tatsh
438f8b5829 Add OutputWrapper write() signature (#301)
* Add OutputWrapper write() signature

* Add #type: ignore[override] to OutputWrapper write() signature
2020-01-28 01:34:13 +03:00
Joseph Kahn
836d5acd8f Allow error handlers to be strings (#307)
Based on the docs on this page: https://docs.djangoproject.com/en/3.0/ref/urls/
2020-01-28 01:33:49 +03:00
Cesar Canassa
bfae51e64c Added manager _db (#296) 2020-01-14 17:05:29 +03:00
Daniel Hillier
e3801918e3 Fix incorrect type for django.core.files.File.file (#293) (#294) 2020-01-11 14:27:46 +03:00
Marti Raudsepp
6f296b0a91 Implement @cached_property attribute inference (#292) 2020-01-10 13:57:09 +03:00
Nikita Sobolev
7ba578f6b2 Refactors validators types (#284)
* Update __init__.pyi

* It should not fail right now 🤔

* Refactor validators a bit

* Fixes CI

* Update __init__.pyi
2019-12-21 15:44:26 +03:00
Maksim Kurnikov
cb123de105 BaseManager.from_queryset(): properly resolve methods for QuerySet defined in another file (#282)
* BaseManager.from_queryset() from another file

* only anal_type per argument

* add resolve for return_type

* fix mypy errors

* remove leftover comment
2019-12-18 20:01:20 +03:00
Maksim Kurnikov
38135f2d1f Merge pull request #281 from mkurnikov/update-deps
Update dev deps, mypy to 0.760
2019-12-18 00:13:11 +03:00
Maxim Kurnikov
998b659749 bump to 1.4.0 2019-12-18 00:03:29 +03:00
Maxim Kurnikov
72f69e1c5e remove unused ignores 2019-12-18 00:02:55 +03:00
Maxim Kurnikov
d666ecd36f update dev deps, mypy to 0.760 2019-12-17 23:50:50 +03:00
Maksim Kurnikov
c1af26c027 handle return value of anal_type properly (#280) 2019-12-17 23:36:44 +03:00
Maxim Kurnikov
3c3dfcbc9f bump to 1.3.3 2019-12-17 19:20:27 +03:00
Maksim Kurnikov
1196336e3b Perform anal_type for arguments and return type when copying methods to another class (#279)
* Found the reproducible test case

* fix import resolution for method copy

* remove irrelevant parts from test

* fix mypy errors

Co-authored-by: Boger <kotvberloge@gmail.com>
2019-12-17 19:19:31 +03:00
Maksim Kurnikov
665f4d8ea1 Make related manager inherit from objects of related model (#278)
* related manager inherits from objects of related model

* fix test typechecking

* lint
2019-12-17 19:06:27 +03:00
Dima Boger
b3ed9e4827 Add inheritance QuerySet support for from_queryset (#275)
* Add testcase for queryset inheritance

* Add PoC

* Add condition for stop to looping over mro

* Change harcoded queryset class name to constant from fullnames
2019-12-16 20:16:41 +03:00
Marti Raudsepp
fb1593630a Expand stubs for django.core.management.color (#276)
Many attributes were previously missing; 'DEBUG' and 'INFO' attributes
were never supported by Django.
2019-12-16 20:16:21 +03:00
JR Heard
031d42a75d update ChoiceField's choices kwarg's annotation (#273)
per the [docs](https://docs.djangoproject.com/en/3.0/ref/forms/fields/#choicefield), `choices` is:

> Either an iterable of 2-tuples to use as choices for this field, or a callable that returns such an iterable.
2019-12-14 09:30:50 +03:00
Maxim Kurnikov
f7e1cfc6c7 bump to 1.3.2 2019-12-13 23:55:08 +03:00
Maksim Kurnikov
d0c25e3bce Allow to run from_queryset() with BaseManager, Manager (#271)
* allow to run from_queryset() with BaseManager, Manager

* fix tests
2019-12-13 20:16:33 +03:00
Maksim Kurnikov
1c31e71ffc enable 'model_forms' for tests typechecking (#270) 2019-12-13 13:30:21 +03:00
Dmitry Groshev
6b3b6be3c1 add .model field to _BaseQuerySet (#268) 2019-12-12 21:50:59 +03:00
Maksim Kurnikov
5832605053 Remove warning about unsupported expression types (#266)
* remove warning about unsupported expression for _meta.get_field()

* lint
2019-12-12 08:20:52 +03:00
Maksim Kurnikov
31e795016f values(), values_list() with ManyToManyField (#267) 2019-12-12 08:09:47 +03:00
Maxim Kurnikov
0cba3f9fd6 bump to 1.3.1 2019-12-12 08:03:47 +03:00
Maksim Kurnikov
f02050911f various annotation improvements (#258) 2019-12-12 06:42:29 +03:00
henribru
e8e6fca78c Fix return type of refresh_from_db (#244) 2019-12-12 05:36:11 +03:00
Maksim Kurnikov
ade48b6546 Add support for BaseManager.from_queryset() (#251)
* add support for BaseManager.from_queryset()

* cleanups

* lint fixes
2019-12-12 05:35:56 +03:00
Maksim Kurnikov
b8f29027d8 Suppress IncompleteDefnException on final_iteration and continue with the loop (#260)
* suppress IncompleteDefnException on final_iteration

* lint
2019-12-12 01:04:24 +03:00
Hannes Ljungberg
eba3f6cb15 Update django.contrib.auth with Django 3.0 compatibility (#256)
* Add support for BaseBackend

* Add User.get_user_permissions

* Add support for UserManager.with_perm

* Add support for reset_url_token
2019-12-11 01:10:10 +03:00
Maksim Kurnikov
5a45544e76 Optimize tests typechecking script (#255)
* skip whole Django repo for tests typechecking

* lint
2019-12-11 00:52:08 +03:00
Maksim Kurnikov
8c2de7da56 add a number of django test directories for typecheck (#257) 2019-12-11 00:51:32 +03:00
Maksim Kurnikov
d43c6dc7e2 Merge pull request #254 from mkurnikov/better-force-text-types
Better types for django.utils.encoding
2019-12-10 23:36:38 +03:00
Maxim Kurnikov
f7e2109e06 add @overload clauses to smart_text, smart_bytes, force_bytes 2019-12-10 23:22:23 +03:00
Hannes Ljungberg
cea62abf5a Add support for database functions introduced in 3.0 (#253)
* Add support for hash database functions

* Add support for Sign
2019-12-10 22:36:11 +03:00
Hannes Ljungberg
3b69ec6a72 Add support for RangeBoundary (#252) 2019-12-10 22:09:55 +03:00
Seth Yastrov
7e794534c0 Better type for force_text using overloads/Literal
- If a str is passed in, it returns a str.
- If strings_only = True and a "protected type" is passed in, returns that type.
- Default if it doesn't match the overloads: return a str
2019-12-10 21:28:40 +03:00
Hannes Ljungberg
f5f33b061d Add support for exclusion constraints (#249) 2019-12-10 20:50:28 +03:00
Ran Benita
58b26fdbd3 Improve TestCase.assertNumQueries type (#250) 2019-12-10 19:37:13 +03:00
Youssef Moussaoui
9ca79c24a2 Move BLANK_CHOICE to django.db.models.fields (#242) 2019-12-08 08:19:24 +03:00
Maxim Kurnikov
540e28f4c6 bump version to 1.3.0 2019-12-06 23:37:19 +03:00
Maksim Kurnikov
4ac43c6ed6 Add Django 3.0 testing to CI (#246)
* add Django 3.0 testing to CI

* remove importlib_metadata usage

* conditionally load choices module for tests
2019-12-06 23:36:24 +03:00
Maksim Kurnikov
cadd6c963b fix model's on_cascade= parameter for test, update to latest gdal (#247) 2019-12-06 03:40:55 +03:00
Konstantin Alekseev
041754f817 Fix smtp backend open (#240) 2019-12-01 20:46:11 +03:00
Konstantin Alekseev
c0c5d1e588 Cleanup EmailMessage types (#208)
* Cleanup EmailMessage types

* Typecheck email module tests.
2019-12-01 17:14:16 +03:00
Maksim Kurnikov
f824003cc4 remove unused ignore pattern (#239) 2019-12-01 00:09:36 +03:00
Youssef Moussaoui
58f1833cab Declare is_relation and related_model on Field (#230) 2019-11-30 22:40:22 +03:00
Maksim Kurnikov
cbb6a7a9ac Merge pull request #238 from mkurnikov/mypy-750
Mypy 0.750 support
2019-11-30 22:27:50 +03:00
Maxim Kurnikov
2c4827bbaf properly change type of self for methods on custom manager classes 2019-11-30 22:08:16 +03:00
Maxim Kurnikov
5a151bf851 update django tests branch 2019-11-30 20:56:31 +03:00
Konstantin Alekseev
cbc7159995 Support mypy 0.750 2019-11-30 13:39:28 +03:00
Patrick Gingras
df4c17a947 added base_fields and declared_fields properties to Form (#235) 2019-11-27 22:48:05 +03:00
yaegassy
445abc046c README.md Fix: sample code for "Notes" (#234) 2019-11-26 15:40:21 +03:00
Anthony Ricaud
557b7a4fa3 Add new View.setup method introduced in Django 2.2 (#233)
https://docs.djangoproject.com/en/2.2/ref/class-based-views/base/#django.views.generic.base.View.setup
https://github.com/django/django/blob/2.2/django/views/generic/base.py#L83-L87
2019-11-20 23:49:38 +03:00
Maksim Kurnikov
8343d76895 Fix has_perm() methods for auth backend, and for contrib.auth.models (#232)
* fix has_perm() methods

* lint
2019-11-19 04:54:17 +03:00
Maksim Kurnikov
8d986a0f43 remove catch-all __getattr__ for Manager, fix some issues with manager methods (#227) 2019-11-12 20:36:07 +03:00
Pilifer
e9a90ebff0 More precise annotations of utils.timezone functions that return instances of tzinfo subclasses. (#209)
* fix annotations of utils.timezone

* use intermediary tzinfo subclass exposed in pytz typeshed

* fix annotations of get_fixed_timezone as it returns datetime.timezone in Django 2.2

* add explanatory comment to get_current_timezone annotations

* black utils.timezone.pyi
2019-11-12 18:27:54 +03:00
Christopher Sabater Cordero
7b74a6944a Add a few missing types to the stubfiles (#214)
* Add types to stub files.

* Fix black and flake8 errors.
2019-11-12 18:25:31 +03:00
Seth Yastrov
83f11a0fc6 Add Tags.translation to stub (#226) 2019-11-12 18:23:29 +03:00
Seth Yastrov
2829faf1af Both CSRF_COOKIE_SAMESITE and SESSION_COOKIE_SAMESITE should be Optional (#216) 2019-11-12 16:13:16 +03:00
src
d061e84cc7 Add HttpResponsePermanentRedirect to django.shortcuts (#211) 2019-11-12 16:12:36 +03:00
Anna Sidwell
3a9263dc62 Two small improvements (#217)
* Add return type for admin.SimpleListFilter.lookups

* force_login() can take any user, not just builtin
2019-11-12 13:31:24 +03:00
Yngve Høiseth
14aea2b4d4 Allow returning bool from test_func (#220) 2019-11-12 05:52:23 +03:00
Maksim Kurnikov
287c64d6fb Pin to 0.740 and fix CI (#225)
* update django sources

* pin mypy version, update to 0.740

* fix tests typechecking

* fix lint
2019-11-12 05:17:36 +03:00
Nikita Sobolev
6601121db2 Fixes travis url 2019-10-21 23:47:06 +03:00
Andrey
87d59c7c1a Fix django.contrib.admin.options.BaseModelAdmin.has_add_permission (#205)
* Fix `django.contrib.admin.options.BaseModelAdmin.has_add_permission` (#203).

* Add `django.db.models.base.Model.unique_error_message` (#204).
2019-10-11 12:16:21 +03:00
Maxim Kurnikov
8402e7c53e improve annotations in some places (#202)
* improve annotations in some places

* linting
2019-10-07 14:50:45 +03:00
Maxim Kurnikov
dceb075152 fix annotation for BaseCommand.handle() (#201) 2019-10-05 21:36:41 +03:00
Maxim Kurnikov
7e3f4bfa02 Fix ForeignKey type for self-reference defined in the abstract model (#200) 2019-10-05 21:36:29 +03:00
Maxim Kurnikov
db9ff6aaf6 Fix crash if model from same app referenced in RelatedField cannot be resolved (#199)
* do not crash if model from same app refd in ForeignKey cannot be resolved

* bump to 1.2.0
2019-10-05 20:00:51 +03:00
Maxim Kurnikov
717be5940f Reorganize code a bit, add current directory to sys.path (#198)
* reorganize code a bit

* add current directory to sys.path

* remove PYTHONPATH mention from the docs

* linting
2019-10-05 19:44:29 +03:00
Nikita Sobolev
b939bc96b7 Improves README with new example repo, python version matrix (#195) 2019-10-01 15:24:48 +03:00
Maxim Kurnikov
02bdf5be95 add support for typechecking of filter/get/exclude arguments (#183)
* add support for typechecking of filter/get/exclude arguments

* linting
2019-09-30 03:05:40 +03:00
Maxim Kurnikov
4d4b0003bd Fix Paginator properties mistyped as Callables (#193)
Co-authored-by: Nick Sweeting <git@sweeting.me>
2019-09-28 22:16:20 +03:00
Maxim Kurnikov
e143ba568c add mypy compatibility table (#190)
* add mypy compatibility table

* add django versions to compatibility table
2019-09-28 22:14:16 +03:00
Maxim Kurnikov
32c0cbca45 add some diagnostic for unused ignores for tests typechecking (#191) 2019-09-28 21:38:56 +03:00
Anthony Ricaud
acc3ca4205 Contexts can contain Any data (#192) 2019-09-28 21:38:04 +03:00
Maxim Kurnikov
be3fc259d5 fix compatibility with 0.730 (#189) 2019-09-28 05:23:55 +03:00
Maxim Kurnikov
7725b416b6 add unused ignores reporting (#188) 2019-09-28 04:48:44 +03:00
Maxim Kurnikov
2c23d8e70f Use runtime information to determine whether class is a models.Model subclass (#182) 2019-09-28 04:05:54 +03:00
Anthony Ricaud
5910bd1b25 resolve_template accepts Sequences of str (#187)
- resolve_template is checking for lists or tuples so let's use a generic Sequence
- Union[Template, Template] seemed redundant
2019-09-25 23:32:23 +03:00
Maxim Kurnikov
963d50c717 add linting stubs with flake8-pyi and check for unused imports (#186) 2019-09-25 02:20:23 +03:00
Maxim Kurnikov
7407b93151 Fix type annotations for django.utils.safestring (#179)
* Add/fix types for django.utils.safestring.mark_safe

Django code ref: 964dd4f4f2/django/utils/safestring.py (L71-L84)

* add generic annotations for mark_safe, remove SafeBytes as it is basically deprecated

Co-authored-by: Daniel Hahler <github@thequod.de>
2019-09-23 21:17:17 +03:00
Daniel Hahler
afcd0d9293 Bump isort, use --diff (#164)
* dev-requirements: bump isort: 4.3.4 => 4.3.21

* isort: use --diff

* known_first_party = mypy_django_plugin

* Run isort
2019-09-23 20:45:43 +03:00
Maxim Kurnikov
a85dbff793 update import_all test, add some stubs for postgres (#178) 2019-09-23 19:47:11 +03:00
Maxim Kurnikov
68aebe2528 Add django.contrib.gis.db.models and django.contrib.gis.db.models.fields (#177)
* add django.contrib.gis.db.models and django.contrib.gis.db.models.fields

* install gdal in ci

* add sudo to apt

* add apt update
2019-09-23 19:30:32 +03:00
Peter Law
d3dca5b408 related_name is Optional[str] (#176)
In the current Django (2.1, 2.2), the `related_name` parameter to
`OneToOneField` and `ForeignKey` classes (much like `ManyToManyField`
and the base `ForeignObject` classes) is `Optional[str]`. While
it's true that most authors won't pass `None` here, derived field
types will want to be able to do so.
2019-09-23 17:38:34 +03:00
Peter Law
c69090ec5b Options.verbose_name_raw is always a string (#175)
At least in the current implementation.
2019-09-21 16:07:55 +03:00
Maxim Kurnikov
29ac1c3017 Split AddManagers for model in separate stages to process IncompleteDefnException properly (#171) 2019-09-18 02:20:20 +03:00
Maxim Kurnikov
23ad65033b add custom Field processing for mixins used in the Model subclasses (#167) 2019-09-18 01:40:41 +03:00
Maxim Kurnikov
64720f492c add proper stubs for django.contrib.auth.models model fields (#170) 2019-09-18 01:40:15 +03:00
Maxim Kurnikov
a8fdd4c673 cleanup some stubs in contrib.admin, contrib.admindocs (#169) 2019-09-17 23:30:49 +03:00
Maxim Kurnikov
813dd8cc1a make types for generic mixins less strict (#168) 2019-09-17 23:30:07 +03:00
Maxim Kurnikov
2b53fa5a1a Fix typecheck tests ci (#165)
* remove mention of mypy newsemanal to prepare for 0.730

* make typecheck_tests CI really work

* fix lints

* fix intentional error

* merge stderr in stdout to preserve order

Co-authored-by: Daniel Hahler <github@thequod.de>
2019-09-16 14:35:13 +03:00
Daniel Hahler
e3ea84143f WIP: fix scripts/typecheck_tests.py (#162)
* WIP: fix scripts/typecheck_tests.py

Exit non-zero if it fails to run.

Currently it fails on CI, but goes unnoticed:
https://travis-ci.com/typeddjango/django-stubs/jobs/235296115

* exit on unexpected rc, and output on stderr

* Fix

* scripts/mypy.ini: django_settings_module=scripts.django_tests_settings
2019-09-14 22:23:45 +03:00
Daniel Hahler
82e3aa5464 ci: minor cleanup (#161)
* ci: Travis: remove unnecessary option with black

Already in config, adding a final newline there.

* .travis.yml: minor cleanup
2019-09-14 21:49:13 +03:00
Daniel Hahler
5b9a467cf0 flake8: ignore certain errors for .pyi files (#159) 2019-09-14 10:52:52 +03:00
Nikita Sobolev
4a4dc53c4d Adds syntax highlight 2019-09-08 12:31:30 +03:00
Nikita Sobolev
77fd46987d Adds gitter icon 2019-09-08 12:30:41 +03:00
Nikita Sobolev
9291164a6b Adds github tempaltes, refs #112 (#155) 2019-09-06 09:16:44 +03:00
Wlises R
0c3e06e875 Solve issue 154: Fix wrong type for size in File. (#156) 2019-09-06 09:16:19 +03:00
Jared Kerim
b8379d4fe6 Add property to forms.changed_data fixes #148 (#149) 2019-08-30 11:18:24 +03:00
Nikita Sobolev
caa0e60743 Fixes travis badge 2019-08-25 20:42:00 +03:00
Maxim Kurnikov
de4fa92441 bump to 1.1.0 2019-08-24 18:40:57 +03:00
Maxim Kurnikov
dce0c0e930 Add 'django.core.cache.backends.memcached' stubs (#141) 2019-08-24 18:35:42 +03:00
Maxim Kurnikov
fc9a335dfd make ValuesQuerySet have proper Collection generic type (#140) 2019-08-24 18:24:21 +03:00
Maxim Kurnikov
5fc39ff110 Merge pull request #139 from mkurnikov/none-to-optional-annotations
Replace None annotations with Optional[...] around, stability fixes
2019-08-24 17:32:14 +03:00
Maxim Kurnikov
e95b40ef52 stability fixes 2019-08-24 17:04:50 +03:00
Maxim Kurnikov
c91a6d1d5b replace None annotations with Optional[] around 2019-08-24 16:35:07 +03:00
Maxim Kurnikov
d7e8222163 Fix related fields inheritance from abstract models (#138) 2019-08-24 02:35:55 +03:00
Maxim Kurnikov
09767210ec Return corresponding descriptors for some fields in class access (#137)
* return corresponding descriptors for some related fields in class access

* return corresponding descriptors for file fields in class access

* fix tests
2019-08-23 04:03:03 +03:00
Maxim Kurnikov
656105bab2 make first() an Optional, allow to specify QuerySet with one parameter (#136) 2019-08-23 03:31:07 +03:00
Nikita Sobolev
ff7bf33e9c Fixes #127, adds urls.pyi for several contrib apps (#129) 2019-08-16 15:45:17 +03:00
Nikita Sobolev
d94b7b0c6a Fixes collectstatic storage type, closes #130 (#131) 2019-08-16 15:45:07 +03:00
Swen Kooij
7bf1664307 Add properties to runserver.Command (#135) 2019-08-16 15:44:49 +03:00
sobolevn
0545c2d3ea Removes .editorconfig, refs #132 2019-08-13 15:06:13 +03:00
sobolevn
825931da9f Fixes yaml spacing, refs #132 2019-08-13 15:05:33 +03:00
sobolevn
737fd239b6 Fixes .editorconfig, refs #132 2019-08-13 15:04:02 +03:00
Nikita Sobolev
7f476057b0 Refactors bad default values, now using Ellipsis (#132)
* Refactors bad default values, now using Ellipsis

* Blacked
2019-08-13 15:01:15 +03:00
Nikita Sobolev
d31512854a Merge pull request #124 from K0Te/fix-email-annotations
Fix EmailMessage.attachements parameter annotation.
2019-08-12 18:46:10 +03:00
Nikita Sobolev
552de422dc Merge pull request #126 from rik/lazy-translation
Improve lazy translation functions
2019-08-12 18:45:15 +03:00
Anthony Ricaud
a9978cc021 Improve lazy translation functions
The lazy versions have the same signature as the non-lazy versions
2019-08-09 12:37:17 +01:00
Oleg Nykolyn
bb08212b20 Fix EmailMessage.attachements parameter annotation. 2019-08-01 22:02:18 +03:00
Maxim Kurnikov
5d2efdb80b Merge pull request #119 from mkurnikov/subclass-queryset-proper-typing
Allow to subclass queryset without loss of typing
2019-07-26 22:47:02 +03:00
Maxim Kurnikov
27793ecd32 allow to subclass queryset without loss of typing 2019-07-26 22:40:37 +03:00
Maxim Kurnikov
dddcb20fe4 bump version to 1.0.2 2019-07-26 22:22:22 +03:00
Aleksander Vognild Burkow
ac40b80764 Mention solution to potential PYTHONPATH pitfall. (#115) 2019-07-26 18:48:38 +03:00
Maxim Kurnikov
6b21a0476d Remove psycopg2 from dependencies (#117)
* remove psycopg2 from direct dependencies, only add it in tests

* bump to 1.0.1

* fix mypy
2019-07-26 18:39:42 +03:00
Maxim Kurnikov
735b58e9bf values_list for related model id flat True (#113) 2019-07-25 21:33:45 +03:00
Maxim Kurnikov
b4cd9757b0 Merge pull request #109 from mkurnikov/new-semanal
New semanal support, rewrite to use Django app registry
2019-07-25 20:14:03 +03:00
Maxim Kurnikov
1b6c337aef enable mypy typechecking for plugin code 2019-07-25 20:03:10 +03:00
Maxim Kurnikov
bc42cc2fa1 add python3.6 tests typechecking 2019-07-25 19:56:37 +03:00
Maxim Kurnikov
62dac1d468 remove some asserts that could be validly triggered 2019-07-25 19:53:12 +03:00
Maxim Kurnikov
409c01eb24 allow to specify QuerySet with one parameter 2019-07-25 19:22:59 +03:00
Maxim Kurnikov
a0a2ecaf46 fix additional mypy config and auto settings 2019-07-25 19:14:36 +03:00
Maxim Kurnikov
4c21855641 fix mypy errors 2019-07-25 18:52:51 +03:00
Maxim Kurnikov
6466c57c69 update setup.py 2019-07-25 17:28:39 +03:00
Maxim Kurnikov
0bb41bc791 add notes about new manager types to README 2019-07-25 17:17:47 +03:00
Maxim Kurnikov
8894de0a04 add new config options to README 2019-07-25 17:03:37 +03:00
Maxim Kurnikov
a019fe9715 csrf middleware callable can be none 2019-07-25 15:03:10 +03:00
Maxim Kurnikov
a97d76020c enable tests typechecking using django submodule 2019-07-24 23:44:57 +03:00
Maxim Kurnikov
ae8e42dd53 lint 2019-07-24 22:56:14 +03:00
Maxim Kurnikov
64049b60b0 add missing psycopg2 dependency 2019-07-24 22:54:12 +03:00
Maxim Kurnikov
b6a5ccabdf move configuration to [mypy.plugins.django-stubs] inside mypy config file 2019-07-24 22:32:52 +03:00
Maxim Kurnikov
e6d7a570e8 fix merge artifact 2019-07-24 22:05:05 +03:00
Maxim Kurnikov
6332620443 rewrite pytest-mypy-plugin extension code to use new hook 2019-07-24 13:39:24 +03:00
Maxim Kurnikov
df021f6baa add some support for proxy models 2019-07-24 13:39:23 +03:00
Maxim Kurnikov
57796077c6 create(id=None) is valid, if id is AutoField 2019-07-24 13:38:50 +03:00
Maxim Kurnikov
46c48b504f tweak travis config to use new tests properly 2019-07-24 13:38:50 +03:00
Maxim Kurnikov
4dfa363521 lint fixes 2019-07-24 13:38:50 +03:00
Maxim Kurnikov
5b2aacddba add missing field methods 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
2c001fd8a7 cleanups 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
a0db24c764 add objects to model, trade false positive for false negative 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
39fb48b08a fix httprequest other fields 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
d7d379e1cd create dummy classes for custom_manager_of_model usecase 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
6962b42cba allow to use fields as Field objects outside Model classes 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
df77299c2f cleanups 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
b86d33c718 allow custom app label for ForeignKey 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
fa57fb0cbf request.user has type of AUTH_USER_MODEL 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
248504c25a various fixes 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
fee4aad3d0 fix OneToOneField without related_name 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
fc9843bea6 add support for _meta.get_field() typechecking 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
5bb1bc250d add get_next_by_FOO, get_previous_by_FOO for date,datetime fields 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
1721c997be add support for get_FIELD_display for choices fields 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
bba6f769b5 add django.contrib.contenttypes to all tests by default 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
07a9bcd4cb remove dataclasses dependency 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
6ece759ca0 remove runtime dependency on pytest-mypy-plugins 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
caf69ec1c9 add Django dependency 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
f2e79d3bfb add GenericForeignKey support, remove some false-positives 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
bfa77efef5 one more edge case for values() 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
4f935edd47 add reverse lookups to values(), values_list() 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
03b59b872d cleanups, fallback to Any in some corner cases 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
0e72b2e6fc more values(), values_list() cases 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
b81fbdeaa9 remove -semanal suffix 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
dc6101b569 remove old semanal plugin data 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
d53121baae add support for forms, values, values_list 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
3c3122a93f add settings support 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
7b1b1b6bfe add related managers support 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
2cb1f257eb add proper __init__, create() support 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
b11a9a85f9 new semanal wip 1 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
9c5a6be9a7 split helpers into smaller files 2019-07-24 13:38:49 +03:00
Maxim Kurnikov
a9c1bcbbc6 Merge pull request #111 from rik/has_perm
More accurate `PermissionsMixin.has_perm`
2019-07-21 19:23:18 +03:00
Anthony Ricaud
f365297baf Allow any Collection to be passed to has_perms 2019-07-21 02:09:05 +01:00
Anthony Ricaud
6859ec94b6 More accurate PermissionsMixin.has_perm
It only accepts `str` for `perm`
2019-07-19 12:42:03 +01:00
Maxim Kurnikov
335c5765c3 enable test folders: select_for_update, i18n, httpwrappers, auth_tests, extra_regress (#107) 2019-07-10 19:38:36 +03:00
Maxim Kurnikov
b397ec04a9 add utils_tests test folder to typechecking (#106) 2019-07-10 18:19:37 +03:00
Nikita Sobolev
f7db296e8b Makes localtime/localdate accept optional params (#105)
* Makes localtime/localdate accept optional params

Closes #104

* Removed None from default values
2019-07-10 15:58:10 +03:00
Maxim Kurnikov
2f6af159f7 add correct return annotation to get_storage_class (#103)
Co-Authored-By: cs-cordero <chris.s.cordero@gmail.com>
2019-07-10 14:06:09 +03:00
Maxim Kurnikov
2799646723 add missing files throughout the codebase (#102) 2019-07-09 05:18:15 +03:00
Maxim Kurnikov
d8230a4147 Add typechecking for 'file_storage', 'files' test folders (#101)
* add typechecking for 'file_storage', 'files' test folders

* fix File class annotations
2019-07-07 03:58:00 +03:00
Peter Law
861c6653fd Make SuccessMessageMixin fully compatible with FormMixin (#86)
This ensures that the order in which these mixins are included
into a derrived class does not matter and ends up more accurately
reflecting the return type of SuccessMessageMixin in the process
(its code doesn't appear to enforce that the returned response
is a redirect).

This provides a fix to a secondary aspect of
https://github.com/mkurnikov/django-stubs/issues/79.
2019-07-02 13:34:05 +03:00
Konstantin Alekseev
db7b46589f Add timezone.localdate() (#87) 2019-07-02 13:33:28 +03:00
Maxim Kurnikov
90cab6c5bf revert meta: Options annotation (#99) 2019-07-01 22:33:00 +03:00
Peter Law
25165de80f Add get_candidate_relations_to_delete (#92)
* Set a precise type for Model._meta

* Add missing 'get_candidate_relations_to_delete' function signature

Fixes https://github.com/mkurnikov/django-stubs/issues/77.
2019-07-01 18:50:01 +03:00
Peter Law
2295b14214 Allow any iterable to be passed to method_decorator (#90)
From reading the source of Django 2.1.9, this seems to be what's
allowed there.

Fixes https://github.com/mkurnikov/django-stubs/issues/78.
2019-07-01 18:49:40 +03:00
Maxim Kurnikov
a77d5b27d8 Update typecheck_tests to django 2.2 branch, remove unused ignores (#98)
* update typecheck_tests to django 2.2 branch, remove unused ignores

* lint fixes
2019-07-01 18:44:34 +03:00
Maxim Kurnikov
4e1c32f6a3 Fix mypy==0.710 errors (#97)
* error -> note for revealed type for tests

* fixes for latest mypy
2019-07-01 00:51:56 +03:00
Maxim Kurnikov
ea1294bd30 set version to 0.13.0, bump mypy to 0.710 2019-07-01 00:02:41 +03:00
Maxim Kurnikov
79d691732d do not release if uncommitted changes 2019-07-01 00:02:41 +03:00
Anton Agestam
629ba954b4 fix: remove SuccessMessageMixin.form_valid violation of Liskov substitution principle (#84) 2019-06-02 13:23:37 +03:00
Ran Benita
0e60b70ae4 A couple of small fixes (#81)
* Fix type of django.contrib.postgres.fields.JSONField(verbose_name)

* Improve type for CursorWrapper.execute(params)

Not perfect. Based on simple cases from
http://initd.org/psycopg/docs/usage.html#adaptation-of-python-values-to-sql-types
2019-05-21 21:26:45 +03:00
Ville Skyttä
dd5b98faf0 django.contrib.messages.api: use HttpRequest instead of WSGIRequest (#73)
Its error messages explicitly note that an HttpRequest is required.
https://docs.djangoproject.com/en/2.1/_modules/django/contrib/messages/api/#add_message
2019-05-21 17:23:19 +03:00
Ethan Smith
e634a5d460 Re-export names from django.core.cache.backend.base (#71) 2019-05-19 19:59:14 +03:00
aszlig
d7d7e6c66e Fix type of prefix arg in staticfiles_urlpatterns (#74)
Using a *type* of None for the prefix keyword argument is not going to
typecheck very well, so it might be a typo here because the default
value (rather than the type) is None.

Signed-off-by: aszlig <aszlig@nix.build>
2019-05-19 19:59:00 +03:00
Anthony Ricaud
b66727657d Type non-parametrised views.decorators.http (#80)
Fixes `error: Untyped decorator makes function "view" untyped`
2019-05-17 20:40:40 +03:00
Maxim Kurnikov
86642e3ddd bump version 2019-04-15 14:50:43 +03:00
Maciej Gol
952e1c3ee9 Preserve callable type in view decorators (#67) 2019-04-13 22:31:49 +03:00
342 changed files with 9704 additions and 6406 deletions

10
.editorconfig Normal file
View File

@@ -0,0 +1,10 @@
# Check http://editorconfig.org for more information
# This is the main config file for this project:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
trim_trailing_whitespace = true

35
.github/ISSUE_TEMPLATE/bug.md vendored Normal file
View File

@@ -0,0 +1,35 @@
---
name: Bug
about: Create a report of something is not working
labels: 'bug'
---
# Bug report
<!--
Hi, thanks for submitting a bug. We appreciate that.
But, we will need some information about what's wrong to help you.
-->
## What's wrong
<!--
Describe what is not working.
Please, attach a traceback.
We would also appreciate a failing test case.
That is EXTREMELY helpful!
-->
## How is that should be
<!-- Describe how it should work. -->
## System information
- OS:
- `python` version:
- `django` version:
- `mypy` version:
- `django-stubs` version:

29
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,29 @@
# I have made things!
<!--
Hi, thanks for submitting a Pull Request. We appreciate it.
Please, fill in all the required information
to make our review and merging processes easier.
Cheers!
-->
## Related issues
<!--
Mark what issues this Pull Request closes or references.
Format is:
- Closes #issue-number
- Refs #issue-number
Example. Refs #0
Documentation: https://blog.github.com/2013-05-14-closing-issues-via-pull-requests/
-->
<!--
If you have any feedback, just write it here.
It can be whatever you want!
-->

7
.gitignore vendored
View File

@@ -5,7 +5,10 @@ out/
/django /django
.idea/ .idea/
.mypy_cache/ .mypy_cache/
django-sources
build/ build/
dist/ dist/
pip-wheel-metadata/ pip-wheel-metadata/
.pytest_cache/
/.envrc
/.direnv
django-sources/

View File

@@ -4,45 +4,58 @@ dist: xenial
sudo: required sudo: required
jobs: jobs:
include: include:
- name: Run plugin test suite with python 3.8
python: 3.8
script: 'pytest'
- name: Run plugin test suite with python 3.7 - name: Run plugin test suite with python 3.7
python: 3.7 python: 3.7
script: | script: 'pytest'
set -e
pytest
- name: Run plugin test suite with python 3.6 - name: Typecheck Django 3.0 test suite with python 3.8
python: 3.8
script: |
python ./scripts/typecheck_tests.py --django_version=3.0
- name: Typecheck Django 3.0 test suite with python 3.7
python: 3.7
script: |
python ./scripts/typecheck_tests.py --django_version=3.0
- name: Typecheck Django 3.0 test suite with python 3.6
python: 3.6 python: 3.6
script: | script: |
set -e python ./scripts/typecheck_tests.py --django_version=3.0
pytest
- name: Typecheck Django test suite - name: Typecheck Django 2.2 test suite with python 3.7
python: 3.7 python: 3.7
script: 'python ./scripts/typecheck_tests.py' script: |
python ./scripts/typecheck_tests.py --django_version=2.2
- name: Mypy for plugin code
python: 3.7
script: 'mypy ./mypy_django_plugin'
- name: Lint with black - name: Lint with black
python: 3.7 python: 3.7
script: 'black --check --line-length=120 django-stubs/' script: 'black --check django-stubs/'
- name: Lint plugin code with flake8 - name: Lint plugin code with flake8
python: 3.7 python: 3.7
script: 'flake8' script: 'flake8'
- name: Lint stubs with flake8-pyi and check for unused imports
python: 3.7
script: 'flake8 --config flake8-pyi.ini'
- name: Lint plugin code with isort - name: Lint plugin code with isort
python: 3.7 python: 3.7
script: 'isort --check' script: 'isort --check --diff'
before_install: | before_install: |
# Upgrade pip, setuptools, and wheel sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y
sudo apt-get update
sudo apt-get install -y binutils libproj-dev gdal-bin
pip install -U pip setuptools wheel pip install -U pip setuptools wheel
install: | install: |
pip install -r ./dev-requirements.txt pip install -r ./dev-requirements.txt
pip install -r ./scripts/typecheck-tests-requirements.txt
#deploy:
# provider: pypi
# user: "mkurnikov"
# password:
# secure: 0E+hkaIdtpEtyL1KZeglunZ5/PKjouFfa8ljakAwoig7VNUL+2sO/bTyg38wRQl0NvzDzEHSMEt1bzg4Tq7b7Zp6nLuewG/w7mGLzqaOlTySiPEfRsg8s6uO2KrTn7g9VhlXH6UtyTXoQdMt6aE8+bt/GmEesanS57NB2mhwmylFgQwlJFu4LfIv/+aGmc4eLeGI2Qhvs9QYf7qvYlLQldgFh8mAckQEEvaBg35sf+puypZgf4nkx1k/dfG9wnFWZU8PJ41LbMw/Wj+k/9NpF8ePwiAr0fvRMErZd8nvoiWjQQjhzgrLVHhXEP5pTHh3zjDuGFMWyKuBhC6WLsG4qOQz/HvxeYvNI+jaTp15BgxtefG/pCNDUl/8GlCde7xVt7xzEcYNJSRaZPY2oofEFSd9qDnr4kqmyCXpNsaHRHvkL61bFjXUcfOsMMYvQCC6N2Jjb7S97RbnDdkOZO/lnFhVANT2rigsaXlSlWyN6f7ApxDNvu6Ehu5yrx6IjlPZJ0sI9vvY3IoS6Fik7w9E6zjNVjbmUn1D4MKFP4v5ppNASOqYcZeLd42j8rjEp0gIc3ccz9aUIT9q8VqSXSdUbqA6SVwvHXIVPxJMXj0bqWBG1iKs0cPBuzRVpRrwkENWCSWElDAewM1qFEnK0LppyoYFbqoQ8F5FG0+re7QttKQ=
# on:
# tags: true

111
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,111 @@
# How to contribute
## Tutorials
If you want to start working on this project,
you will need to get familiar with these projects:
- [Django docs](https://docs.djangoproject.com/en/dev/)
- [Typing in Python](https://inventwithpython.com/blog/2019/11/24/type-hints-for-busy-python-programmers/)
- [How to write custom mypy plugins](https://mypy.readthedocs.io/en/stable/extending_mypy.html)
- [Typechecking Django and DRF](https://sobolevn.me/2019/08/typechecking-django-and-drf) guide
- [Testing mypy stubs, plugins, and types](https://sobolevn.me/2019/08/testing-mypy-types) guide
It is also recommended to take a look at these resources:
- [Awesome Python Typing](https://github.com/typeddjango/awesome-python-typing)
## Dev documentation
TODO
## Dependencies
We use `pip` to manage the dependencies.
To install them you would need to activate your `virtualenv` and run `install` command:
```bash
pip install -r ./dev-requirements.txt
```
## Tests and linters
We use `mypy`, `pytest`, `flake8`, and `black` for quality control.
Here's [how we run our CI](https://github.com/typeddjango/django-stubs/blob/master/.travis.yml).
### Typechecking
To run typechecking use:
```bash
mypy ./mypy_django_plugin
```
### Testing
There are unit tests and type-related tests.
To run unit tests:
```bash
pytest
```
Type-related tests ensure that different Django versions do work correctly.
To run type-related tests:
```bash
python ./scripts/typecheck_tests.py --django_version=2.2
python ./scripts/typecheck_tests.py --django_version=3.0
```
Currently we only support two Django versions.
### Linting
To run auto-formatting:
```bash
isort -rc .
black django-stubs/
```
To run linting:
```bash
flake8
flake8 --config flake8-pyi.ini
```
## Submitting your code
We use [trunk based](https://trunkbaseddevelopment.com/)
development (we also sometimes call it `wemake-git-flow`).
What the point of this method?
1. We use protected `master` branch,
so the only way to push your code is via pull request
2. We use issue branches: to implement a new feature or to fix a bug
create a new branch named `issue-$TASKNUMBER`
3. Then create a pull request to `master` branch
4. We use `git tag`s to make releases, so we can track what has changed
since the latest release
So, this way we achieve an easy and scalable development process
which frees us from merging hell and long-living branches.
In this method, the latest version of the app is always in the `master` branch.
## Other help
You can contribute by spreading a word about this library.
It would also be a huge contribution to write
a short article on how you are using this project.
You can also share your best practices with us.

124
README.md
View File

@@ -1,56 +1,120 @@
<img src="http://mypy-lang.org/static/mypy_light.svg" alt="mypy logo" width="300px"/> <img src="http://mypy-lang.org/static/mypy_light.svg" alt="mypy logo" width="300px"/>
# pep484 stubs for Django framework # Typesafe Django Framework
[![Build Status](https://travis-ci.org/mkurnikov/django-stubs.svg?branch=master)](https://travis-ci.org/mkurnikov/django-stubs) [![Build Status](https://travis-ci.com/typeddjango/django-stubs.svg?branch=master)](https://travis-ci.com/typeddjango/django-stubs)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Gitter](https://badges.gitter.im/mypy-django/Lobby.svg)](https://gitter.im/mypy-django/Lobby)
This package contains type stubs and mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns. This package contains [type stubs](https://www.python.org/dev/peps/pep-0561/) and a custom mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need this project. The final goal is to be able to get precise types for most common patterns.
Supports Python 3.6/3.7, and Django 2.1.x series.
Could be run on earlier versions of Django, but expect some missing imports warnings.
## Installation ## Installation
``` ```bash
pip install django-stubs pip install django-stubs
``` ```
To make mypy aware of the plugin, you need to add See [Configuration](#configuration) section to get started.
```
[mypy]
plugins =
mypy_django_plugin.main
```
in your `mypy.ini` file.
## Configuration ## Configuration
In order to specify config file, set `MYPY_DJANGO_CONFIG` environment variable with path to the config file. Default is `./mypy_django.ini` To make `mypy` happy, you will need to add:
Config file format (.ini): ```ini
[mypy]
plugins =
mypy_django_plugin.main
[mypy.plugins.django-stubs]
django_settings_module = "myproject.settings"
``` ```
[mypy_django_plugin]
# specify settings module to use for django.conf.settings, this setting in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
# could also be specified with DJANGO_SETTINGS_MODULE environment variable
# (it also takes priority over config file)
django_settings = mysettings.local
# if True, all unknown settings in django.conf.settings will fallback to Any, Two things happeining here:
# specify it if your settings are loaded dynamically to avoid false positives
ignore_missing_settings = True
# if True, unknown attributes on Model instances won't produce errors 1. We need to explicitly list our plugin to be loaded by `mypy`
ignore_missing_model_attributes = True 2. Our plugin also requires `django` settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
## Version compatibility
We rely on different `django` and `mypy` versions:
| django-stubs | mypy version | django version | python version
| ------------ | ---- | ---- | ---- |
| 1.5.0 | 0.780 | 2.2.x \|\| 3.x | ^3.6
| 1.4.0 | 0.770 | 2.2.x \|\| 3.x | ^3.6
| 1.3.0 | 0.750 | 2.2.x \|\| 3.x | ^3.6
| 1.2.0 | 0.730 | 2.2.x | ^3.6
| 1.1.0 | 0.720 | 2.2.x | ^3.6
| 0.12.x | old semantic analyzer (<0.711), dmypy support | 2.1.x | ^3.6
## FAQ
### Is this an official Django project?
No, it is not. We are indendepent from Django at the moment.
There's a [proposal](https://github.com/django/deps/pull/65) to merge our project into the Django itself.
You show your support by linking the PR.
### Is it safe to use this in production?
Yes, it is! This project does not affect your runtime at all.
It only affects `mypy` type checking process.
But, it does not make any sense to use this project without `mypy`.
### mypy crashes when I run it with this plugin installed
Current implementation uses Django runtime to extract models information, so it will crash, if your installed apps or `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`.
In other words, if your `manage.py runserver` crashes, mypy will crash too.
You can also run `mypy` with [`--tb`](https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-show-traceback)
option to get extra information about the error.
### I cannot use QuerySet or Manager with type annotations
You can get a `TypeError: 'type' object is not subscriptable`
when you will try to use `QuerySet[MyModel]` or `Manager[MyModel]`.
This happens because Django classes do not support [`__class_getitem__`](https://www.python.org/dev/peps/pep-0560/#class-getitem) magic method.
You can use strings instead: `'QuerySet[MyModel]'` and `'Manager[MyModel]'`, this way it will work as a type for `mypy` and as a regular `str` in runtime.
Currently we [are working](https://github.com/django/django/pull/12405) on providing `__class_getitem__` to the classes where we need them.
### How can I use HttpRequest with custom user model?
You can subclass standard request like so:
```python
from django.http import HttpRequest
from my_user_app.models import MyUser
class MyRequest(HttpRequest):
user: MyUser
``` ```
And then use `MyRequest` instead of standard `HttpRequest` inside your project.
## Related projects
- [`awesome-python-typing`](https://github.com/typeddjango/awesome-python-typing) - Awesome list of all typing-related things in Python.
- [`djangorestframework-stubs`](https://github.com/typeddjango/djangorestframework-stubs) - Stubs for Django REST Framework.
- [`pytest-mypy-plugins`](https://github.com/typeddjango/pytest-mypy-plugins) - `pytest` plugin that we use for testing `mypy` stubs and plugins.
- [`wemake-django-template`](https://github.com/wemake-services/wemake-django-template) - Create new typed Django projects in seconds.
## To get help ## To get help
We have Gitter here https://gitter.im/mypy-django/Lobby. We have Gitter here: <https://gitter.im/mypy-django/Lobby>
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter. If you think you have more generic typing issue, please refer to <https://github.com/python/mypy> and their Gitter.

View File

@@ -1,5 +1,8 @@
black black
pytest-mypy-plugins pytest-mypy-plugins==1.3.0
flake8 psycopg2
isort==4.3.4 flake8==3.7.9
flake8-pyi==19.3.0
isort==4.3.21
gitpython==3.1.0
-e . -e .

View File

@@ -1,5 +1,6 @@
from typing import Any, Iterator, Type, Optional, Dict from typing import Any, Iterator, Type, Optional, Dict
from django.apps.registry import Apps
from django.db.models.base import Model from django.db.models.base import Model
MODELS_MODULE_NAME: str MODELS_MODULE_NAME: str
@@ -7,11 +8,11 @@ MODELS_MODULE_NAME: str
class AppConfig: class AppConfig:
name: str = ... name: str = ...
module: Optional[Any] = ... module: Optional[Any] = ...
apps: None = ... apps: Optional[Apps] = ...
label: str = ... label: str = ...
verbose_name: str = ... verbose_name: str = ...
path: str = ... path: str = ...
models_module: None = ... models_module: Optional[str] = ...
models: Dict[str, Type[Model]] = ... models: Dict[str, Type[Model]] = ...
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ... def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
@classmethod @classmethod

View File

@@ -1,36 +1,37 @@
import collections import threading
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
from django.db.migrations.state import AppConfigStub
from django.db.models.base import Model from django.db.models.base import Model
from .config import AppConfig from .config import AppConfig
class Apps: class Apps:
all_models: collections.defaultdict = ... all_models: Dict[str, Dict[str, Type[Model]]] = ...
app_configs: collections.OrderedDict = ... app_configs: Dict[str, AppConfig] = ...
stored_app_configs: List[Any] = ... stored_app_configs: List[Any] = ...
apps_ready: bool = ... apps_ready: bool = ...
ready_event: threading.Event = ...
loading: bool = ... loading: bool = ...
_pending_operations: DefaultDict[Tuple[str, str], List] _pending_operations: Dict[Tuple[str, str], List]
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
models_ready: bool = ... models_ready: bool = ...
ready: bool = ... ready: bool = ...
def populate(self, installed_apps: Union[List[AppConfigStub], List[str], Tuple] = ...) -> None: ... def __init__(self, installed_apps: Optional[Iterable[Union[AppConfig, str]]] = ...) -> None: ...
def populate(self, installed_apps: Iterable[Union[AppConfig, str]] = ...) -> None: ...
def check_apps_ready(self) -> None: ... def check_apps_ready(self) -> None: ...
def check_models_ready(self) -> None: ... def check_models_ready(self) -> None: ...
def get_app_configs(self) -> Iterable[AppConfig]: ... def get_app_configs(self) -> Iterable[AppConfig]: ...
def get_app_config(self, app_label: str) -> AppConfig: ... def get_app_config(self, app_label: str) -> AppConfig: ...
# it's not possible to support it in plugin properly now
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Model]]: ... def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Model]]: ...
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Model]: ... def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ...
def register_model(self, app_label: str, model: Type[Model]) -> None: ... def register_model(self, app_label: str, model: Type[Model]) -> None: ...
def is_installed(self, app_name: str) -> bool: ... def is_installed(self, app_name: str) -> bool: ...
def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ... def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ...
def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ... def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ...
def get_swappable_settings_name(self, to_string: str) -> Optional[str]: ... def get_swappable_settings_name(self, to_string: str) -> Optional[str]: ...
def set_available_apps(self, available: List[str]) -> None: ... def set_available_apps(self, available: Iterable[str]) -> None: ...
def unset_available_apps(self) -> None: ... def unset_available_apps(self) -> None: ...
def set_installed_apps(self, installed: Union[List[str], Tuple[str]]) -> None: ... def set_installed_apps(self, installed: Iterable[str]) -> None: ...
def unset_installed_apps(self) -> None: ... def unset_installed_apps(self) -> None: ...
def clear_cache(self) -> None: ... def clear_cache(self) -> None: ...
def lazy_model_operation(self, function: Callable, *model_keys: Any) -> None: ... def lazy_model_operation(self, function: Callable, *model_keys: Any) -> None: ...

View File

@@ -6,6 +6,8 @@ from django.utils.functional import LazyObject
from . import global_settings from . import global_settings
ENVIRONMENT_VARIABLE: str = ... ENVIRONMENT_VARIABLE: str = ...
DEFAULT_CONTENT_TYPE_DEPRECATED_MSG: str = ...
FILE_CHARSET_DEPRECATED_MSG: str = ...
# required for plugin to be able to distinguish this specific instance of LazySettings from others # required for plugin to be able to distinguish this specific instance of LazySettings from others
class _DjangoConfLazyObject(LazyObject): class _DjangoConfLazyObject(LazyObject):
@@ -22,3 +24,6 @@ class Settings:
def is_overridden(self, setting: str) -> bool: ... def is_overridden(self, setting: str) -> bool: ...
class UserSettingsHolder: ... class UserSettingsHolder: ...
class SettingsReference(str):
def __init__(self, value: str, setting_name: str) -> None: ...

View File

@@ -345,7 +345,7 @@ SESSION_COOKIE_PATH = "/"
SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_HTTPONLY = True
# Whether to set the flag restricting cookie leaks on cross-site requests. # Whether to set the flag restricting cookie leaks on cross-site requests.
# This can be 'Lax', 'Strict', or None to disable the flag. # This can be 'Lax', 'Strict', or None to disable the flag.
SESSION_COOKIE_SAMESITE = "Lax" SESSION_COOKIE_SAMESITE: Optional[str] = ...
# Whether to save the session data on every request. # Whether to save the session data on every request.
SESSION_SAVE_EVERY_REQUEST = False SESSION_SAVE_EVERY_REQUEST = False
# Whether a user's session cookie expires when the Web browser is closed. # Whether a user's session cookie expires when the Web browser is closed.
@@ -413,7 +413,7 @@ CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_PATH = "/" CSRF_COOKIE_PATH = "/"
CSRF_COOKIE_SECURE = False CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_SAMESITE = "Lax" CSRF_COOKIE_SAMESITE: Optional[str] = ...
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN" CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
CSRF_TRUSTED_ORIGINS: List[str] = ... CSRF_TRUSTED_ORIGINS: List[str] = ...
CSRF_USE_SESSIONS = False CSRF_USE_SESSIONS = False

View File

@@ -0,0 +1,3 @@
from typing import Dict, Any
LANG_INFO: Dict[str, Any] = ...

View File

@@ -5,10 +5,10 @@ from django.http.response import HttpResponse, HttpResponseBase
from django.urls import URLResolver, URLPattern from django.urls import URLResolver, URLPattern
handler400: Callable[..., HttpResponse] = ... handler400: Union[str, Callable[..., HttpResponse]] = ...
handler403: Callable[..., HttpResponse] = ... handler403: Union[str, Callable[..., HttpResponse]] = ...
handler404: Callable[..., HttpResponse] = ... handler404: Union[str, Callable[..., HttpResponse]] = ...
handler500: Callable[..., HttpResponse] = ... handler500: Union[str, Callable[..., HttpResponse]] = ...
IncludedURLConf = Tuple[List[URLResolver], Optional[str], Optional[str]] IncludedURLConf = Tuple[List[URLResolver], Optional[str], Optional[str]]

View File

@@ -1,11 +1,13 @@
from typing import Any, List, Union from typing import Any, List, Union, Iterable, Optional
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin from django.contrib.admin.options import BaseModelAdmin
from django.core.checks.messages import Error from django.core.checks.messages import Error
from django.apps.config import AppConfig
_CheckError = Union[str, Error] _CheckError = Union[str, Error]
def check_admin_app(app_configs: None, **kwargs: Any) -> List[_CheckError]: ... def check_admin_app(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[_CheckError]: ...
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ... def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
class BaseModelAdminChecks: class BaseModelAdminChecks:

View File

@@ -1,3 +1,5 @@
from typing import Any, Callable, Optional from typing import Any, Callable, Optional, Type
def register(*models: Any, site: Optional[Any] = ...) -> Callable: ... from django.db.models.base import Model
def register(*models: Type[Model], site: Optional[Any] = ...) -> Callable: ...

View File

@@ -24,7 +24,7 @@ class SimpleListFilter(ListFilter):
parameter_name: Any = ... parameter_name: Any = ...
lookup_choices: Any = ... lookup_choices: Any = ...
def value(self) -> Optional[str]: ... def value(self) -> Optional[str]: ...
def lookups(self, request: Any, model_admin: Any) -> None: ... def lookups(self, request: Any, model_admin: Any) -> List[Tuple[Any, str]]: ...
class FieldListFilter(ListFilter): class FieldListFilter(ListFilter):
field: Field = ... field: Field = ...

View File

@@ -1,7 +1,7 @@
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Iterable
from django.contrib.auth.forms import AdminPasswordChangeForm
from django.forms.boundfield import BoundField from django.forms.boundfield import BoundField
from django.forms.forms import BaseForm
from django.forms.utils import ErrorDict from django.forms.utils import ErrorDict
from django.forms.widgets import Media, Widget from django.forms.widgets import Media, Widget
from django.utils.safestring import SafeText from django.utils.safestring import SafeText
@@ -23,10 +23,10 @@ class AdminForm:
readonly_fields: Any = ... readonly_fields: Any = ...
def __init__( def __init__(
self, self,
form: AdminPasswordChangeForm, form: BaseForm,
fieldsets: List[Tuple[None, Dict[str, List[str]]]], fieldsets: List[Tuple[None, Dict[str, List[str]]]],
prepopulated_fields: Dict[Any, Any], prepopulated_fields: Dict[Any, Any],
readonly_fields: Any = ..., readonly_fields: Optional[Iterable[Any]] = ...,
model_admin: Any = ..., model_admin: Any = ...,
) -> None: ... ) -> None: ...
def __iter__(self) -> Iterator[Fieldset]: ... def __iter__(self) -> Iterator[Fieldset]: ...
@@ -47,7 +47,7 @@ class Fieldset:
self, self,
form: Any, form: Any,
name: Optional[Any] = ..., name: Optional[Any] = ...,
readonly_fields: Any = ..., readonly_fields: Optional[Iterable[Any]] = ...,
fields: Any = ..., fields: Any = ...,
classes: Any = ..., classes: Any = ...,
description: Optional[Any] = ..., description: Optional[Any] = ...,
@@ -64,7 +64,7 @@ class Fieldline:
model_admin: Any = ... model_admin: Any = ...
readonly_fields: Any = ... readonly_fields: Any = ...
def __init__( def __init__(
self, form: Any, field: Any, readonly_fields: Optional[Any] = ..., model_admin: Optional[Any] = ... self, form: Any, field: Any, readonly_fields: Optional[Iterable[Any]] = ..., model_admin: Optional[Any] = ...
) -> None: ... ) -> None: ...
def __iter__(self) -> Iterator[Union[AdminField, AdminReadonlyField]]: ... def __iter__(self) -> Iterator[Union[AdminField, AdminReadonlyField]]: ...
def errors(self) -> SafeText: ... def errors(self) -> SafeText: ...

View File

@@ -1,5 +1,9 @@
from collections import OrderedDict from collections import OrderedDict
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union, Mapping, TypeVar
from django.forms.forms import BaseForm
from django.forms.formsets import BaseFormSet
from typing_extensions import Literal, TypedDict
from django.contrib.admin.filters import ListFilter from django.contrib.admin.filters import ListFilter
from django.contrib.admin.models import LogEntry from django.contrib.admin.models import LogEntry
@@ -26,8 +30,10 @@ from django.db.models.fields import Field
IS_POPUP_VAR: str IS_POPUP_VAR: str
TO_FIELD_VAR: str TO_FIELD_VAR: str
HORIZONTAL: Any HORIZONTAL: Literal[1] = ...
VERTICAL: Any VERTICAL: Literal[2] = ...
_Direction = Union[Literal[1], Literal[2]]
def get_content_type_for_model(obj: Union[Type[Model], Model]) -> ContentType: ... def get_content_type_for_model(obj: Union[Type[Model], Model]) -> ContentType: ...
def get_ul_class(radio_style: int) -> str: ... def get_ul_class(radio_style: int) -> str: ...
@@ -37,26 +43,39 @@ class IncorrectLookupParameters(Exception): ...
FORMFIELD_FOR_DBFIELD_DEFAULTS: Any FORMFIELD_FOR_DBFIELD_DEFAULTS: Any
csrf_protect_m: Any csrf_protect_m: Any
class _OptionalFieldOpts(TypedDict, total=False):
classes: Sequence[str]
description: str
class _FieldOpts(_OptionalFieldOpts, total=True):
fields: Sequence[Union[str, Sequence[str]]]
# Workaround for mypy issue, a Sequence type should be preferred here.
# https://github.com/python/mypy/issues/8921
# _FieldsetSpec = Sequence[Tuple[Optional[str], _FieldOpts]]
_T = TypeVar("_T")
_ListOrTuple = Union[Tuple[_T, ...], List[_T]]
_FieldsetSpec = _ListOrTuple[Tuple[Optional[str], _FieldOpts]]
class BaseModelAdmin: class BaseModelAdmin:
autocomplete_fields: Any = ... autocomplete_fields: Sequence[str] = ...
raw_id_fields: Any = ... raw_id_fields: Sequence[str] = ...
fields: Any = ... fields: Sequence[Union[str, Sequence[str]]] = ...
exclude: Any = ... exclude: Sequence[str] = ...
fieldsets: Any = ... fieldsets: _FieldsetSpec = ...
form: Any = ... form: Type[BaseForm] = ...
filter_vertical: Any = ... filter_vertical: Sequence[str] = ...
filter_horizontal: Any = ... filter_horizontal: Sequence[str] = ...
radio_fields: Any = ... radio_fields: Mapping[str, _Direction] = ...
prepopulated_fields: Any = ... prepopulated_fields: Mapping[str, Sequence[str]] = ...
formfield_overrides: Any = ... formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] = ...
readonly_fields: Any = ... readonly_fields: Sequence[Union[str, Callable[[Model], Any]]] = ...
ordering: Any = ... ordering: Sequence[str] = ...
sortable_by: Any = ... sortable_by: Sequence[str] = ...
view_on_site: bool = ... view_on_site: bool = ...
show_full_result_count: bool = ... show_full_result_count: bool = ...
checks_class: Any = ... checks_class: Any = ...
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ... def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
def __init__(self) -> None: ...
def formfield_for_dbfield( def formfield_for_dbfield(
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
) -> Optional[Field]: ... ) -> Optional[Field]: ...
@@ -87,15 +106,14 @@ class BaseModelAdmin:
def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ... def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ...
def lookup_allowed(self, lookup: str, value: str) -> bool: ... def lookup_allowed(self, lookup: str, value: str) -> bool: ...
def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ... def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ...
def has_add_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ... def has_add_permission(self, request: HttpRequest) -> bool: ...
def has_change_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ... def has_change_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
def has_delete_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ... def has_delete_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
def has_view_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ... def has_view_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
def has_module_permission(self, request: HttpRequest) -> bool: ... def has_module_permission(self, request: HttpRequest) -> bool: ...
class ModelAdmin(BaseModelAdmin): class ModelAdmin(BaseModelAdmin):
formfield_overrides: Any list_display: Sequence[Union[str, Callable[[Model], Any]]] = ...
list_display: Sequence[Union[str, Callable]] = ...
list_display_links: Optional[Sequence[Union[str, Callable]]] = ... list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ... list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
list_select_related: Union[bool, Sequence[str]] = ... list_select_related: Union[bool, Sequence[str]] = ...
@@ -103,26 +121,25 @@ class ModelAdmin(BaseModelAdmin):
list_max_show_all: int = ... list_max_show_all: int = ...
list_editable: Sequence[str] = ... list_editable: Sequence[str] = ...
search_fields: Sequence[str] = ... search_fields: Sequence[str] = ...
date_hierarchy: Optional[Any] = ... date_hierarchy: Optional[str] = ...
save_as: bool = ... save_as: bool = ...
save_as_continue: bool = ... save_as_continue: bool = ...
save_on_top: bool = ... save_on_top: bool = ...
paginator: Any = ... paginator: Type = ...
preserve_filters: bool = ... preserve_filters: bool = ...
inlines: Sequence[Type[InlineModelAdmin]] = ... inlines: Sequence[Type[InlineModelAdmin]] = ...
add_form_template: Any = ... add_form_template: str = ...
change_form_template: Any = ... change_form_template: str = ...
change_list_template: Any = ... change_list_template: str = ...
delete_confirmation_template: Any = ... delete_confirmation_template: str = ...
delete_selected_confirmation_template: Any = ... delete_selected_confirmation_template: str = ...
object_history_template: Any = ... object_history_template: str = ...
popup_response_template: Any = ... popup_response_template: str = ...
actions: Any = ... actions: Sequence[Callable[[ModelAdmin, HttpRequest, QuerySet], None]] = ...
action_form: Any = ... action_form: Any = ...
actions_on_top: bool = ... actions_on_top: bool = ...
actions_on_bottom: bool = ... actions_on_bottom: bool = ...
actions_selection_counter: bool = ... actions_selection_counter: bool = ...
checks_class: Any = ...
model: Type[Model] = ... model: Type[Model] = ...
opts: Options = ... opts: Options = ...
admin_site: AdminSite = ... admin_site: AdminSite = ...
@@ -230,9 +247,9 @@ class ModelAdmin(BaseModelAdmin):
def history_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ... def history_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ...
class InlineModelAdmin(BaseModelAdmin): class InlineModelAdmin(BaseModelAdmin):
model: Any = ... model: Type[Model] = ...
fk_name: Any = ... fk_name: str = ...
formset: Any = ... formset: BaseFormSet = ...
extra: int = ... extra: int = ...
min_num: Optional[int] = ... min_num: Optional[int] = ...
max_num: Optional[int] = ... max_num: Optional[int] = ...
@@ -241,8 +258,8 @@ class InlineModelAdmin(BaseModelAdmin):
verbose_name_plural: Optional[str] = ... verbose_name_plural: Optional[str] = ...
can_delete: bool = ... can_delete: bool = ...
show_change_link: bool = ... show_change_link: bool = ...
classes: Any = ... classes: Optional[Sequence[str]] = ...
admin_site: Any = ... admin_site: AdminSite = ...
parent_model: Any = ... parent_model: Any = ...
opts: Any = ... opts: Any = ...
has_registered_model: Any = ... has_registered_model: Any = ...

View File

@@ -1,13 +1,15 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
from django.contrib.admin.options import ModelAdmin from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model from django.db.models.base import Model
from django.http.response import HttpResponse from django.http.response import HttpResponse
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.urls.resolvers import URLPattern, URLResolver from django.urls.resolvers import URLResolver
from django.utils.functional import LazyObject from django.utils.functional import LazyObject
from django.apps.config import AppConfig
all_sites: Any all_sites: Any
class AlreadyRegistered(Exception): ... class AlreadyRegistered(Exception): ...
@@ -28,16 +30,16 @@ class AdminSite:
name: str = ... name: str = ...
_registry: Dict[Type[Model], ModelAdmin] _registry: Dict[Type[Model], ModelAdmin]
def __init__(self, name: str = ...) -> None: ... def __init__(self, name: str = ...) -> None: ...
def check(self, app_configs: None) -> List[Any]: ... def check(self, app_configs: Optional[Iterable[AppConfig]]) -> List[Any]: ...
def register( def register(
self, self,
model_or_iterable: Union[List[Type[Model]], Tuple[Type[Model]], Type[Model]], model_or_iterable: Union[Type[Model], Iterable[Type[Model]]],
admin_class: Optional[Type[ModelAdmin]] = ..., admin_class: Optional[Type[ModelAdmin]] = ...,
**options: Any **options: Any
) -> None: ... ) -> None: ...
def unregister(self, model_or_iterable: Type[Model]) -> None: ... def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ...
def is_registered(self, model: Type[Model]) -> bool: ... def is_registered(self, model: Type[Model]) -> bool: ...
def add_action(self, action: Callable, name: None = ...) -> None: ... def add_action(self, action: Callable, name: Optional[str] = ...) -> None: ...
def disable_action(self, name: str) -> None: ... def disable_action(self, name: str) -> None: ...
def get_action(self, name: str) -> Callable: ... def get_action(self, name: str) -> Callable: ...
@property @property
@@ -52,14 +54,21 @@ class AdminSite:
@property @property
def urls(self) -> Tuple[List[URLResolver], str, str]: ... def urls(self) -> Tuple[List[URLResolver], str, str]: ...
def each_context(self, request: Any): ... def each_context(self, request: Any): ...
def password_change(self, request: WSGIRequest, extra_context: Dict[str, str] = ...) -> TemplateResponse: ... def password_change(
def password_change_done(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ... self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def password_change_done(
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[Any, Any]] = ...) -> HttpResponse: ... def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[Any, Any]] = ...) -> HttpResponse: ...
def logout(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ... def logout(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def login(self, request: WSGIRequest, extra_context: None = ...) -> HttpResponse: ... def login(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
def _build_app_dict(self, request: WSGIRequest, label: Optional[str] = ...) -> Dict[str, Any]: ...
def get_app_list(self, request: WSGIRequest) -> List[Any]: ... def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, str]] = ...) -> TemplateResponse: ... def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
def app_index(self, request: WSGIRequest, app_label: str, extra_context: None = ...) -> TemplateResponse: ... def app_index(
self, request: WSGIRequest, app_label: str, extra_context: Optional[Dict[str, Any]] = ...
) -> TemplateResponse: ...
class DefaultAdminSite(LazyObject): ... class DefaultAdminSite(LazyObject): ...

View File

@@ -27,7 +27,7 @@ class ResultList(list):
def results(cl: ChangeList) -> Iterator[ResultList]: ... def results(cl: ChangeList) -> Iterator[ResultList]: ...
def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ... def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ...
def result_list( def result_list(
cl: ChangeList cl: ChangeList,
) -> Dict[ ) -> Dict[
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int] str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
]: ... ]: ...

View File

@@ -1,7 +1,6 @@
from typing import Any, Optional from typing import Any
from django.contrib.admin.helpers import InlineAdminForm from django.contrib.admin.helpers import InlineAdminForm
from django.contrib.admin.templatetags.base import InclusionAdminNode
from django.template.base import Parser, Token from django.template.base import Parser, Token
from django.template.context import Context, RequestContext from django.template.context import Context, RequestContext

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional from typing import Any
register: Any register: Any

View File

@@ -0,0 +1,23 @@
from typing import Any, Callable
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.test.selenium import SeleniumTestCase
from django.utils.deprecation import MiddlewareMixin
class CSPMiddleware(MiddlewareMixin): ...
class AdminSeleniumTestCase(SeleniumTestCase, StaticLiveServerTestCase):
def wait_until(self, callback: Callable, timeout: int = ...) -> None: ...
def wait_for_popup(self, num_windows: int = ..., timeout: int = ...) -> None: ...
def wait_for(self, css_selector: str, timeout: int = ...) -> None: ...
def wait_for_text(self, css_selector: str, text: str, timeout: int = ...) -> None: ...
def wait_for_value(self, css_selector: str, text: str, timeout: int = ...) -> None: ...
def wait_until_visible(self, css_selector: str, timeout: int = ...) -> None: ...
def wait_until_invisible(self, css_selector: str, timeout: int = ...) -> None: ...
def wait_page_loaded(self) -> None: ...
def admin_login(self, username: str, password: str, login_url: str = ...) -> None: ...
def get_css_value(self, selector: str, attribute: str) -> Any: ...
def get_select_option(self, selector: str, value: Any) -> Any: ...
def assertSelectOptions(self, selector: str, values: Any) -> None: ...
def assertSelectedOptions(self, selector: str, values: Any) -> None: ...
def has_css_class(self, selector: str, klass: str) -> bool: ...

View File

@@ -9,12 +9,10 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model from django.db.models.base import Model
from django.db.models.deletion import Collector from django.db.models.deletion import Collector
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.reverse_related import ManyToOneRel from django.db.models.fields.reverse_related import ManyToOneRel
from django.db.models.options import Options from django.db.models.options import Options
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.forms.forms import BaseForm from django.forms.forms import BaseForm
from django.utils.safestring import SafeText
from django.db.models.fields import Field, reverse_related from django.db.models.fields import Field, reverse_related
@@ -27,7 +25,7 @@ def unquote(s: str) -> str: ...
def flatten(fields: Any) -> List[Union[Callable, str]]: ... def flatten(fields: Any) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ... def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ...
def get_deleted_objects( def get_deleted_objects(
objs: QuerySet, request: WSGIRequest, admin_site: AdminSite objs: Sequence[Optional[Model]], request: WSGIRequest, admin_site: AdminSite
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ... ) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
class NestedObjects(Collector): class NestedObjects(Collector):
@@ -41,22 +39,14 @@ class NestedObjects(Collector):
model_objs: Any = ... model_objs: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def add_edge(self, source: Optional[Model], target: Model) -> None: ... def add_edge(self, source: Optional[Model], target: Model) -> None: ...
def collect( def related_objects(self, related: ManyToOneRel, objs: Sequence[Optional[Model]]) -> QuerySet: ...
self, def nested(self, format_callback: Callable = ...) -> List[Any]: ...
objs: Union[Sequence[Optional[Model]], QuerySet],
source: Optional[Type[Model]] = ...,
source_attr: Optional[str] = ...,
**kwargs: Any
) -> None: ...
def related_objects(self, related: ManyToOneRel, objs: List[Model]) -> QuerySet: ...
def nested(self, format_callback: Callable = ...) -> Union[List[SafeText], List[int]]: ...
def can_fast_delete(self, *args: Any, **kwargs: Any) -> bool: ...
def model_format_dict(obj: Any): ... def model_format_dict(obj: Any): ...
def model_ngettext(obj: Union[Options, QuerySet], n: Optional[int] = ...) -> str: ... def model_ngettext(obj: Union[Options, QuerySet], n: Optional[int] = ...) -> str: ...
def lookup_field( def lookup_field(
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ... name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
) -> Tuple[Optional[Field], Callable, Callable]: ... ) -> Tuple[Optional[Field], Any, Any]: ...
def label_for_field( def label_for_field(
name: Union[Callable, str], name: Union[Callable, str],
model: Type[Model], model: Type[Model],
@@ -65,16 +55,14 @@ def label_for_field(
form: Optional[BaseForm] = ..., form: Optional[BaseForm] = ...,
) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ... ) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ...
def help_text_for_field(name: str, model: Type[Model]) -> str: ... def help_text_for_field(name: str, model: Type[Model]) -> str: ...
def display_for_field( def display_for_field(value: Any, field: Field, empty_value_display: str) -> str: ...
value: Any, field: Union[Field, reverse_related.OneToOneRel], empty_value_display: str
) -> str: ...
def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ... def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ...
class NotRelationField(Exception): ... class NotRelationField(Exception): ...
def get_model_from_relation(field: Union[Field, reverse_related.ForeignObjectRel]) -> Type[Model]: ... def get_model_from_relation(field: Union[Field, reverse_related.ForeignObjectRel]) -> Type[Model]: ...
def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ... def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ...
def get_fields_from_path(model: Type[Model], path: str) -> List[Union[Field, FieldCacheMixin]]: ... def get_fields_from_path(model: Type[Model], path: str) -> List[Field]: ...
def construct_change_message( def construct_change_message(
form: AdminPasswordChangeForm, formsets: None, add: bool form: AdminPasswordChangeForm, formsets: None, add: bool
) -> List[Dict[str, Dict[str, List[str]]]]: ... ) -> List[Dict[str, Dict[str, List[str]]]]: ...

View File

@@ -1,5 +1,7 @@
from typing import Any, Callable, Optional from typing import Callable, TypeVar, overload
def staff_member_required( _C = TypeVar("_C", bound=Callable)
view_func: Optional[Callable] = ..., redirect_field_name: str = ..., login_url: str = ... @overload
) -> Callable: ... def staff_member_required(view_func: _C = ..., redirect_field_name: str = ..., login_url: str = ...) -> _C: ...
@overload
def staff_member_required(view_func: None = ..., redirect_field_name: str = ..., login_url: str = ...) -> Callable: ...

View File

@@ -2,7 +2,11 @@ from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.contrib.admin.filters import ListFilter, SimpleListFilter from django.contrib.admin.filters import ListFilter, SimpleListFilter
from django.contrib.admin.options import ModelAdmin from django.contrib.admin.options import ( # noqa: F401
ModelAdmin,
IS_POPUP_VAR as IS_POPUP_VAR,
TO_FIELD_VAR as TO_FIELD_VAR,
)
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model from django.db.models.base import Model
from django.db.models.expressions import Combinable, CombinedExpression, OrderBy from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
@@ -77,9 +81,7 @@ class ChangeList:
paginator: Any = ... paginator: Any = ...
def get_results(self, request: WSGIRequest) -> None: ... def get_results(self, request: WSGIRequest) -> None: ...
def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[CombinedExpression, str]]: ... def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[CombinedExpression, str]]: ...
def get_ordering( def get_ordering(self, request: WSGIRequest, queryset: QuerySet) -> List[Union[OrderBy, Combinable, str]]: ...
self, request: WSGIRequest, queryset: QuerySet
) -> Union[List[Union[Combinable, str]], List[Union[OrderBy, str]]]: ...
def get_ordering_field_columns(self) -> OrderedDict: ... def get_ordering_field_columns(self) -> OrderedDict: ...
def get_queryset(self, request: WSGIRequest) -> QuerySet: ... def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
def apply_select_related(self, qs: QuerySet) -> QuerySet: ... def apply_select_related(self, qs: QuerySet) -> QuerySet: ...

View File

@@ -1,10 +1,10 @@
from typing import Any, Dict, List, Optional, Set, Tuple, Union from typing import Any, Dict, Optional, Tuple, Union
from uuid import UUID from uuid import UUID
from django.contrib.admin.sites import AdminSite from django.contrib.admin.sites import AdminSite
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel
from django.forms.models import ModelChoiceIterator from django.forms.models import ModelChoiceIterator
from django.forms.widgets import ChoiceWidget, Media from django.forms.widgets import Media
from django import forms from django import forms
@@ -43,7 +43,7 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): ...
class RelatedFieldWidgetWrapper(forms.Widget): class RelatedFieldWidgetWrapper(forms.Widget):
template_name: str = ... template_name: str = ...
choices: ModelChoiceIterator = ... choices: ModelChoiceIterator = ...
widget: AutocompleteSelect = ... widget: forms.Widget = ...
rel: ManyToOneRel = ... rel: ManyToOneRel = ...
can_add_related: bool = ... can_add_related: bool = ...
can_change_related: bool = ... can_change_related: bool = ...
@@ -52,7 +52,7 @@ class RelatedFieldWidgetWrapper(forms.Widget):
admin_site: AdminSite = ... admin_site: AdminSite = ...
def __init__( def __init__(
self, self,
widget: ChoiceWidget, widget: forms.Widget,
rel: ForeignObjectRel, rel: ForeignObjectRel,
admin_site: AdminSite, admin_site: AdminSite,
can_add_related: Optional[bool] = ..., can_add_related: Optional[bool] = ...,
@@ -74,6 +74,9 @@ class AdminIntegerFieldWidget(forms.NumberInput):
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ... class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ...
class AdminUUIDInputWidget(forms.TextInput):
def __init__(self, attrs: Optional[Dict[str, str]] = ...) -> None: ...
SELECT2_TRANSLATIONS: Any SELECT2_TRANSLATIONS: Any
class AutocompleteMixin: class AutocompleteMixin:

View File

@@ -0,0 +1,3 @@
from typing import Any, List
urlpatterns: List[Any] = ...

View File

@@ -3,46 +3,17 @@ from typing import Any, Optional, Union
from django.db.models.fields import Field from django.db.models.fields import Field
from django.views.generic import TemplateView from django.views.generic import TemplateView
from .utils import get_view_name
MODEL_METHODS_EXCLUDE: Any MODEL_METHODS_EXCLUDE: Any
class BaseAdminDocsView(TemplateView): class BaseAdminDocsView(TemplateView): ...
template_name: str = ... class BookmarkletsView(BaseAdminDocsView): ...
def dispatch(self, request: Any, *args: Any, **kwargs: Any): ... class TemplateTagIndexView(BaseAdminDocsView): ...
def get_context_data(self, **kwargs: Any): ... class TemplateFilterIndexView(BaseAdminDocsView): ...
class ViewIndexView(BaseAdminDocsView): ...
class BookmarkletsView(BaseAdminDocsView): class ViewDetailView(BaseAdminDocsView): ...
template_name: str = ... class ModelIndexView(BaseAdminDocsView): ...
def get_context_data(self, **kwargs: Any): ... class ModelDetailView(BaseAdminDocsView): ...
class TemplateDetailView(BaseAdminDocsView): ...
class TemplateTagIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class TemplateFilterIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ViewIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ViewDetailView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ModelIndexView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class ModelDetailView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
class TemplateDetailView(BaseAdminDocsView):
template_name: str = ...
def get_context_data(self, **kwargs: Any): ...
def get_return_data_type(func_name: Any): ... def get_return_data_type(func_name: Any): ...
def get_readable_field_data_type(field: Union[Field, str]) -> str: ... def get_readable_field_data_type(field: Union[Field, str]) -> str: ...

View File

@@ -1,23 +1,34 @@
from typing import Any, Optional, Set, Union from typing import Any, Optional, Set, Union
from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AnonymousUser, User from django.contrib.auth.models import AnonymousUser, User, Permission
from django.db.models.base import Model
_AnyUser = Union[Model, AnonymousUser]
UserModel: Any UserModel: Any
class ModelBackend: class BaseBackend:
def authenticate( def authenticate(
self, request: Any, username: Optional[Union[int, str]] = ..., password: Optional[str] = ..., **kwargs: Any self, request: Any, username: Optional[str] = ..., password: Optional[str] = ..., **kwargs: Any
) -> Optional[AbstractBaseUser]: ... ) -> Optional[AbstractBaseUser]: ...
def user_can_authenticate(self, user: Optional[AbstractBaseUser]) -> bool: ... def get_user(self, user_id: int) -> Optional[AbstractBaseUser]: ...
def get_user_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ... def get_user_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
def get_group_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ... def get_group_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
def get_all_permissions(self, user_obj: AbstractBaseUser, obj: Optional[str] = ...) -> Set[str]: ... def get_all_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
def has_perm( def has_perm(self, user_obj: _AnyUser, perm: str, obj: Optional[Model] = ...) -> bool: ...
self, user_obj: Union[AbstractBaseUser, AnonymousUser], perm: str, obj: Optional[str] = ...
) -> bool: ... class ModelBackend(BaseBackend):
def has_module_perms(self, user_obj: Union[AbstractBaseUser, AnonymousUser], app_label: str) -> bool: ... def has_module_perms(self, user_obj: _AnyUser, app_label: str) -> bool: ...
def get_user(self, user_id: int) -> AbstractBaseUser: ... def user_can_authenticate(self, user: Optional[_AnyUser]) -> bool: ...
def with_perm(
self,
perm: Union[str, Permission],
is_active: bool = ...,
include_superusers: bool = ...,
obj: Optional[Model] = ...,
): ...
class AllowAllUsersModelBackend(ModelBackend): ... class AllowAllUsersModelBackend(ModelBackend): ...

View File

@@ -1,27 +1,34 @@
from typing import Any, Optional, Tuple, List, overload import sys
from typing import Any, Optional, Tuple, List, overload, TypeVar
from django.db.models.base import Model
from django.db import models from django.db import models
class BaseUserManager(models.Manager): if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
_T = TypeVar("_T", bound=Model)
class BaseUserManager(models.Manager[_T]):
@classmethod @classmethod
def normalize_email(cls, email: Optional[str]) -> str: ... def normalize_email(cls, email: Optional[str]) -> str: ...
def make_random_password(self, length: int = ..., allowed_chars: str = ...) -> str: ... def make_random_password(self, length: int = ..., allowed_chars: str = ...) -> str: ...
def get_by_natural_key(self, username: Optional[str]) -> AbstractBaseUser: ... def get_by_natural_key(self, username: Optional[str]) -> _T: ...
class AbstractBaseUser(models.Model): class AbstractBaseUser(models.Model):
password: models.CharField = ...
last_login: Optional[models.DateTimeField] = ...
is_active: models.BooleanField = ...
REQUIRED_FIELDS: List[str] = ... REQUIRED_FIELDS: List[str] = ...
class Meta: ...
password = models.CharField(max_length=128)
last_login = models.DateTimeField(blank=True, null=True)
def get_username(self) -> str: ... def get_username(self) -> str: ...
def clean(self) -> None: ...
def save(self, *args: Any, **kwargs: Any) -> None: ...
def natural_key(self) -> Tuple[str]: ... def natural_key(self) -> Tuple[str]: ...
@property @property
def is_anonymous(self) -> bool: ... def is_anonymous(self) -> Literal[False]: ...
@property @property
def is_authenticated(self) -> bool: ... def is_authenticated(self) -> Literal[True]: ...
def set_password(self, raw_password: Optional[str]) -> None: ... def set_password(self, raw_password: Optional[str]) -> None: ...
def check_password(self, raw_password: str) -> bool: ... def check_password(self, raw_password: str) -> bool: ...
def set_unusable_password(self) -> None: ... def set_unusable_password(self) -> None: ...

View File

@@ -1,6 +1,8 @@
from typing import Any, List from typing import Any, List, Iterable, Optional
from django.core.checks.messages import CheckMessage from django.core.checks.messages import CheckMessage
def check_user_model(app_configs: None = ..., **kwargs: Any) -> List[CheckMessage]: ... from django.apps.config import AppConfig
def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
def check_user_model(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
def check_models_permissions(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...

View File

@@ -1,13 +1,21 @@
from typing import Any, Callable, List, Optional, Set, Union from typing import Callable, List, Optional, Set, Union, TypeVar, overload
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
from django.http.response import HttpResponseBase
from django.contrib.auth.models import AbstractUser
_VIEW = TypeVar("_VIEW", bound=Callable[..., HttpResponseBase])
def user_passes_test( def user_passes_test(
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ... test_func: Callable[[AbstractUser], bool], login_url: Optional[str] = ..., redirect_field_name: str = ...
) -> Callable: ... ) -> Callable[[_VIEW], _VIEW]: ...
def login_required(
function: Optional[Callable] = ..., redirect_field_name: str = ..., login_url: Optional[str] = ... # There are two ways of calling @login_required: @with(arguments) and @bare
) -> Callable: ... @overload
def login_required(redirect_field_name: str = ..., login_url: Optional[str] = ...) -> Callable[[_VIEW], _VIEW]: ...
@overload
def login_required(function: _VIEW, redirect_field_name: str = ..., login_url: Optional[str] = ...) -> _VIEW: ...
def permission_required( def permission_required(
perm: Union[List[str], Set[str], str], login_url: None = ..., raise_exception: bool = ... perm: Union[List[str], Set[str], str], login_url: None = ..., raise_exception: bool = ...
) -> Callable: ... ) -> Callable[[_VIEW], _VIEW]: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional from typing import Any, Dict
UserModel: Any UserModel: Any

View File

@@ -23,7 +23,7 @@ class BasePasswordHasher:
memory_cost: int = ... memory_cost: int = ...
parallelism: int = ... parallelism: int = ...
digest: Any = ... digest: Any = ...
iterations: Optional[int] = ... iterations: int = ...
def salt(self) -> str: ... def salt(self) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ... def verify(self, password: str, encoded: str) -> bool: ...
def encode(self, password: str, salt: str) -> Any: ... def encode(self, password: str, salt: str) -> Any: ...

View File

@@ -1,4 +1,9 @@
import getpass as getpass # noqa: F401
from typing import Any
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
class NotRunningInTTYException(Exception): ... class NotRunningInTTYException(Exception): ...
class Command(BaseCommand): ...
class Command(BaseCommand):
stdin: Any

View File

@@ -23,6 +23,6 @@ class PermissionRequiredMixin(AccessMixin):
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
class UserPassesTestMixin(AccessMixin): class UserPassesTestMixin(AccessMixin):
def test_func(self) -> None: ... def test_func(self) -> Optional[bool]: ...
def get_test_func(self) -> Callable: ... def get_test_func(self) -> Callable: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...

View File

@@ -1,61 +1,88 @@
from typing import Any, List, Optional, Set, Tuple, Type, Union import sys
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar, Union
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db.models.base import Model
from django.db.models.manager import EmptyManager from django.db.models.manager import EmptyManager
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.db import models from django.db import models
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
_AnyUser = Union[Model, "AnonymousUser"]
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ... def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
class PermissionManager(models.Manager): class PermissionManager(models.Manager["Permission"]):
def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ... def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ...
class Permission(models.Model): class Permission(models.Model):
content_type_id: int content_type_id: int
name: models.CharField = ... objects: PermissionManager
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
codename: models.CharField = ... name = models.CharField(max_length=255)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
codename = models.CharField(max_length=100)
def natural_key(self) -> Tuple[str, str, str]: ... def natural_key(self) -> Tuple[str, str, str]: ...
class GroupManager(models.Manager): class GroupManager(models.Manager["Group"]):
def get_by_natural_key(self, name: str) -> Group: ... def get_by_natural_key(self, name: str) -> Group: ...
class Group(models.Model): class Group(models.Model):
name: models.CharField = ... objects: GroupManager
permissions: models.ManyToManyField = models.ManyToManyField(Permission)
name = models.CharField(max_length=150)
permissions = models.ManyToManyField(Permission)
def natural_key(self): ... def natural_key(self): ...
class UserManager(BaseUserManager): _T = TypeVar("_T", bound=Model)
class UserManager(BaseUserManager[_T]):
def create_user( def create_user(
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
) -> AbstractUser: ... ) -> _T: ...
def create_superuser( def create_superuser(
self, username: str, email: Optional[str], password: Optional[str], **extra_fields: Any self, username: str, email: Optional[str], password: Optional[str], **extra_fields: Any
) -> AbstractBaseUser: ... ) -> _T: ...
def with_perm(
self,
perm: Union[str, Permission],
is_active: bool = ...,
include_superusers: bool = ...,
backend: Optional[Union[Type[ModelBackend], str]] = ...,
obj: Optional[Model] = ...,
): ...
class PermissionsMixin(models.Model): class PermissionsMixin(models.Model):
is_superuser: models.BooleanField = ... is_superuser = models.BooleanField()
groups: models.ManyToManyField = models.ManyToManyField(Group) groups = models.ManyToManyField(Group)
user_permissions: models.ManyToManyField = models.ManyToManyField(Permission) user_permissions = models.ManyToManyField(Permission)
def get_group_permissions(self, obj: None = ...) -> Set[str]: ... def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def get_all_permissions(self, obj: Optional[str] = ...) -> Set[str]: ... def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def has_perm(self, perm: Union[Tuple[str, Any], str], obj: Optional[str] = ...) -> bool: ... def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def has_perms(self, perm_list: Union[List[str], Set[str], Tuple[str]], obj: None = ...) -> bool: ... def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
def has_module_perms(self, app_label: str) -> bool: ... def has_module_perms(self, app_label: str) -> bool: ...
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
username_validator: UnicodeUsernameValidator = ... username_validator: UnicodeUsernameValidator = ...
username: models.CharField = ...
first_name: models.CharField = ... username = models.CharField(max_length=150)
last_name: models.CharField = ... first_name = models.CharField(max_length=30, blank=True)
email: models.EmailField = ... last_name = models.CharField(max_length=150, blank=True)
is_staff: models.BooleanField = ... email = models.EmailField(blank=True)
date_joined: models.DateTimeField = ... is_staff = models.BooleanField()
is_active = models.BooleanField()
date_joined = models.DateTimeField()
EMAIL_FIELD: str = ... EMAIL_FIELD: str = ...
USERNAME_FIELD: str = ... USERNAME_FIELD: str = ...
def clean(self) -> None: ...
def get_full_name(self) -> str: ... def get_full_name(self) -> str: ...
def get_short_name(self) -> str: ... def get_short_name(self) -> str: ...
def email_user(self, subject: str, message: str, from_email: str = ..., **kwargs: Any) -> None: ... def email_user(self, subject: str, message: str, from_email: str = ..., **kwargs: Any) -> None: ...
@@ -77,13 +104,14 @@ class AnonymousUser:
def groups(self) -> EmptyManager: ... def groups(self) -> EmptyManager: ...
@property @property
def user_permissions(self) -> EmptyManager: ... def user_permissions(self) -> EmptyManager: ...
def get_group_permissions(self, obj: None = ...) -> Set[Any]: ... def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def get_all_permissions(self, obj: Any = ...) -> Set[str]: ... def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[Any]: ...
def has_perm(self, perm: str, obj: None = ...) -> bool: ... def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
def has_perms(self, perm_list: Union[List[str], Tuple[str]], obj: None = ...) -> bool: ... def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
def has_module_perms(self, module: str) -> bool: ... def has_module_perms(self, module: str) -> bool: ...
@property @property
def is_anonymous(self) -> bool: ... def is_anonymous(self) -> Literal[True]: ...
@property @property
def is_authenticated(self) -> bool: ... def is_authenticated(self) -> Literal[False]: ...
def get_username(self) -> str: ... def get_username(self) -> str: ...

View File

@@ -1,22 +1,20 @@
from pathlib import Path, PosixPath from pathlib import Path, PosixPath
from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union
from django.contrib.auth.base_user import AbstractBaseUser from django.db.models.base import Model
_UserModel = Model
class PasswordValidator(Protocol): class PasswordValidator(Protocol):
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...): ... def password_changed(self, password: str, user: Optional[_UserModel] = ...): ...
def get_default_password_validators() -> List[PasswordValidator]: ... def get_default_password_validators() -> List[PasswordValidator]: ...
def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ... def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ...
def validate_password( def validate_password(
password: str, password: str, user: Optional[_UserModel] = ..., password_validators: Optional[Sequence[PasswordValidator]] = ...
user: Optional[AbstractBaseUser] = ...,
password_validators: Optional[Sequence[PasswordValidator]] = ...,
) -> None: ... ) -> None: ...
def password_changed( def password_changed(
password: str, password: str, user: Optional[_UserModel] = ..., password_validators: Optional[Sequence[PasswordValidator]] = ...
user: Optional[AbstractBaseUser] = ...,
password_validators: Optional[Sequence[PasswordValidator]] = ...,
) -> None: ... ) -> None: ...
def password_validators_help_texts(password_validators: Optional[Sequence[PasswordValidator]] = ...) -> List[str]: ... def password_validators_help_texts(password_validators: Optional[Sequence[PasswordValidator]] = ...) -> List[str]: ...
@@ -25,7 +23,7 @@ password_validators_help_text_html: Any
class MinimumLengthValidator: class MinimumLengthValidator:
min_length: int = ... min_length: int = ...
def __init__(self, min_length: int = ...) -> None: ... def __init__(self, min_length: int = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ... def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
def get_help_text(self) -> str: ... def get_help_text(self) -> str: ...
class UserAttributeSimilarityValidator: class UserAttributeSimilarityValidator:
@@ -33,16 +31,16 @@ class UserAttributeSimilarityValidator:
user_attributes: Sequence[str] = ... user_attributes: Sequence[str] = ...
max_similarity: float = ... max_similarity: float = ...
def __init__(self, user_attributes: Sequence[str] = ..., max_similarity: float = ...) -> None: ... def __init__(self, user_attributes: Sequence[str] = ..., max_similarity: float = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ... def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
def get_help_text(self) -> str: ... def get_help_text(self) -> str: ...
class CommonPasswordValidator: class CommonPasswordValidator:
DEFAULT_PASSWORD_LIST_PATH: Path = ... DEFAULT_PASSWORD_LIST_PATH: Path = ...
passwords: Set[str] = ... passwords: Set[str] = ...
def __init__(self, password_list_path: Union[PosixPath, str] = ...) -> None: ... def __init__(self, password_list_path: Union[PosixPath, str] = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ... def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
def get_help_text(self) -> str: ... def get_help_text(self) -> str: ...
class NumericPasswordValidator: class NumericPasswordValidator:
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ... def validate(self, password: str, user: Optional[_UserModel] = ...) -> None: ...
def get_help_text(self) -> str: ... def get_help_text(self) -> str: ...

View File

@@ -0,0 +1,3 @@
from typing import Any, List
urlpatterns: List[Any] = ...

View File

@@ -55,6 +55,7 @@ class PasswordResetDoneView(PasswordContextMixin, TemplateView):
class PasswordResetConfirmView(PasswordContextMixin, FormView): class PasswordResetConfirmView(PasswordContextMixin, FormView):
post_reset_login: bool = ... post_reset_login: bool = ...
post_reset_login_backend: Any = ... post_reset_login_backend: Any = ...
reset_url_token: str = ...
title: Any = ... title: Any = ...
token_generator: Any = ... token_generator: Any = ...
validlink: bool = ... validlink: bool = ...

View File

@@ -1,4 +1,6 @@
from typing import Any, List, Optional from typing import Any, List, Iterable, Optional
def check_generic_foreign_keys(app_configs: None = ..., **kwargs: Any) -> List[Any]: ... from django.apps.config import AppConfig
def check_model_name_lengths(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
def check_generic_foreign_keys(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
def check_model_name_lengths(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...

View File

@@ -1,19 +1,24 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, Generic from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import Error from django.core.checks.messages import Error
from django.db.models.base import Model from django.db.models.base import Model
from django.db.models.expressions import Combinable
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.related import ForeignObject from django.db.models.fields.related import ForeignObject
from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor from django.db.models.fields.related_descriptors import ReverseManyToOneDescriptor
from django.db.models.fields.reverse_related import ForeignObjectRel from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.fields import Field, PositiveIntegerField
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.db.models.query_utils import FilteredRelation, PathInfo from django.db.models.query_utils import FilteredRelation, PathInfo
from django.db.models.sql.where import WhereNode from django.db.models.sql.where import WhereNode
from django.db.models.fields import Field, PositiveIntegerField
class GenericForeignKey(FieldCacheMixin): class GenericForeignKey(FieldCacheMixin):
# django-stubs implementation only fields
_pyi_private_set_type: Union[Any, Combinable]
_pyi_private_get_type: Any
# attributes
auto_created: bool = ... auto_created: bool = ...
concrete: bool = ... concrete: bool = ...
editable: bool = ... editable: bool = ...
@@ -44,36 +49,21 @@ class GenericForeignKey(FieldCacheMixin):
def get_prefetch_queryset( def get_prefetch_queryset(
self, instances: Union[List[Model], QuerySet], queryset: Optional[QuerySet] = ... self, instances: Union[List[Model], QuerySet], queryset: Optional[QuerySet] = ...
) -> Tuple[List[Model], Callable, Callable, bool, str, bool]: ... ) -> Tuple[List[Model], Callable, Callable, bool, str, bool]: ...
def __get__( def __get__(self, instance: Optional[Model], cls: Type[Model] = ...) -> Optional[Any]: ...
self, instance: Optional[Model], cls: Type[Model] = ... def __set__(self, instance: Model, value: Optional[Any]) -> None: ...
) -> Optional[Union[GenericForeignKey, Model]]: ...
def __set__(self, instance: Model, value: Optional[Model]) -> None: ...
class GenericRel(ForeignObjectRel): class GenericRel(ForeignObjectRel):
field: GenericRelation field: GenericRelation
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]]
model: Type[Model]
multiple: bool
on_delete: Callable
parent_link: bool
related_name: str
related_query_name: None
symmetrical: bool
def __init__( def __init__(
self, self,
field: GenericRelation, field: GenericRelation,
to: Union[Type[Model], str], to: Union[Type[Model], str],
related_name: None = ..., related_name: Optional[str] = ...,
related_query_name: Optional[str] = ..., related_query_name: Optional[str] = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ..., limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
) -> None: ... ) -> None: ...
class GenericRelation(ForeignObject): class GenericRelation(ForeignObject):
auto_created: bool = ...
many_to_many: bool = ...
many_to_one: bool = ...
one_to_many: bool = ...
one_to_one: bool = ...
rel_class: Any = ... rel_class: Any = ...
mti_inherited: bool = ... mti_inherited: bool = ...
object_id_field_name: Any = ... object_id_field_name: Any = ...
@@ -90,23 +80,16 @@ class GenericRelation(ForeignObject):
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ..., limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
**kwargs: Any **kwargs: Any
) -> None: ... ) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def resolve_related_fields(self) -> List[Tuple[PositiveIntegerField, Field]]: ... def resolve_related_fields(self) -> List[Tuple[PositiveIntegerField, Field]]: ...
def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ... def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ... def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
def value_to_string(self, obj: Model) -> str: ... def value_to_string(self, obj: Model) -> str: ...
model: Any = ...
def set_attributes_from_rel(self) -> None: ...
def get_internal_type(self) -> str: ...
def get_content_type(self) -> ContentType: ... def get_content_type(self) -> ContentType: ...
def get_extra_restriction( def get_extra_restriction(
self, where_class: Type[WhereNode], alias: Optional[str], remote_alias: str self, where_class: Type[WhereNode], alias: Optional[str], remote_alias: str
) -> WhereNode: ... ) -> WhereNode: ...
def bulk_related_objects(self, objs: List[Model], using: str = ...) -> QuerySet: ... def bulk_related_objects(self, objs: List[Model], using: str = ...) -> QuerySet: ...
class ReverseGenericManyToOneDescriptor(ReverseManyToOneDescriptor): class ReverseGenericManyToOneDescriptor(ReverseManyToOneDescriptor): ...
field: GenericRelation
rel: GenericRel
def related_manager_cls(self): ...
def create_generic_related_manager(superclass: Any, rel: Any): ... def create_generic_related_manager(superclass: Any, rel: Any): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional, Union from typing import Union
from django.http.request import HttpRequest from django.http.request import HttpRequest
from django.http.response import HttpResponseRedirect from django.http.response import HttpResponseRedirect

View File

@@ -0,0 +1,3 @@
from typing import Any, List
urlpatterns: List[Any] = ...

View File

@@ -1,5 +1,3 @@
from typing import Any, Optional
from django.contrib.flatpages.models import FlatPage from django.contrib.flatpages.models import FlatPage
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest
from django.http.response import HttpResponse from django.http.response import HttpResponse

View File

View File

View File

@@ -0,0 +1,13 @@
from django.db.models import *
from .fields import (
GeometryField as GeometryField,
LineStringField as LineStringField,
MultiLineStringField as MultiLineStringField,
MultiPointField as MultiPointField,
MultiPolygonField as MultiPolygonField,
PointField as PointField,
PolygonField as PolygonField,
GeometryCollectionField as GeometryCollectionField,
RasterField as RasterField,
)

View File

@@ -0,0 +1,91 @@
from typing import Any, Iterable, NamedTuple, Optional, TypeVar, Union, Tuple
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
_Connection = Any
# __set__ value type
_ST = TypeVar("_ST")
# __get__ return type
_GT = TypeVar("_GT")
class SRIDCacheEntry(NamedTuple):
units: Any
units_name: str
geodetic: bool
spheroid: str
def get_srid_info(srid: int, connection: _Connection) -> SRIDCacheEntry: ...
class BaseSpatialField(Field[_ST, _GT]):
def __init__(
self,
verbose_name: Optional[Union[str, bytes]] = ...,
srid: int = ...,
spatial_index: bool = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
def spheroid(self, connection: _Connection) -> str: ...
def units(self, connection: _Connection) -> Any: ...
def units_name(self, connection: _Connection) -> str: ...
def geodetic(self, connection: _Connection) -> bool: ...
class GeometryField(BaseSpatialField):
def __init__(
self,
verbose_name: Optional[Union[str, bytes]] = ...,
dim: int = ...,
geography: bool = ...,
extent: Tuple[float, float, float, float] = ...,
tolerance: float = ...,
srid: int = ...,
spatial_index: bool = ...,
name: Optional[str] = ...,
primary_key: bool = ...,
max_length: Optional[int] = ...,
unique: bool = ...,
blank: bool = ...,
null: bool = ...,
db_index: bool = ...,
default: Any = ...,
editable: bool = ...,
auto_created: bool = ...,
serialize: bool = ...,
unique_for_date: Optional[str] = ...,
unique_for_month: Optional[str] = ...,
unique_for_year: Optional[str] = ...,
choices: Optional[_FieldChoices] = ...,
help_text: str = ...,
db_column: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: Optional[_ErrorMessagesToOverride] = ...,
): ...
class PointField(GeometryField): ...
class LineStringField(GeometryField): ...
class PolygonField(GeometryField): ...
class MultiPointField(GeometryField): ...
class MultiLineStringField(GeometryField): ...
class MultiPolygonField(GeometryField): ...
class GeometryCollectionField(GeometryField): ...
class RasterField(BaseSpatialField): ...

View File

@@ -1,15 +1,14 @@
from datetime import date, datetime as datetime from datetime import date, datetime as datetime
from decimal import Decimal from typing import Any, Optional, SupportsInt, Union
from typing import Any, Optional, Union
register: Any register: Any
def ordinal(value: Optional[str]) -> Optional[str]: ... def ordinal(value: Optional[Union[str, SupportsInt]]) -> Optional[str]: ...
def intcomma(value: Optional[Union[Decimal, float, str]], use_l10n: bool = ...) -> str: ... def intcomma(value: Optional[Union[str, SupportsInt]], use_l10n: bool = ...) -> str: ...
intword_converters: Any intword_converters: Any
def intword(value: Optional[str]) -> Optional[Union[int, str]]: ... def intword(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
def apnumber(value: Optional[str]) -> Optional[Union[int, str]]: ... def apnumber(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
def naturalday(value: Optional[Union[date, str]], arg: None = ...) -> Optional[str]: ... def naturalday(value: Optional[Union[date, str]], arg: None = ...) -> Optional[str]: ...
def naturaltime(value: datetime) -> str: ... def naturaltime(value: datetime) -> str: ...

View File

@@ -1,13 +1,12 @@
from typing import Any, List, Optional, Union from typing import Any, List, Optional, Union
from django.contrib.messages.storage.base import BaseStorage from django.contrib.messages.storage.base import BaseStorage
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest from django.http.request import HttpRequest
class MessageFailure(Exception): ... class MessageFailure(Exception): ...
def add_message( def add_message(
request: Optional[WSGIRequest], request: Optional[HttpRequest],
level: int, level: int,
message: str, message: str,
extra_tags: str = ..., extra_tags: str = ...,
@@ -16,12 +15,12 @@ def add_message(
def get_messages(request: HttpRequest) -> Union[List[Any], BaseStorage]: ... def get_messages(request: HttpRequest) -> Union[List[Any], BaseStorage]: ...
def get_level(request: HttpRequest) -> int: ... def get_level(request: HttpRequest) -> int: ...
def set_level(request: HttpRequest, level: int) -> bool: ... def set_level(request: HttpRequest, level: int) -> bool: ...
def debug(request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ... def debug(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
def info(request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ... def info(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...
def success( def success(
request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ... request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
) -> None: ... ) -> None: ...
def warning( def warning(
request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ... request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...
) -> None: ... ) -> None: ...
def error(request: WSGIRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ... def error(request: HttpRequest, message: str, extra_tags: str = ..., fail_silently: Union[bool, str] = ...) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Union
from django.contrib.messages.storage.base import BaseStorage from django.contrib.messages.storage.base import BaseStorage
from django.http.request import HttpRequest from django.http.request import HttpRequest

View File

@@ -1,4 +1,4 @@
from typing import Any, List, Optional, Union from typing import Any, List, Optional
from django.http.request import HttpRequest from django.http.request import HttpRequest
from django.http.response import HttpResponseBase from django.http.response import HttpResponseBase

View File

@@ -1,3 +1,3 @@
from typing import Dict, Optional from typing import Dict
def get_level_tags() -> Dict[int, str]: ... def get_level_tags() -> Dict[int, str]: ...

View File

@@ -1,9 +1,9 @@
from typing import Any, Dict, Optional from typing import Dict
from django.forms.forms import Form from django.forms.forms import BaseForm
from django.http.response import HttpResponseRedirect from django.http.response import HttpResponse
class SuccessMessageMixin: class SuccessMessageMixin:
success_message: str = ... success_message: str = ...
def form_valid(self, form: Form) -> HttpResponseRedirect: ... def form_valid(self, form: BaseForm) -> HttpResponse: ...
def get_success_message(self, cleaned_data: Dict[str, str]) -> str: ... def get_success_message(self, cleaned_data: Dict[str, str]) -> str: ...

View File

@@ -0,0 +1,24 @@
from .general import (
ArrayAgg as ArrayAgg,
BitAnd as BitAnd,
BitOr as BitOr,
BoolAnd as BoolAnd,
BoolOr as BoolOr,
JSONBAgg as JSONBAgg,
StringAgg as StringAgg,
)
from .statistics import (
Corr as Corr,
CovarPop as CovarPop,
RegrAvgX as RegrAvgX,
RegrAvgY as RegrAvgY,
RegrCount as RegrCount,
RegrIntercept as RegrIntercept,
RegrR2 as RegrR2,
RegrSlope as RegrSlope,
RegrSXX as RegrSXX,
RegrSXY as RegrSXY,
RegrSYY as RegrSYY,
StatAggregate as StatAggregate,
)

View File

@@ -0,0 +1,11 @@
from django.db.models.aggregates import Aggregate
from .mixins import OrderableAggMixin
class ArrayAgg(OrderableAggMixin, Aggregate): ...
class BitAnd(Aggregate): ...
class BitOr(Aggregate): ...
class BoolAnd(Aggregate): ...
class BoolOr(Aggregate): ...
class JSONBAgg(Aggregate): ...
class StringAgg(OrderableAggMixin, Aggregate): ...

View File

@@ -0,0 +1 @@
class OrderableAggMixin: ...

View File

@@ -0,0 +1,14 @@
from django.db.models.aggregates import Aggregate
class StatAggregate(Aggregate): ...
class Corr(StatAggregate): ...
class CovarPop(StatAggregate): ...
class RegrAvgX(StatAggregate): ...
class RegrAvgY(StatAggregate): ...
class RegrCount(StatAggregate): ...
class RegrIntercept(StatAggregate): ...
class RegrR2(StatAggregate): ...
class RegrSlope(StatAggregate): ...
class RegrSXX(StatAggregate): ...
class RegrSXY(StatAggregate): ...
class RegrSYY(StatAggregate): ...

View File

@@ -0,0 +1,18 @@
from typing import Optional, Sequence, Tuple, Union
from django.db.models.constraints import BaseConstraint
from django.db.models.expressions import Combinable
from django.db.models.query_utils import Q
class ExclusionConstraint(BaseConstraint):
expressions: Sequence[Tuple[Union[str, Combinable], str]]
index_type: str
condition: Optional[Q]
def __init__(
self,
*,
name: str,
expressions: Sequence[Tuple[Union[str, Combinable], str]],
condition: Optional[Q] = ...,
index_type: Optional[str] = ...,
): ...

View File

@@ -4,8 +4,17 @@ from .ranges import (
RangeField as RangeField, RangeField as RangeField,
IntegerRangeField as IntegerRangeField, IntegerRangeField as IntegerRangeField,
BigIntegerRangeField as BigIntegerRangeField, BigIntegerRangeField as BigIntegerRangeField,
DecimalRangeField as DecimalRangeField,
FloatRangeField as FloatRangeField, FloatRangeField as FloatRangeField,
DateRangeField as DateRangeField, DateRangeField as DateRangeField,
DateTimeRangeField as DateTimeRangeField, DateTimeRangeField as DateTimeRangeField,
RangeOperators as RangeOperators,
RangeBoundary as RangeBoundary,
) )
from .hstore import HStoreField as HStoreField from .hstore import HStoreField as HStoreField
from .citext import (
CICharField as CICharField,
CIEmailField as CIEmailField,
CIText as CIText,
CITextField as CITextField,
)

View File

@@ -1,10 +1,11 @@
from json import JSONEncoder from json import JSONEncoder
from typing import Any, Dict, List, Optional, Tuple, Type, Union from typing import Any, Optional, Type
from django.db.models import Field from django.db.models import Field
from django.db.models.lookups import Transform
from .mixins import CheckFieldDefaultMixin from .mixins import CheckFieldDefaultMixin
class JsonAdapter(object): class JsonAdapter:
encoder: Any = ... encoder: Any = ...
def __init__(self, adapted: Any, dumps: Optional[Any] = ..., encoder: Optional[Any] = ...) -> None: ... def __init__(self, adapted: Any, dumps: Optional[Any] = ..., encoder: Optional[Any] = ...) -> None: ...
def dumps(self, obj: Any): ... def dumps(self, obj: Any): ...
@@ -15,12 +16,17 @@ class JSONField(CheckFieldDefaultMixin, Field):
default_error_messages: Any = ... default_error_messages: Any = ...
encoder: Any = ... encoder: Any = ...
def __init__( def __init__(
self, verbose_name: None = ..., name: None = ..., encoder: Optional[Type[JSONEncoder]] = ..., **kwargs: Any self,
verbose_name: Optional[str] = ...,
name: Optional[str] = ...,
encoder: Optional[Type[JSONEncoder]] = ...,
**kwargs: Any
) -> None: ... ) -> None: ...
def db_type(self, connection: Any): ...
def deconstruct(self) -> Tuple[None, str, List[Any], Dict[str, Union[Type[JSONEncoder], bool]]]: ...
def get_transform(self, name: Any): ...
def get_prep_value(self, value: Any): ...
def validate(self, value: Any, model_instance: Any) -> None: ...
def value_to_string(self, obj: Any): ... def value_to_string(self, obj: Any): ...
def formfield(self, **kwargs: Any): ...
class KeyTransform(Transform):
operator: str = ...
nested_operator: str = ...
def __init__(self, key_name: str, *args: Any, **kwargs: Any) -> None: ...
class KeyTextTransform(KeyTransform): ...

View File

@@ -18,6 +18,9 @@ class IntegerRangeField(RangeField):
class BigIntegerRangeField(RangeField): class BigIntegerRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ... def __get__(self, instance, owner) -> NumericRange: ...
class DecimalRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class FloatRangeField(RangeField): class FloatRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ... def __get__(self, instance, owner) -> NumericRange: ...
@@ -26,3 +29,20 @@ class DateTimeRangeField(RangeField):
class DateRangeField(RangeField): class DateRangeField(RangeField):
def __get__(self, instance, owner) -> DateRange: ... def __get__(self, instance, owner) -> DateRange: ...
class RangeOperators:
EQUAL: str
NOT_EQUAL: str
CONTAINS: str
CONTAINED_BY: str
OVERLAPS: str
FULLY_LT: str
FULLY_GT: str
NOT_LT: str
NOT_GT: str
ADJACENT_TO: str
class RangeBoundary(models.Expression):
lower: str
upper: str
def __init__(self, inclusive_lower: bool = ..., inclusive_upper: bool = ...): ...

View File

@@ -0,0 +1,4 @@
from django.db.models import Func
class RandomUUID(Func): ...
class TransactionNow(Func): ...

View File

@@ -0,0 +1,82 @@
from typing import Optional, Sequence
from django.db.models.query_utils import Q
from django.db.models import Index
class PostgresIndex(Index): ...
class BrinIndex(PostgresIndex):
def __init__(
self,
*,
autosummarize: Optional[bool] = ...,
pages_per_range: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class BTreeIndex(PostgresIndex):
def __init__(
self,
*,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class GinIndex(PostgresIndex):
def __init__(
self,
*,
fastupdate: Optional[bool] = ...,
gin_pending_list_limit: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class GistIndex(PostgresIndex):
def __init__(
self,
*,
buffering: Optional[bool] = ...,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class HashIndex(PostgresIndex):
def __init__(
self,
*,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...
class SpGistIndex(PostgresIndex):
def __init__(
self,
*,
fillfactor: Optional[int] = ...,
fields: Sequence[str] = ...,
name: Optional[str] = ...,
db_tablespace: Optional[str] = ...,
opclasses: Sequence[str] = ...,
condition: Optional[Q] = ...
) -> None: ...

View File

@@ -0,0 +1,18 @@
from django.db.models.lookups import Exact
from django.db.models import Lookup, Transform
from .search import SearchVectorExact
class PostgresSimpleLookup(Lookup):
operator: str
class DataContains(PostgresSimpleLookup): ...
class ContainedBy(PostgresSimpleLookup): ...
class Overlap(PostgresSimpleLookup): ...
class HasKey(PostgresSimpleLookup): ...
class HasKeys(PostgresSimpleLookup): ...
class HasAnyKeys(HasKeys): ...
class Unaccent(Transform): ...
class SearchLookup(SearchVectorExact): ...
class TrigramSimilar(PostgresSimpleLookup): ...
class JSONExact(Exact): ...

View File

@@ -0,0 +1,63 @@
from typing import Any, Dict, Optional, TypeVar, Union
from django.db.models.expressions import Combinable, CombinedExpression, Func, Value, _OutputField
from django.db.models.lookups import Lookup
from django.db.models import Field
_Expression = Union[str, Combinable, "SearchQueryCombinable"]
class SearchVectorExact(Lookup): ...
class SearchVectorField(Field): ...
class SearchQueryField(Field): ...
class SearchVectorCombinable:
ADD: str = ...
class SearchVector(SearchVectorCombinable, Func):
config: Optional[Any] = ...
def __init__(self, *expressions: _Expression, **extra: Any): ...
class CombinedSearchVector(SearchVectorCombinable, CombinedExpression):
def __init__(
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
): ...
_T = TypeVar("_T", bound="SearchQueryCombinable")
class SearchQueryCombinable:
BITAND: str = ...
BITOR: str = ...
def __or__(self: _T, other: SearchQueryCombinable) -> _T: ...
def __ror__(self: _T, other: SearchQueryCombinable) -> _T: ...
def __and__(self: _T, other: SearchQueryCombinable) -> _T: ...
def __rand__(self: _T, other: SearchQueryCombinable) -> _T: ...
class SearchQuery(SearchQueryCombinable, Value): # type: ignore
SEARCH_TYPES: Dict[str, str] = ...
def __init__(
self,
value: str,
output_field: Optional[_OutputField] = ...,
*,
config: Optional[_Expression] = ...,
invert: bool = ...,
search_type: str = ...
): ...
def __invert__(self: _T) -> _T: ...
class CombinedSearchQuery(SearchQueryCombinable, CombinedExpression): # type: ignore
def __init__(
self, lhs, connector, rhs, config: Optional[_Expression] = ..., output_field: Optional[_OutputField] = ...
) -> None: ...
class SearchRank(Func):
def __init__(
self, vector: Union[SearchVector, _Expression], query: Union[SearchQuery, _Expression], **extra: Any
) -> None: ...
class TrigramBase(Func):
def __init__(self, expression: _Expression, string, **extra: Any) -> None: ...
class TrigramSimilarity(TrigramBase): ...
class TrigramDistance(TrigramBase): ...

View File

@@ -0,0 +1,5 @@
from typing import Any, Tuple
def get_hstore_oids(connection_alias: str) -> Tuple[Any, ...]: ...
def get_citext_oids(connection_alias: str) -> Tuple[Any, ...]: ...
def register_type_handlers(connection: Any, **kwargs: Any) -> None: ...

View File

@@ -0,0 +1,17 @@
from typing import Any, Dict, Iterable, Mapping, Optional
from django.core.validators import MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator
class ArrayMaxLengthValidator(MaxLengthValidator): ...
class ArrayMinLengthValidator(MinLengthValidator): ...
class KeysValidator:
messages: Dict[str, str] = ...
strict: bool = ...
def __init__(
self, keys: Iterable[str], strict: bool = ..., messages: Optional[Mapping[str, str]] = ...
) -> None: ...
def __call__(self, value: Any) -> None: ...
class RangeMaxValueValidator(MaxValueValidator): ...
class RangeMinValueValidator(MinValueValidator): ...

View File

@@ -0,0 +1,4 @@
from django.core.exceptions import SuspiciousOperation
class InvalidSessionKey(SuspiciousOperation): ...
class SuspiciousSession(SuspiciousOperation): ...

View File

@@ -1,5 +1,5 @@
from datetime import datetime from datetime import datetime
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Optional, Union, Protocol
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.contrib.sites.requests import RequestSite from django.contrib.sites.requests import RequestSite
@@ -13,10 +13,19 @@ class SitemapNotFound(Exception): ...
def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None: ... def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None: ...
class _SupportsLen(Protocol):
def __len__(self) -> int: ...
class _SupportsCount(Protocol):
def count(self) -> int: ...
class _SupportsOrdered(Protocol):
ordered: bool = ...
class Sitemap: class Sitemap:
limit: int = ... limit: int = ...
protocol: Optional[str] = ... protocol: Optional[str] = ...
def items(self) -> List[Any]: ... def items(self) -> Union[_SupportsLen, _SupportsCount, _SupportsOrdered]: ...
def location(self, obj: Model) -> str: ... def location(self, obj: Model) -> str: ...
@property @property
def paginator(self) -> Paginator: ... def paginator(self) -> Paginator: ...

View File

@@ -1,10 +1,10 @@
from typing import Any from typing import Any
from django.apps.config import AppConfig
from django.apps.registry import Apps from django.apps.registry import Apps
from django.contrib.sites.apps import SitesConfig
def create_default_site( def create_default_site(
app_config: SitesConfig, app_config: AppConfig,
verbosity: int = ..., verbosity: int = ...,
interactive: bool = ..., interactive: bool = ...,
using: str = ..., using: str = ...,

View File

@@ -1,15 +1,6 @@
from typing import Any, List, Optional from typing import Optional
from django.core.checks.messages import Error
from django.db.models.query import QuerySet
from django.db import models from django.db import models
class CurrentSiteManager(models.Manager): class CurrentSiteManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def __init__(self, field_name: Optional[str] = ...) -> None: ... def __init__(self, field_name: Optional[str] = ...) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def get_queryset(self) -> QuerySet: ...

View File

@@ -6,15 +6,16 @@ from django.db import models
SITE_CACHE: Any SITE_CACHE: Any
class SiteManager(models.Manager): class SiteManager(models.Manager["Site"]):
def get_current(self, request: Optional[HttpRequest] = ...) -> Site: ... def get_current(self, request: Optional[HttpRequest] = ...) -> Site: ...
def clear_cache(self) -> None: ... def clear_cache(self) -> None: ...
def get_by_natural_key(self, domain: str) -> Site: ... def get_by_natural_key(self, domain: str) -> Site: ...
class Site(models.Model): class Site(models.Model):
domain: models.CharField = ... objects: SiteManager
name: models.CharField = ...
objects: SiteManager = ... domain = models.CharField(max_length=100)
name = models.CharField(max_length=50)
def natural_key(self) -> Tuple[str]: ... def natural_key(self) -> Tuple[str]: ...
def clear_site_cache(sender: Type[Site], **kwargs: Any) -> None: ... def clear_site_cache(sender: Type[Site], **kwargs: Any) -> None: ...

View File

@@ -1,5 +1,7 @@
from typing import Any, List, Optional from typing import Any, List, Iterable, Optional
from django.core.checks.messages import Error from django.core.checks.messages import Error
def check_finders(app_configs: None = ..., **kwargs: Any) -> List[Error]: ... from django.apps.config import AppConfig
def check_finders(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Error]: ...

View File

@@ -37,7 +37,7 @@ def get_finders() -> Iterator[BaseFinder]: ...
def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ... def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...
@overload @overload
def get_finder( def get_finder(
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"] import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"],
) -> AppDirectoriesFinder: ... ) -> AppDirectoriesFinder: ...
@overload @overload
def get_finder(import_path: str) -> BaseFinder: ... def get_finder(import_path: str) -> BaseFinder: ...

View File

@@ -1,6 +1,6 @@
from typing import Any, Dict, List from typing import Any, Dict, List
from django.core.files.storage import FileSystemStorage from django.core.files.storage import Storage
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
class Command(BaseCommand): class Command(BaseCommand):
@@ -23,6 +23,6 @@ class Command(BaseCommand):
def log(self, msg: str, level: int = ...) -> None: ... def log(self, msg: str, level: int = ...) -> None: ...
def is_local_storage(self) -> bool: ... def is_local_storage(self) -> bool: ...
def clear_dir(self, path: str) -> None: ... def clear_dir(self, path: str) -> None: ...
def delete_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> bool: ... def delete_file(self, path: str, prefixed_path: str, source_storage: Storage) -> bool: ...
def link_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> None: ... def link_file(self, path: str, prefixed_path: str, source_storage: Storage) -> None: ...
def copy_file(self, path: str, prefixed_path: str, source_storage: FileSystemStorage) -> None: ... def copy_file(self, path: str, prefixed_path: str, source_storage: Storage) -> None: ...

View File

@@ -4,7 +4,6 @@ from typing import Any, Callable, Iterator, Optional, Tuple
from django.core.files.base import File from django.core.files.base import File
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
from django.utils.functional import LazyObject from django.utils.functional import LazyObject
from django.utils.safestring import SafeText
class StaticFilesStorage(FileSystemStorage): class StaticFilesStorage(FileSystemStorage):
base_location: Any = ... base_location: Any = ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional from typing import Any
from django.template.base import Parser, Token from django.template.base import Parser, Token
from django.templatetags.static import StaticNode from django.templatetags.static import StaticNode

View File

@@ -0,0 +1,3 @@
from django.test import LiveServerTestCase
class StaticLiveServerTestCase(LiveServerTestCase): ...

View File

@@ -2,6 +2,6 @@ from typing import Any, List, Optional
from django.urls.resolvers import URLPattern from django.urls.resolvers import URLPattern
urlpatterns: Any urlpatterns: List[Any] = ...
def staticfiles_urlpatterns(prefix: None = ...) -> List[URLPattern]: ... def staticfiles_urlpatterns(prefix: Optional[str] = ...) -> List[URLPattern]: ...

View File

@@ -1,5 +1,5 @@
from collections import OrderedDict from collections import OrderedDict
from typing import Any, Iterator, List, Optional, Tuple, Union from typing import Iterator, List, Optional, Tuple, Union
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional from typing import Any
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest
from django.http.response import FileResponse from django.http.response import FileResponse

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional from typing import Any, Dict, List
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.handlers.wsgi import WSGIRequest from django.core.handlers.wsgi import WSGIRequest

View File

@@ -1,7 +1,11 @@
from collections import OrderedDict from collections import OrderedDict
from typing import Any, Callable, Dict, Union from typing import Any, Callable, Dict, Union
from .backends.base import BaseCache as BaseCache from .backends.base import (
BaseCache as BaseCache,
CacheKeyWarning as CacheKeyWarning,
InvalidCacheBackendError as InvalidCacheBackendError,
)
DEFAULT_CACHE_ALIAS: str DEFAULT_CACHE_ALIAS: str

View File

@@ -19,16 +19,16 @@ class BaseCache:
def __init__(self, params: Dict[str, Any]) -> None: ... def __init__(self, params: Dict[str, Any]) -> None: ...
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ... def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
def make_key(self, key: Any, version: Optional[Any] = ...) -> str: ... def make_key(self, key: Any, version: Optional[Any] = ...) -> str: ...
def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... def add(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> bool: ...
def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ... def get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> Any: ...
def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... def set(self, key: Any, value: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ...
def touch(self, key: Any, timeout: Any = ..., version: Optional[Any] = ...) -> None: ... def touch(self, key: Any, timeout: Any = ..., version: Optional[Any] = ...) -> bool: ...
def delete(self, key: Any, version: Optional[Any] = ...) -> None: ... def delete(self, key: Any, version: Optional[Any] = ...) -> None: ...
def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ... def get_many(self, keys: List[str], version: Optional[int] = ...) -> Dict[str, Union[int, str]]: ...
def get_or_set( def get_or_set(
self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ... self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ...
) -> Optional[Any]: ... ) -> Optional[Any]: ...
def has_key(self, key: Any, version: Optional[Any] = ...): ... def has_key(self, key: Any, version: Optional[Any] = ...) -> bool: ...
def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... def incr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ... def decr(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...
def __contains__(self, key: str) -> bool: ... def __contains__(self, key: str) -> bool: ...

View File

@@ -1,26 +1,6 @@
from typing import Any, Callable, Dict, Optional, Union from typing import Any, Dict
from django.core.cache.backends.base import BaseCache from django.core.cache.backends.base import BaseCache
class LocMemCache(BaseCache): class LocMemCache(BaseCache):
default_timeout: int def __init__(self, name: str, params: Dict[str, Any]) -> None: ...
key_func: Callable
key_prefix: str
version: int
def __init__(self, name: str, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ...
def add(
self,
key: str,
value: Union[Dict[str, int], Dict[str, str], bytes, int, str],
timeout: Any = ...,
version: Optional[int] = ...,
) -> Any: ...
def get(
self, key: Union[int, str], default: Optional[Union[int, str]] = ..., version: Optional[int] = ...
) -> Any: ...
def set(self, key: Union[int, str], value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> Any: ...
def incr(self, key: Union[int, str], delta: int = ..., version: Optional[int] = ...) -> int: ...
def has_key(self, key: str, version: Optional[int] = ...) -> Any: ...
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
def clear(self) -> None: ...

View File

@@ -0,0 +1,10 @@
from django.core.cache.backends.base import BaseCache
class BaseMemcachedCache(BaseCache):
def __init__(self, server, params, library, value_not_found_exception) -> None: ...
class MemcachedCache(BaseMemcachedCache):
def __init__(self, server, params): ...
class PyLibMCCache(BaseMemcachedCache):
def __init__(self, server, params): ...

View File

@@ -1,3 +1,17 @@
from .messages import Warning as Warning, Info as Info, Debug as Debug, Error as Error, Critical as Critical from .messages import (
CheckMessage as CheckMessage,
Debug as Debug,
Info as Info,
Warning as Warning,
Error as Error,
Critical as Critical,
DEBUG as DEBUG,
INFO as INFO,
WARNING as WARNING,
ERROR as ERROR,
CRITICAL as CRITICAL,
)
from .registry import run_checks as run_checks, Tags as Tags, register as register from .registry import register as register, run_checks as run_checks, tag_exists as tag_exists, Tags as Tags
from . import model_checks as model_checks

View File

@@ -1,7 +1,9 @@
from typing import Any, List, Optional from typing import Any, List, Iterable, Optional
from django.core.checks.messages import Error from django.core.checks.messages import Error
from django.apps.config import AppConfig
E001: Any E001: Any
def check_default_cache_is_configured(app_configs: None, **kwargs: Any) -> List[Error]: ... def check_default_cache_is_configured(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Error]: ...

View File

@@ -1,3 +1,3 @@
from typing import Any, List, Optional from typing import Any, List
def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ... def check_database_backends(*args: Any, **kwargs: Any) -> List[Any]: ...

View File

@@ -7,11 +7,11 @@ ERROR: int
CRITICAL: int CRITICAL: int
class CheckMessage: class CheckMessage:
level: Any = ... level: int = ...
msg: Any = ... msg: str = ...
hint: Any = ... hint: Optional[str] = ...
obj: Any = ... obj: Any = ...
id: Any = ... id: Optional[str] = ...
def __init__( def __init__(
self, level: int, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ... self, level: int, msg: str, hint: Optional[str] = ..., obj: Any = ..., id: Optional[str] = ...
) -> None: ... ) -> None: ...
@@ -25,19 +25,9 @@ class Info(CheckMessage):
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class Warning(CheckMessage): class Warning(CheckMessage):
hint: str
id: str
level: int
msg: str
obj: Any
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class Error(CheckMessage): class Error(CheckMessage):
hint: None
id: str
level: int
msg: str
obj: Any
def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class Critical(CheckMessage): class Critical(CheckMessage):

View File

@@ -1,6 +1,8 @@
from typing import Any, List from typing import Any, List, Iterable, Optional
from django.core.checks.messages import Warning from django.core.checks.messages import Warning
def check_all_models(app_configs: None = ..., **kwargs: Any) -> List[Warning]: ... from django.apps.config import AppConfig
def check_lazy_references(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
def check_all_models(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Warning]: ...
def check_lazy_references(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...

View File

@@ -12,6 +12,7 @@ class Tags:
security: str = ... security: str = ...
signals: str = ... signals: str = ...
templates: str = ... templates: str = ...
translation: str = ...
urls: str = ... urls: str = ...
class CheckRegistry: class CheckRegistry:

View File

@@ -1,7 +1,9 @@
from typing import Any, List, Optional from typing import Any, List, Iterable, Optional
from django.core.checks.messages import Warning from django.core.checks.messages import Warning
from django.apps.config import AppConfig
SECRET_KEY_MIN_LENGTH: int SECRET_KEY_MIN_LENGTH: int
SECRET_KEY_MIN_UNIQUE_CHARACTERS: int SECRET_KEY_MIN_UNIQUE_CHARACTERS: int
W001: Any W001: Any
@@ -17,15 +19,15 @@ W019: Any
W020: Any W020: Any
W021: Any W021: Any
def check_security_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_security_middleware(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_xframe_options_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_xframe_options_middleware(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_sts(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_sts(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_sts_include_subdomains(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_sts_include_subdomains(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_sts_preload(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_sts_preload(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_content_type_nosniff(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_content_type_nosniff(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_xss_filter(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_xss_filter(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_ssl_redirect(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_ssl_redirect(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_secret_key(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_secret_key(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_debug(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_debug(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_xframe_deny(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_xframe_deny(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_allowed_hosts(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_allowed_hosts(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...

View File

@@ -1,9 +1,11 @@
from typing import Any, List, Optional from typing import Any, List, Iterable, Optional
from django.core.checks.messages import Warning from django.core.checks.messages import Warning
from django.apps.config import AppConfig
W003: Any W003: Any
W016: Any W016: Any
def check_csrf_middleware(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_csrf_middleware(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_csrf_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_csrf_cookie_secure(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...

View File

@@ -1,7 +1,9 @@
from typing import Any, List, Optional from typing import Any, List, Iterable, Optional
from django.core.checks.messages import Warning from django.core.checks.messages import Warning
from django.apps.config import AppConfig
def add_session_cookie_message(message: Any): ... def add_session_cookie_message(message: Any): ...
W010: Any W010: Any
@@ -14,5 +16,5 @@ W013: Any
W014: Any W014: Any
W015: Any W015: Any
def check_session_cookie_secure(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_session_cookie_secure(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...
def check_session_cookie_httponly(app_configs: None, **kwargs: Any) -> List[Warning]: ... def check_session_cookie_httponly(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Warning]: ...

View File

@@ -1,9 +1,11 @@
from typing import Any, List, Optional from typing import Any, List, Iterable, Optional
from django.core.checks.messages import Error from django.core.checks.messages import Error
from django.apps.config import AppConfig
E001: Any E001: Any
E002: Any E002: Any
def check_setting_app_dirs_loaders(app_configs: None, **kwargs: Any) -> List[Error]: ... def check_setting_app_dirs_loaders(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Error]: ...
def check_string_if_invalid_is_string(app_configs: None, **kwargs: Any) -> List[Error]: ... def check_string_if_invalid_is_string(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[Error]: ...

Some files were not shown because too many files have changed in this diff Show More