178 Commits

Author SHA1 Message Date
Maxim Kurnikov
13d19017b7 bump version 2019-04-01 19:40:13 +03:00
Maxim Kurnikov
28a3f126ee make mypy.checker import locally to prevent import cycles 2019-04-01 19:39:50 +03:00
Maxim Kurnikov
304cb19de6 really drop universal 2019-04-01 01:43:14 +03:00
Maxim Kurnikov
c57f4f7152 only python3.6+ are supported 2019-04-01 01:08:46 +03:00
Maxim Kurnikov
8a826fee1e bump version 2019-04-01 00:54:36 +03:00
Maxim Kurnikov
37d85c2ca6 pin mypy version, django-stubs not yet supports mypyc 2019-04-01 00:54:15 +03:00
Seth Yastrov
71fb0432f3 52/model subtypes dont typecheck (#55)
* Fix problem where Model instancess are not considered subtypes of each other due to fallback_to_any = True. Fixes #52.

- Added a stub for __getstate__ to Model.
- Added a stub for clean() to Model.
- Correct arg type for sort_dependencies so they are covariant (Iterable rather than List).

Test ignores:
- Added some test ignores in cases where a model inherits from 2 different base models.
- Added some test ignores for cases that MyPy flags as errors due to variable redefinitions or imports that are incompatible types.

* Address review comment.
2019-03-28 23:13:02 +03:00
Maxim Kurnikov
9288c34648 fix @classproperty return type (#58) 2019-03-27 23:13:10 +03:00
Maxim Kurnikov
70050f28b9 drop --universal 2019-03-26 03:23:25 +03:00
Maxim Kurnikov
4338c17970 bump version 2019-03-25 14:22:17 +03:00
Maxim Kurnikov
91f789c38c fix SessionBase.exists() return type (#57) 2019-03-25 14:21:12 +03:00
Maxim Kurnikov
0f5b45fba1 bump version 2019-03-25 13:31:41 +03:00
Seth Yastrov
5b455b729a Specific return types for values and values list (#53)
* Instead of using Literal types, overload QuerySet.values_list in the plugin. Fixes #43.

- Add a couple of extra type checks that Django makes:
  1) 'flat' and 'named' can't be used together.
  2) 'flat' is not valid when values_list is called with more than one field.

* Determine better row types for values_list/values based on fields specified.

- In the case of values_list, we use a Row type with either a single primitive, Tuple, or NamedTuple.
- In the case of values, we use a TypedDict.
- In both cases, Any is used as a fallback for individual fields if those fields cannot be resolved.

A couple other fixes I made along the way:
- Don't create reverse relation for ForeignKeys with related_name='+'
- Don't skip creating other related managers in AddRelatedManagers if a dynamic value is encountered
  for related_name parameter, or if the type cannot be determined.

* Fix for TypedDict so that they are considered anonymous.

* Clean up some comments.

* Implement making TypedDict anonymous in a way that doesn't crash sometimes.

* Fix flake8 errors.

* Remove even uglier hack about making TypedDict anonymous.

* Address review comments. Write a few better comments inside tests.

* Fix crash when running with mypyc ("interpreted classes cannot inherit from compiled") due to the way I extended TypedDictType.

- Implemented the hack in another way that works on mypyc.
- Added a couple extra tests of accessing 'id' / 'pk' via values_list.

* Fix flake8 errors.

* Support annotation expressions (use type Any) for TypedDicts row types returned by values_list.

- Bonus points: handle values_list gracefully (use type Any) where Tuples are returned
  where some of the fields arguments are not string literals.
2019-03-25 12:53:09 +03:00
Maxim Kurnikov
5c6be7ad12 Add test to import all modules to check validity of stubs (#56)
* add import_all.test builder

* fix errors

* fix typechecking errors

* fix migrations typechecking
2019-03-25 01:57:34 +03:00
Maxim Kurnikov
5d0ee40ada Fix errors in db.models.expressions and db.models.functions.* (#54)
* fix errors at db.models.expressions and db.models.functions.*

* catch KeyError if QuerySet has not been loaded
2019-03-24 02:54:10 +03:00
Konstantin Alekseev
77f15d7478 Configure black using pyproject.toml (#50) 2019-03-18 16:53:12 +03:00
Konstantin Alekseev
4f83d8d1bb Use less specific types in validators args (#49) 2019-03-18 13:31:35 +03:00
Seth Yastrov
b1a04d2f7d Instead of using Literal types, overload QuerySet.values_list in the plugin. Fixes #43. (#44)
- Add a couple of extra type checks that Django makes:
  1) 'flat' and 'named' can't be used together.
  2) 'flat' is not valid when values_list is called with more than one field.
2019-03-13 22:10:37 +03:00
Maxim Kurnikov
7c57143310 forms/__init__ reimports 2019-03-10 21:14:15 +03:00
Maxim Kurnikov
c3d76f9a1e bump version 2019-03-10 20:03:00 +03:00
Maxim Kurnikov
fde071b883 fix classonlymethod, replace with six from typeshed 2019-03-10 19:56:54 +03:00
Seth Yastrov
324b961d74 Support returning the correct values for the different QuerySet methods when using .values() and .values_list(). (#33)
* Support returning the correct values for the different QuerySet methods when using .values() and .values_list().

* Fix slicing on QuerySet. Fix django queries test, and remove some ignored errors that are no longer needed.

* Remove accidental change in RawQuerySet.

* Readded some still-necessary ignores to aggregation django test.

* Add more tests of first/last/earliest/last/__getitem__, per mkurnikov's comments.

- Fix .iterator()

* Re-add Iterator as base-class of QuerySet.

* Make QuerySet a Collection.

* - Fix return type for QuerySet.select_for_update().
- Use correct return type for QuerySet.dates() / QuerySet.datetimes().
- Use correct type params in return type for QuerySet.__and__ / QuerySet.__or__
- Re-add Sized as base class for QuerySet.
- Add test of .all() for all _Row types.
- Add test of .get() for all _Row types.
- Remove some redundant QuerySet method tests.

* Automatically fill in second type parameter for QuerySet.

... if second parameter is omitted.
2019-03-10 12:13:50 +03:00
Seth Yastrov
86c63d790b Fix type errors on other models' managers when using objects = models.Manager() in Model. (#34)
* Fix bug where models with a class variable using a manager defined would interfere with other managers.

- Fill in the type argument for that particular instance of the manager, rather than modifying the bases of the Manager type.
- Instantiate a new Instance from determine_proper_manager_type so The code doesn't crash under mypy-mypyc.

* Use helpers.reparametrize_instance per review comment.

* Updated ignored errors in Django test for get_objects_or_404.

- For some reason, `Manager[nothing]` is now removed from expected types.
  However, I think this makes sense anyway, as Manager is a subclass of QuerySet.
2019-03-08 12:30:38 +03:00
Matt Basta
050c1b8887 Add gzip_page decorator (#41)
* Add gzip_page decorator

* Update to preserve Callable
2019-03-06 21:16:24 +03:00
Maxim Kurnikov
8978ad471f bump version 2019-03-06 12:05:24 +03:00
Richard Eames
f7dfbefbd6 Make CharField(blank=True) not be considered nullable (#39)
* Make CharField(blank=True) not be considered nullable

The documentation on [blank](https://docs.djangoproject.com/en/2.1/ref/models/fields/#blank) says that it "will allow the entry of an empty value", which for a string is just a 0-length string. This patch allows `CharField(blank=True,...)` to no longer be considered `Optional`.

closes #38

* fixed tests for `CharField(blank=True)`

* allow blank CharField to be nullable in the constructor, but the underlying type
is str (unless `null=True`)
2019-03-06 01:37:44 +03:00
Maxim Kurnikov
627daa55f5 fix extension of django.views __init__ file 2019-03-06 01:28:42 +03:00
Maxim Kurnikov
194489ee8d bump version 2019-03-05 20:21:43 +03:00
Maxim Kurnikov
1d2c7fb805 Remove _Val alias for MultiValueDict so that generic evaluate (#36)
* remove _Val alias for MultiValueDict so that generic evaluate

* fix multivaluedict init argument
2019-03-05 20:16:24 +03:00
Maxim Kurnikov
18c908bf98 set plugin_generated on new symbol nodes 2019-03-05 20:15:46 +03:00
Maxim Kurnikov
e0e8814804 Revert "dont convert to optional, if anytype"
This reverts commit 53f5d2214b.
2019-03-05 19:11:02 +03:00
Maxim Kurnikov
53f5d2214b dont convert to optional, if anytype 2019-03-05 18:43:10 +03:00
Maxim Kurnikov
9e4ed70fc5 Disable note: messages (#35)
* add global note: ignore
2019-03-01 05:15:05 +03:00
Maxim Kurnikov
18445f686f set fallback= for ini parser 2019-03-01 02:25:15 +03:00
Maxim Kurnikov
c962b8ac68 attempt to add flake8 and isort 2019-03-01 02:07:53 +03:00
Maxim Kurnikov
70c3126348 add plugin testing for python3.6 2019-02-27 18:12:29 +03:00
Maxim Kurnikov
af8ecc5520 remove django from dependencies, it's not required for static analysis 2019-02-27 18:11:54 +03:00
Maxim Kurnikov
64f8870d0b bump version 2019-02-27 17:59:04 +03:00
Maxim Kurnikov
df5c70c703 fixes for FormMixin's get_form/get_form_class 2019-02-25 04:01:36 +03:00
Maxim Kurnikov
c09a97e005 Merge pull request #29 from syastrov/queryset_in_bulk
QuerySet.in_bulk returns Dict with values of correct model type.
2019-02-22 23:23:36 +03:00
Seth Yastrov
0e30821ad3 Add possibility to pass list of test names as command-line arguments to typecheck_tests.py script. 2019-02-22 20:03:30 +01:00
Seth Yastrov
2dadd681ff Change in_bulk id_list param to Iterable rather than Sequence. 2019-02-22 20:03:20 +01:00
Seth Yastrov
2dec3b4325 Merge branch 'master' into queryset_in_bulk 2019-02-22 08:16:48 +01:00
Seth Yastrov
3b8c5d08e8 QuerySet.in_bulk fixes.
- Made id_list of type Sequence[Any], rather than Any, according to mkurnikov's review.
- Removed **kwargs.
- Made returned Dict keys of type Any rather than int or str as it depends on the provided field's type.
- Added test with examples from Django docs.
2019-02-22 08:13:31 +01:00
Maxim Kurnikov
eaee3d390f fix HttpResponse stubs by removing AnyStr 2019-02-22 03:22:11 +03:00
Maxim Kurnikov
b686751f19 fix some stubs 2019-02-22 02:55:49 +03:00
Maxim Kurnikov
73ea682356 rework django.views 2019-02-22 01:50:52 +03:00
Maxim Kurnikov
9ea25f3e56 bump version 2019-02-22 00:13:59 +03:00
Maxim Kurnikov
dacf88c692 optimize hooks a bit 2019-02-22 00:12:23 +03:00
Maxim Kurnikov
3d14d07e4e incremental = True for plugin tests should be fixed now 2019-02-21 17:35:46 +03:00
Maxim Kurnikov
6e6d1645d3 enable incremental mode for tests, disable it for one so that it would pass 2019-02-21 00:06:09 +03:00
Seth Yastrov
cda703a94b QuerySet.in_bulk returns Dict with values of correct model type.
- The keys are still Union[int, str] which doesn't cover all
possibilities, but it's not possible to cover without handling this in
the plugin, because the type of the Dict keys are dynamic depending on
which value for field_name you pass in.
2019-02-20 20:51:43 +01:00
Maxim Kurnikov
2bd018951b forms, generic views fixes 2019-02-20 22:24:26 +03:00
Maxim Kurnikov
14ea848dd7 add nested Meta inheritance support for forms 2019-02-20 21:52:28 +03:00
Maxim Kurnikov
2d3b5492f0 fix form errors in CI 2019-02-20 21:24:49 +03:00
Maxim Kurnikov
194258ab8e Merge pull request #23 from syastrov/better-types-for-transaction-atomic
Add better typings plus test for transaction.atomic.
2019-02-20 21:12:14 +03:00
Maxim Kurnikov
116aa2c539 clean up forms 2019-02-20 15:22:46 +03:00
Seth Yastrov
67c99434e5 Add better typings plus test for transaction.atomic.
- All cases are handled, including bare decorator (@transaction.atomic).
- Decorated function's signature is preserved when type-checking.
2019-02-20 06:40:22 +01:00
Maxim Kurnikov
5d8cdbcf29 fix integer set type 2019-02-20 02:38:45 +03:00
Maxim Kurnikov
78810f55b6 Merge pull request #26 from roderik333/supertype-processformview
*args and **kwargs changed from 'object' to 'str' and 'any' in post()…
2019-02-19 15:23:50 +03:00
Rune Steinnes
36662896bc *args and **kwargs changed from 'object' to 'str' and 'any' in post(), put() and get() 2019-02-19 12:48:07 +01:00
Maxim Kurnikov
e54dbb79c9 Merge pull request #24 from roderik333/replace-wsgirequest-in-loginrequiredmixin
Replaced WSGIRequest with http.HttpRequest in mixin:LoginRequiredMixin
2019-02-19 13:54:43 +03:00
Rune Steinnes
41f283552a Replaced WSGIRequest with http.HttpRequest in mixin:LoginRequiredMixin 2019-02-19 11:16:27 +01:00
Maxim Kurnikov
ab73d53ae5 add support for models defined in the same module be specified as name of class in related fields 2019-02-19 00:43:27 +03:00
Maxim Kurnikov
d24be4b35f add supported versions to README 2019-02-19 00:42:12 +03:00
Maxim Kurnikov
9d60b472df fix *args, **kwargs for views.generic.base 2019-02-18 15:45:01 +03:00
Maxim Kurnikov
632e063e22 back to incremental = True for tests 2019-02-18 02:16:13 +03:00
Maxim Kurnikov
66224416b5 bump version 2019-02-18 01:47:45 +03:00
Maxim Kurnikov
e5b2496eb5 update django tests sources to latest commit 2019-02-18 01:05:57 +03:00
Maxim Kurnikov
f980311be0 finish strict_optional support, enable it for typechecking of django tests 2019-02-18 00:52:56 +03:00
Maxim Kurnikov
400a0f0486 silence some false positives 2019-02-17 20:20:33 +03:00
Maxim Kurnikov
882ec71d23 remove redundant test 2019-02-17 18:08:58 +03:00
Maxim Kurnikov
e9f9202ed1 preliminary support for strict_optional 2019-02-17 18:07:53 +03:00
Maxim Kurnikov
6763217a80 some strict optional fixes 2019-02-16 21:28:37 +03:00
Maxim Kurnikov
6da5ead6f0 move to pypi version of pytest plugin 2019-02-15 22:01:35 +03:00
Maxim Kurnikov
c382d6aa2f fix redefining field with name id with different than int type 2019-02-15 21:54:40 +03:00
Maxim Kurnikov
63a14f7107 chmod +x 2019-02-15 20:06:13 +03:00
Maxim Kurnikov
dc33dd9493 fix setup.py definition 2019-02-15 20:03:55 +03:00
Maxim Kurnikov
4cb10390cf bump version 2019-02-14 03:34:49 +03:00
Maxim Kurnikov
c1640b619f fix stale import 2019-02-14 03:21:11 +03:00
Maxim Kurnikov
a08ad80a0d fix star import parsing for settings 2019-02-14 03:16:07 +03:00
Maxim Kurnikov
f30cd092f1 add default for MYPY_DJANGO_CONFIG 2019-02-13 23:02:49 +03:00
Maxim Kurnikov
dcd9ee0bb8 enable 'validation' test folder 2019-02-13 21:12:58 +03:00
Maxim Kurnikov
26a80a8279 add properly typed FOREIGN_KEY_FIELD_NAME_id fields to models 2019-02-13 21:05:02 +03:00
Maxim Kurnikov
82de0a8791 lint 2019-02-13 20:00:42 +03:00
Maxim Kurnikov
79ebe20f2e add more test folders 2019-02-13 19:44:25 +03:00
Maxim Kurnikov
587c2c484b more accurate types for from_queryset() 2019-02-13 17:55:50 +03:00
Maxim Kurnikov
4a22da29cb add support for default related managers, fixes #18 2019-02-13 17:11:22 +03:00
Maxim Kurnikov
70378b8f40 preserve fallback to Any for unrecognized field types for init/create 2019-02-13 17:00:35 +03:00
Maxim Kurnikov
b7f7713c5a add support for get_user_model(), fixes #16 2019-02-13 15:56:21 +03:00
Maxim Kurnikov
2720b74242 add proper generic support for get_object_or_404/get_list_or_404, fixes #22 2019-02-13 14:52:10 +03:00
Maxim Kurnikov
563c0add5e add release script 2019-02-13 14:36:33 +03:00
Maxim Kurnikov
3191740c6b bump version 2019-02-13 14:36:17 +03:00
Maxim Kurnikov
cf7c263fb5 fix tests 2019-02-12 17:09:28 +03:00
Maxim Kurnikov
16a983152a CharField can receive ints 2019-02-12 04:08:30 +03:00
Maxim Kurnikov
9eb95fbab3 add BaseManager.create() typechecking 2019-02-12 03:54:48 +03:00
Maxim Kurnikov
7aafca2e5d Change license to MIT 2019-02-11 13:56:34 +03:00
Maxim Kurnikov
d05e739d75 fix ci 2019-02-11 01:29:30 +03:00
Maxim Kurnikov
faefdcca5b fix ci 2019-02-11 01:12:59 +03:00
Maxim Kurnikov
643f852775 enable two more test folders 2019-02-10 04:41:54 +03:00
Maxim Kurnikov
6b7507206a fix couple edge cases with __init__ 2019-02-10 04:32:27 +03:00
Maxim Kurnikov
5f6f597266 add config file support 2019-02-09 03:21:49 +03:00
Maxim Kurnikov
5c6aa9a00b bump mypy version 2019-02-09 03:03:49 +03:00
Maxim Kurnikov
916df1efb6 add Model.__init__ typechecking 2019-02-08 17:16:03 +03:00
Maxim Kurnikov
dead370244 fix ci 2019-02-07 20:58:12 +03:00
Maxim Kurnikov
dcb4da378b add dataclasses as a dependency for python3.6 2019-02-07 19:19:16 +03:00
Maxim Kurnikov
d4cb729c93 rework settings, add loading of the django.conf.global_settings, cleanups 2019-02-07 19:13:39 +03:00
Maxim Kurnikov
faee26703e fix ci 2019-02-07 02:10:53 +03:00
Maxim Kurnikov
f7b586f038 ci should be good now 2019-02-07 01:43:34 +03:00
Maxim Kurnikov
56cd3bc77d fix ci 2019-02-07 01:27:29 +03:00
Maxim Kurnikov
11500f337d try ci fix 2019-02-07 01:19:19 +03:00
Maxim Kurnikov
723d9fbfb7 fix 2019-02-07 01:04:43 +03:00
Maxim Kurnikov
3fb3bbcf19 fix values_list 2019-02-07 01:01:05 +03:00
Maxim Kurnikov
191496ed72 enable some test folders, bunch of fixes 2019-02-07 00:08:05 +03:00
Maxim Kurnikov
d43cb1fcd7 fixes 2019-02-06 22:20:12 +03:00
Maxim Kurnikov
2559901ff3 more test folders 2019-02-06 20:56:44 +03:00
Maxim Kurnikov
0c121d65d1 fixes 2019-02-06 20:46:05 +03:00
Maxim Kurnikov
d18fc0bf5f enable 6 more test folders 2019-02-06 14:29:42 +03:00
Maxim Kurnikov
c534e75aaf remove Meta entries 2019-02-06 13:22:53 +03:00
Maxim Kurnikov
af30bb6c4a Merge pull request #15 from HyreAS/more-fields
More fields
2019-02-05 16:46:57 +03:00
Maxim Kurnikov
dbc9b49867 add test_runner/lookup test folders 2019-02-05 16:41:28 +03:00
Aleksander Vognild Burkow
a9c1f35494 Update decimal reveal_type test 2019-02-05 14:30:23 +01:00
Aleksander Vognild Burkow
4ea4c3eddd Ignore external psycopg2 types 2019-02-05 14:23:06 +01:00
Maxim Kurnikov
e4d2b795e3 fix ci 2019-02-05 16:09:42 +03:00
Maxim Kurnikov
be0b2eebb2 add central directory for mypy cache 2019-02-05 15:35:01 +03:00
Maxim Kurnikov
38291e0651 fix ci 2019-02-04 19:38:19 +03:00
Maxim Kurnikov
69d4ccaf54 fixes, add some testing folders 2019-02-04 19:31:37 +03:00
Aleksander Vognild Burkow
6c87ccf228 Add tests for the new fields 2019-02-04 17:15:34 +01:00
Aleksander Vognild Burkow
08bf5660bf Add additional django field __get__ types
These are taken from the corresponding
django/contrib/postgres/fields/ranges.py file.
2019-02-04 17:08:00 +01:00
Aleksander Vognild Burkow
7819165e42 Add decimal field typings 2019-02-04 17:08:00 +01:00
Maxim Kurnikov
3dcab64e07 add stricter dependencies 2019-02-04 18:47:01 +03:00
Maxim Kurnikov
5a08a99d8b disable deployment on tags for now 2019-02-04 18:46:13 +03:00
Maxim Kurnikov
6fcccb3769 bump to 0.3.0 2019-02-03 21:59:05 +03:00
Maxim Kurnikov
68c5da12f9 add pypi deploy config 2019-02-03 21:13:36 +03:00
Maxim Kurnikov
f5135dac9f expressions 2019-02-03 20:41:27 +03:00
Maxim Kurnikov
2a6a0120a9 black reformat 2019-02-03 20:09:27 +03:00
Maxim Kurnikov
59b4d2e849 add custom_lookups, custom_managers test folders 2019-02-03 20:06:13 +03:00
Maxim Kurnikov
5f6b4bfd30 add test_views test folder 2019-02-03 19:51:17 +03:00
Maxim Kurnikov
d03fddd96d split error suppression for tests typechecking, fix ci, bunch of fixes 2019-02-03 19:33:51 +03:00
Maxim Kurnikov
e409dbdb82 Merge pull request #5 from K0Te/django-db-models-missing-imports
Add missing re-imports to django.db.models.
2019-02-03 18:52:19 +03:00
Maxim Kurnikov
880bab395b Merge pull request #14 from HyreAS/reexport-timezone-imports
Reexport utils.timezone imports
2019-02-03 16:36:56 +03:00
Aleksander Vognild Burkow
9461dbfb4f Reexport utils.timezone imports
These are reexported by django.
2019-02-01 17:05:26 +01:00
Oleg Nykolyn
7a7f68ede4 Fix formatting. 2019-01-31 21:44:32 +02:00
Oleg Nykolyn
3ccecebe3f Fix and uncomment tests. 2019-01-31 21:35:35 +02:00
Oleg Nykolyn
55415458dc Merge branch 'master' into django-db-models-missing-imports 2019-01-31 20:32:47 +02:00
Oleg Nykolyn
255e4af911 Add annotations for Prefetch, prefetch_related_objects. 2019-01-31 20:29:15 +02:00
Maxim Kurnikov
7f8477ff3d silence failing test folders 2019-01-31 18:43:38 +03:00
Maxim Kurnikov
06724b762e black 2019-01-31 18:43:24 +03:00
Maxim Kurnikov
19e9cd7ffc fix failing plugin tests 2019-01-31 18:33:19 +03:00
Maxim Kurnikov
815c3ea497 add missing comma 2019-01-31 18:28:52 +03:00
Maxim Kurnikov
b636d24051 fixes for stubs 2019-01-31 18:28:18 +03:00
Maxim Kurnikov
c9e8fe53a5 sort out all test folders into passable and TODOs 2019-01-30 22:43:09 +03:00
Maxim Kurnikov
b1153204d7 enable bunch of folders 2019-01-30 21:01:33 +03:00
Maxim Kurnikov
bb2d107e38 some fixes 2019-01-30 18:12:13 +03:00
Maxim Kurnikov
322addf6b2 mention gitter in readme 2019-01-30 17:33:14 +03:00
Maxim Kurnikov
8a952b416e enable more test folders: db.functions 2019-01-30 16:53:22 +03:00
Maxim Kurnikov
1868100bd9 enable more folders 2019-01-30 16:12:19 +03:00
Maxim Kurnikov
628c1224d6 enable test typechecking for a bunch of django test suite folders 2019-01-30 15:56:59 +03:00
Maxim Kurnikov
978379c454 add stubs for admin_changeset tests 2019-01-29 20:29:19 +03:00
Maxim Kurnikov
ece2b87318 disable globbing for tests folders, add regex support for ignored errors 2019-01-29 20:07:13 +03:00
Maxim Kurnikov
f07a9ecbb8 Merge pull request #8 from K0Te/get_object_or_404-annotation
Fix get_object_or_404() klass parameter annotation.
2019-01-29 19:19:07 +03:00
Maxim Kurnikov
e2bacbcbde fix typecheck script 2019-01-26 19:21:33 +03:00
Maxim Kurnikov
835889e3a4 move to plain python script for typechecking 2019-01-26 19:12:24 +03:00
Maxim Kurnikov
2914a0e560 fixes 2019-01-26 19:10:46 +03:00
Maxim Kurnikov
e35c474cf8 lint 2019-01-26 18:07:55 +03:00
Maxim Kurnikov
5d8576348e make typecheck ci pass 2019-01-26 18:04:26 +03:00
Maxim Kurnikov
145ce6bf18 return proper error rc 2019-01-26 17:59:12 +03:00
Maxim Kurnikov
db3f958d2c print typechecking errors to stderr 2019-01-26 17:46:10 +03:00
Oleg Nykolyn
161d296871 Fix get_object_or_404() klass parameter annotation. 2019-01-26 16:41:41 +02:00
Maxim Kurnikov
d6c9aa1b00 intentionally break a build 2019-01-26 17:33:43 +03:00
Oleg Nykolyn
2525b5b89f Add missing re-imports to django.db.models. 2019-01-26 16:32:46 +02:00
Maxim Kurnikov
eacdd2ba09 fix plugin tests 2019-01-26 17:26:06 +03:00
Maxim Kurnikov
b701d008f5 fix ls command for typecheck script 2019-01-26 17:20:19 +03:00
Maxim Kurnikov
1afa079b0b add tests for the django test suite 2019-01-26 17:17:35 +03:00
Maxim Kurnikov
38e841c4c7 look for models.Model in full mro for to= parameter 2019-01-25 17:23:34 +03:00
Maxim Kurnikov
bc4bc31722 add reimport for auth signals 2019-01-24 21:43:02 +03:00
Maxim Kurnikov
0f1af6581d on pypi now 2019-01-24 20:51:53 +03:00
Maxim Kurnikov
1b95bec5aa add README content for long_description 2019-01-24 20:48:43 +03:00
290 changed files with 7759 additions and 4265 deletions

View File

@@ -1,31 +1,48 @@
language: python
# cache package wheels (1 cache per python version)
cache: pip
# newer python versions are available only on xenial (while some older only on trusty) Ubuntu distribution
dist: xenial
sudo: required
jobs:
include:
- name: "Run plugin test suite with python 3.7"
python: 3.7
script: |
set -e
pytest
- name: Run plugin test suite with python 3.7
python: 3.7
script: |
set -e
pytest
- name: "Lint with black"
python: 3.7
script: |
black --check --line-length=120 django-stubs/
- name: Run plugin test suite with python 3.6
python: 3.6
script: |
set -e
pytest
# - name: "Typecheck Django test suite"
# python: 3.7
# script: |
# xonsh ./scripts/typecheck_django_tests.xsh
- name: Typecheck Django test suite
python: 3.7
script: 'python ./scripts/typecheck_tests.py'
- name: Lint with black
python: 3.7
script: 'black --check --line-length=120 django-stubs/'
- name: Lint plugin code with flake8
python: 3.7
script: 'flake8'
- name: Lint plugin code with isort
python: 3.7
script: 'isort --check'
before_install: |
# Upgrade pip, setuptools, and wheel
pip install -U pip setuptools wheel xonsh
pip install -U pip setuptools wheel
install: |
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

View File

@@ -1,27 +1,8 @@
Copyright (c) Maxim Kurnikov.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of Django nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -7,12 +7,14 @@
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.
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
```
git clone https://github.com/mkurnikov/django-stubs.git
cd django-stubs
pip install -U .
pip install django-stubs
```
To make mypy aware of the plugin, you need to add
@@ -25,4 +27,27 @@ plugins =
in your `mypy.ini` file.
Also, it uses value of `DJANGO_SETTINGS_MODULE` from the environment, so set it before execution, otherwise some features will not work.
## Configuration
In order to specify config file, set `MYPY_DJANGO_CONFIG` environment variable with path to the config file. Default is `./mypy_django.ini`
Config file format (.ini):
```
[mypy_django_plugin]
# specify settings module to use for django.conf.settings, this setting
# 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,
# specify it if your settings are loaded dynamically to avoid false positives
ignore_missing_settings = True
```
## To get help
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.

View File

@@ -1,3 +1,5 @@
black
-e git+https://github.com/mkurnikov/pytest-mypy-plugins.git#egg=pytest-mypy-plugins
pytest-mypy-plugins
flake8
isort==4.3.4
-e .

View File

@@ -1,5 +1,12 @@
from typing import Any
from typing import Any, NamedTuple
from .utils.version import get_version as get_version
VERSION: Any
__version__: str
def setup(set_prefix: bool = ...) -> None: ...
# Used by mypy_django_plugin when returning a QuerySet row that is a NamedTuple where the field names are unknown
class _NamedTupleAnyAttr(NamedTuple):
def __getattr__(self, item: str) -> Any: ...
def __setattr__(self, item: str, value: Any) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Iterator, Type
from typing import Any, Iterator, Type, Optional, Dict
from django.db.models.base import Model
@@ -6,14 +6,14 @@ MODELS_MODULE_NAME: str
class AppConfig:
name: str = ...
module: Any = ...
module: Optional[Any] = ...
apps: None = ...
label: str = ...
verbose_name: str = ...
path: str = ...
models_module: None = ...
models: None = ...
def __init__(self, app_name: str, app_module: None) -> None: ...
models: Dict[str, Type[Model]] = ...
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
@classmethod
def create(cls, entry: str) -> AppConfig: ...
def get_model(self, model_name: str, require_ready: bool = ...) -> Type[Model]: ...

View File

@@ -1,5 +1,5 @@
import collections
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict
from django.db.migrations.state import AppConfigStub
from django.db.models.base import Model
@@ -12,6 +12,7 @@ class Apps:
stored_app_configs: List[Any] = ...
apps_ready: bool = ...
loading: bool = ...
_pending_operations: DefaultDict[Tuple[str, str], List]
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
models_ready: bool = ...
ready: bool = ...

View File

@@ -2,6 +2,8 @@ from typing import Any
from django.utils.functional import LazyObject
ENVIRONMENT_VARIABLE: str = ...
# required for plugin to be able to distinguish this specific instance of LazySettings from others
class _DjangoConfLazyObject(LazyObject): ...
@@ -11,5 +13,8 @@ class LazySettings(_DjangoConfLazyObject):
settings: LazySettings = ...
class Settings: ...
class Settings:
def __init__(self, settings_module: str): ...
def is_overridden(self, setting: str) -> bool: ...
class UserSettingsHolder: ...

View File

@@ -0,0 +1,507 @@
"""
Default Django settings. Override these with settings in the module pointed to
by the DJANGO_SETTINGS_MODULE environment variable.
"""
# This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings.
from typing import Any, Dict, List, Optional, Pattern, Tuple, Protocol, Union, Callable, TYPE_CHECKING, Sequence
####################
# CORE #
####################
if TYPE_CHECKING:
from django.db.models.base import Model
DEBUG: bool = ...
# Whether the framework should propagate raw exceptions rather than catching
# them. This is useful under some testing situations and should never be used
# on a live site.
DEBUG_PROPAGATE_EXCEPTIONS: bool = ...
# People who get code error notifications.
# In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')]
ADMINS: List[Tuple[str, str]] = ...
# List of IP addresses, as strings, that:
# * See debug comments, when DEBUG is true
# * Receive x-headers
INTERNAL_IPS: List[str] = ...
# Hosts/domain names that are valid for this site.
# "*" matches anything, ".example.com" matches example.com and all subdomains
ALLOWED_HOSTS: List[str] = ...
# Local time zone for this installation. All choices can be found here:
# https://en.wikipedia.org/wiki/List_of_tz_zones_by_name (although not all
# systems may support all possibilities). When USE_TZ is True, this is
# interpreted as the default user time zone.
TIME_ZONE: str = ...
# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ: bool = ...
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE: str = ...
# Languages we provide translations for, out of the box.
LANGUAGES: List[Tuple[str, str]] = ...
# Languages using BiDi (right-to-left) layout
LANGUAGES_BIDI: List[str] = ...
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N: bool = ...
LOCALE_PATHS: List[str] = ...
# Settings for language cookie
LANGUAGE_COOKIE_NAME: str = ...
LANGUAGE_COOKIE_AGE: Optional[int] = ...
LANGUAGE_COOKIE_DOMAIN: Optional[str] = ...
LANGUAGE_COOKIE_PATH: str = ...
# If you set this to True, Django will format dates, numbers and calendars
# according to user current locale.
USE_L10N: bool = ...
# Not-necessarily-technical managers of the site. They get broken link
# notifications and other various emails.
MANAGERS = ADMINS
# Default content type and charset to use for all HttpResponse objects, if a
# MIME type isn't manually specified. These are used to construct the
# Content-Type header.
DEFAULT_CONTENT_TYPE: str = ...
DEFAULT_CHARSET: str = ...
# Encoding of files read from disk (template and initial SQL files).
FILE_CHARSET: str = ...
# Email address that error messages come from.
SERVER_EMAIL: str = ...
# Database connection info. If left empty, will default to the dummy backend.
DATABASES: Dict[str, Dict[str, Any]] = ...
# Classes used to implement DB routing behavior.
class Router(Protocol):
def allow_migrate(self, db, app_label, **hints): ...
DATABASE_ROUTERS: List[Union[str, Router]] = ...
# The email backend to use. For possible shortcuts see django.core.mail.
# The default is to use the SMTP backend.
# Third-party backends can be specified by providing a Python path
# to a module that defines an EmailBackend class.
EMAIL_BACKEND: str = ...
# Host for sending email.
EMAIL_HOST: str = ...
# Port for sending email.
EMAIL_PORT: int = ...
# Whether to send SMTP 'Date' header in the local time zone or in UTC.
EMAIL_USE_LOCALTIME: bool = ...
# Optional SMTP authentication information for EMAIL_HOST.
EMAIL_HOST_USER: str = ...
EMAIL_HOST_PASSWORD: str = ...
EMAIL_USE_TLS: bool = ...
EMAIL_USE_SSL: bool = ...
EMAIL_SSL_CERTFILE: Optional[str] = ...
EMAIL_SSL_KEYFILE: Optional[str] = ...
EMAIL_TIMEOUT: Optional[int] = ...
# List of strings representing installed apps.
INSTALLED_APPS: List[str] = ...
TEMPLATES: List[Dict[str, Any]] = ...
# Default form rendering class.
FORM_RENDERER: str = ...
# Default email address to use for various automated correspondence from
# the site managers.
DEFAULT_FROM_EMAIL: str = ...
# Subject-line prefix for email messages send with django.core.mail.mail_admins
# or ...mail_managers. Make sure to include the trailing space.
EMAIL_SUBJECT_PREFIX: str = ...
# Whether to append trailing slashes to URLs.
APPEND_SLASH: bool = ...
# Whether to prepend the "www." subdomain to URLs that don't have it.
PREPEND_WWW: bool = ...
# Override the server-derived value of SCRIPT_NAME
FORCE_SCRIPT_NAME = None
# List of compiled regular expression objects representing User-Agent strings
# that are not allowed to visit any page, systemwide. Use this for bad
# robots/crawlers. Here are a few examples:
# import re
# DISALLOWED_USER_AGENTS = [
# re.compile(r'^NaverBot.*'),
# re.compile(r'^EmailSiphon.*'),
# re.compile(r'^SiteSucker.*'),
# re.compile(r'^sohu-search'),
# ]
DISALLOWED_USER_AGENTS: List[Pattern] = ...
ABSOLUTE_URL_OVERRIDES: Dict[str, Callable[[Model], str]] = ...
# List of compiled regular expression objects representing URLs that need not
# be reported by BrokenLinkEmailsMiddleware. Here are a few examples:
# import re
# IGNORABLE_404_URLS = [
# re.compile(r'^/apple-touch-icon.*\.png$'),
# re.compile(r'^/favicon.ico$'),
# re.compile(r'^/robots.txt$'),
# re.compile(r'^/phpmyadmin/'),
# re.compile(r'\.(cgi|php|pl)$'),
# ]
IGNORABLE_404_URLS: List[Pattern] = ...
# A secret key for this particular Django installation. Used in secret-key
# hashing algorithms. Set this in your settings, or Django will complain
# loudly.
SECRET_KEY: str = ...
# Default file storage mechanism that holds media.
DEFAULT_FILE_STORAGE: str = ...
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT: str = ...
# URL that handles the media served from MEDIA_ROOT.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL: str = ...
# Absolute path to the directory static files should be collected to.
# Example: "/var/www/example.com/static/"
STATIC_ROOT: Optional[str] = ...
# URL that handles the static files served from STATIC_ROOT.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL: Optional[str] = ...
# List of upload handler classes to be applied in order.
FILE_UPLOAD_HANDLERS: List[str] = ...
# Maximum size, in bytes, of a request before it will be streamed to the
# file system instead of into memory.
FILE_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB
# Maximum size in bytes of request data (excluding file uploads) that will be
# read before a SuspiciousOperation (RequestDataTooBig) is raised.
DATA_UPLOAD_MAX_MEMORY_SIZE: int = ... # i.e. 2.5 MB
# Maximum number of GET/POST parameters that will be read before a
# SuspiciousOperation (TooManyFieldsSent) is raised.
DATA_UPLOAD_MAX_NUMBER_FIELDS: int = ...
# Directory in which upload streamed files will be temporarily saved. A value of
# `None` will make Django use the operating system's default temporary directory
# (i.e. "/tmp" on *nix systems).
FILE_UPLOAD_TEMP_DIR: Optional[str] = ...
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https://docs.python.org/library/os.html#files-and-directories.
FILE_UPLOAD_PERMISSIONS = None
# The numeric mode to assign to newly-created directories, when uploading files.
# The value should be a mode as you'd pass to os.chmod;
# see https://docs.python.org/library/os.html#files-and-directories.
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
# Python module path where user will place custom format definition.
# The directory where this setting is pointing should contain subdirectories
# named as the locales, containing a formats.py file
# (i.e. "myproject.locale" for myproject/locale/en/formats.py etc. use)
FORMAT_MODULE_PATH: Optional[str] = ...
# Default formatting for date objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT: str = ...
# Default formatting for datetime objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATETIME_FORMAT: str = ...
# Default formatting for time objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
TIME_FORMAT: str = ...
# Default formatting for date objects when only the year and month are relevant.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
YEAR_MONTH_FORMAT: str = ...
# Default formatting for date objects when only the month and day are relevant.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
MONTH_DAY_FORMAT: str = ...
# Default short formatting for date objects. See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
SHORT_DATE_FORMAT: str = ...
# Default short formatting for datetime objects.
# See all available format strings here:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
SHORT_DATETIME_FORMAT: str = ...
# Default formats to be used when parsing dates from input boxes, in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
DATE_INPUT_FORMATS: List[str] = ...
# Default formats to be used when parsing times from input boxes, in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
TIME_INPUT_FORMATS: List[str] = ... # '14:30:59' # '14:30:59.000200' # '14:30'
# Default formats to be used when parsing dates and times from input boxes,
# in order
# See all available format string here:
# https://docs.python.org/library/datetime.html#strftime-behavior
# * Note that these format strings are different from the ones to display dates
DATETIME_INPUT_FORMATS: List[str] = ...
# First day of week, to be used on calendars
# 0 means Sunday, 1 means Monday...
FIRST_DAY_OF_WEEK: int = ...
# Decimal separator symbol
DECIMAL_SEPARATOR: str = ...
# Boolean that sets whether to add thousand separator when formatting numbers
USE_THOUSAND_SEPARATOR: bool = ...
# Number of digits that will be together, when splitting them by
# THOUSAND_SEPARATOR. 0 means no grouping, 3 means splitting by thousands...
NUMBER_GROUPING: int = ...
# Thousand separator symbol
THOUSAND_SEPARATOR: str = ...
# The tablespaces to use for each model when not specified otherwise.
DEFAULT_TABLESPACE: str = ...
DEFAULT_INDEX_TABLESPACE: str = ...
# Default X-Frame-Options header value
X_FRAME_OPTIONS: str = ...
USE_X_FORWARDED_HOST: bool = ...
USE_X_FORWARDED_PORT: bool = ...
# The Python dotted path to the WSGI application that Django's internal server
# (runserver) will use. If `None`, the return value of
# 'django.core.wsgi.get_wsgi_application' is used, thus preserving the same
# behavior as previous versions of Django. Otherwise this should point to an
# actual WSGI application object.
WSGI_APPLICATION: Optional[str] = ...
# If your Django app is behind a proxy that sets a header to specify secure
# connections, AND that proxy ensures that user-submitted headers with the
# same name are ignored (so that people can't spoof it), set this value to
# a tuple of (header_name, header_value). For any requests that come in with
# that header/value, request.is_secure() will return True.
# WARNING! Only set this if you fully understand what you're doing. Otherwise,
# you may be opening yourself up to a security risk.
SECURE_PROXY_SSL_HEADER: Optional[Tuple[str, str]] = ...
##############
# MIDDLEWARE #
##############
# List of middleware to use. Order is important; in the request phase, these
# middleware will be applied in the order given, and in the response
# phase the middleware will be applied in reverse order.
MIDDLEWARE: List[str] = ...
############
# SESSIONS #
############
# Cache to store session data if using the cache session backend.
SESSION_CACHE_ALIAS = "default"
# Cookie name. This can be whatever you want.
SESSION_COOKIE_NAME = "sessionid"
# Age of cookie, in seconds (default: 2 weeks).
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
# A string like "example.com", or None for standard domain cookie.
SESSION_COOKIE_DOMAIN: Optional[str] = ...
# Whether the session cookie should be secure (https:// only).
SESSION_COOKIE_SECURE = False
# The path of the session cookie.
SESSION_COOKIE_PATH = "/"
# Whether to use the non-RFC standard httpOnly flag (IE, FF3+, others)
SESSION_COOKIE_HTTPONLY = True
# Whether to set the flag restricting cookie leaks on cross-site requests.
# This can be 'Lax', 'Strict', or None to disable the flag.
SESSION_COOKIE_SAMESITE = "Lax"
# Whether to save the session data on every request.
SESSION_SAVE_EVERY_REQUEST = False
# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
# The module to store session data
SESSION_ENGINE = "django.contrib.sessions.backends.db"
# Directory to store session files if using the file session module. If None,
# the backend will use a sensible default.
SESSION_FILE_PATH: Optional[str] = ...
# class to serialize session data
SESSION_SERIALIZER = "django.contrib.sessions.serializers.JSONSerializer"
#########
# CACHE #
#########
# The cache backends to use.
CACHES: Dict[str, Dict[str, Any]] = ...
CACHE_MIDDLEWARE_KEY_PREFIX = ""
CACHE_MIDDLEWARE_SECONDS = 600
CACHE_MIDDLEWARE_ALIAS = "default"
##################
# AUTHENTICATION #
##################
AUTH_USER_MODEL: str = ...
AUTHENTICATION_BACKENDS: Sequence[str] = ...
LOGIN_URL = "/accounts/login/"
LOGIN_REDIRECT_URL: str = ...
LOGOUT_REDIRECT_URL: Optional[str] = ...
# The number of days a password reset link is valid for
PASSWORD_RESET_TIMEOUT_DAYS = 3
# the first hasher in this list is the preferred algorithm. any
# password using different algorithms will be converted automatically
# upon login
PASSWORD_HASHERS: List[str] = ...
AUTH_PASSWORD_VALIDATORS: List[Dict[str, str]] = ...
###########
# SIGNING #
###########
SIGNING_BACKEND = "django.core.signing.TimestampSigner"
########
# CSRF #
########
# Dotted path to callable to be used as view when a request is
# rejected by the CSRF middleware.
CSRF_FAILURE_VIEW = "django.views.csrf.csrf_failure"
# Settings for CSRF cookie.
CSRF_COOKIE_NAME = "csrftoken"
CSRF_COOKIE_AGE = 60 * 60 * 24 * 7 * 52
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_PATH = "/"
CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_SAMESITE = "Lax"
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
CSRF_TRUSTED_ORIGINS: List[str] = ...
CSRF_USE_SESSIONS = False
############
# MESSAGES #
############
# Class to use as messages backend
MESSAGE_STORAGE = "django.contrib.messages.storage.fallback.FallbackStorage"
# Default values of MESSAGE_LEVEL and MESSAGE_TAGS are defined within
# django.contrib.messages to avoid imports in this settings file.
###########
# LOGGING #
###########
# The callable to use to configure logging
LOGGING_CONFIG = "logging.config.dictConfig"
# Custom logging configuration.
LOGGING: Dict[str, Any] = ...
# Default exception reporter filter class used in case none has been
# specifically assigned to the HttpRequest instance.
DEFAULT_EXCEPTION_REPORTER_FILTER = "django.views.debug.SafeExceptionReporterFilter"
###########
# TESTING #
###########
# The name of the class to use to run the test suite
TEST_RUNNER = "django.test.runner.DiscoverRunner"
# Apps that don't need to be serialized at test database creation time
# (only apps with migrations are to start with)
TEST_NON_SERIALIZED_APPS: List[str] = ...
############
# FIXTURES #
############
# The list of directories to search for fixtures
FIXTURE_DIRS: List[str] = ...
###############
# STATICFILES #
###############
# A list of locations of additional static files
STATICFILES_DIRS: List[str] = ...
# The default file storage backend used during the build process
STATICFILES_STORAGE: str = ...
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS: List[str] = ...
##############
# MIGRATIONS #
##############
# Migration module overrides for apps, by app label.
MIGRATION_MODULES: Dict[str, str] = ...
#################
# SYSTEM CHECKS #
#################
# List of all issues generated by system checks that should be silenced. Light
# issues like warnings, infos or debugs will not generate a message. Silencing
# serious issues like errors and criticals does not result in hiding the
# message, but Django will not stop you from e.g. running server.
SILENCED_SYSTEM_CHECKS: List[str] = ...
#######################
# SECURITY MIDDLEWARE #
#######################
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_REDIRECT_EXEMPT: List[str] = ...
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False

View File

@@ -1,20 +1,22 @@
# Stubs for django.conf.urls (Python 3.5)
from typing import Any, Callable, Dict, List, Optional, overload, Tuple, Union
from django.http.response import HttpResponse
from django.http.response import HttpResponse, HttpResponseBase
from django.urls import URLResolver, URLPattern
handler400 = ... # type: str
handler403 = ... # type: str
handler404 = ... # type: str
handler500 = ... # type: str
handler400: Callable[..., HttpResponse] = ...
handler403: Callable[..., HttpResponse] = ...
handler404: Callable[..., HttpResponse] = ...
handler500: Callable[..., HttpResponse] = ...
IncludedURLConf = Tuple[List[URLResolver], Optional[str], Optional[str]]
def include(arg: Any, namespace: str = ..., app_name: str = ...) -> IncludedURLConf: ...
@overload
def url(regex: str, view: Callable[..., HttpResponse], kwargs: Dict[str, Any] = ..., name: str = ...) -> URLPattern: ...
def url(
regex: str, view: Callable[..., HttpResponseBase], kwargs: Dict[str, Any] = ..., name: str = ...
) -> URLPattern: ...
@overload
def url(regex: str, view: IncludedURLConf, kwargs: Dict[str, Any] = ..., name: str = ...) -> URLResolver: ...
@overload

View File

@@ -1,5 +1,5 @@
from django.contrib.admin.decorators import register as register
from django.contrib.admin.filters import (
from .decorators import register as register
from .filters import (
AllValuesFieldListFilter as AllValuesFieldListFilter,
BooleanFieldListFilter as BooleanFieldListFilter,
ChoicesFieldListFilter as ChoicesFieldListFilter,
@@ -10,14 +10,15 @@ from django.contrib.admin.filters import (
RelatedOnlyFieldListFilter as RelatedOnlyFieldListFilter,
SimpleListFilter as SimpleListFilter,
)
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME as ACTION_CHECKBOX_NAME
from django.contrib.admin.options import (
from .helpers import ACTION_CHECKBOX_NAME as ACTION_CHECKBOX_NAME
from .options import (
HORIZONTAL as HORIZONTAL,
VERTICAL as VERTICAL,
ModelAdmin as ModelAdmin,
StackedInline as StackedInline,
TabularInline as TabularInline,
)
from django.contrib.admin.sites import AdminSite as AdminSite, site as site
from .sites import AdminSite as AdminSite, site as site
from . import checks as checks
def autodiscover() -> None: ...

View File

@@ -1,25 +1,6 @@
from typing import Any
from django.apps import AppConfig
class SimpleAdminConfig(AppConfig):
apps: None
label: str
models: None
models_module: None
module: Any
path: str
default_site: str = ...
name: str = ...
verbose_name: Any = ...
def ready(self) -> None: ...
class AdminConfig(SimpleAdminConfig):
apps: None
label: str
models: None
models_module: None
module: Any
name: str
path: str
def ready(self) -> None: ...
class AdminConfig(SimpleAdminConfig): ...

View File

@@ -1,19 +1,18 @@
from typing import Any, List
from typing import Any, List, Union
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin
from django.core.checks.messages import Error
def check_admin_app(app_configs: None, **kwargs: Any) -> List[str]: ...
def check_dependencies(**kwargs: Any) -> List[Error]: ...
_CheckError = Union[str, Error]
def check_admin_app(app_configs: None, **kwargs: Any) -> List[_CheckError]: ...
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
class BaseModelAdminChecks:
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[Error]: ...
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
class ModelAdminChecks(BaseModelAdminChecks):
def check(self, admin_obj: ModelAdmin, **kwargs: Any) -> List[Error]: ...
class InlineModelAdminChecks(BaseModelAdminChecks):
def check(self, inline_obj: InlineModelAdmin, **kwargs: Any) -> List[Any]: ...
class ModelAdminChecks(BaseModelAdminChecks): ...
class InlineModelAdminChecks(BaseModelAdminChecks): ...
def must_be(type: Any, option: Any, obj: Any, id: Any): ...
def must_inherit_from(parent: Any, option: Any, obj: Any, id: Any): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Iterator
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
@@ -16,7 +16,7 @@ class ListFilter:
self, request: WSGIRequest, params: Dict[str, str], model: Type[Model], model_admin: ModelAdmin
) -> None: ...
def has_output(self) -> bool: ...
def choices(self, changelist: Any) -> None: ...
def choices(self, changelist: Any) -> Optional[Iterator[Dict[str, Any]]]: ...
def queryset(self, request: Any, queryset: QuerySet) -> Optional[QuerySet]: ...
def expected_parameters(self) -> Optional[List[str]]: ...

View File

@@ -1,33 +1,7 @@
from typing import Any, Dict
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
from django.contrib.auth.models import User
class AdminAuthenticationForm(AuthenticationForm):
auto_id: str
data: Dict[str, str]
empty_permitted: bool
error_class: type
fields: Dict[Any, Any]
files: Dict[Any, Any]
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
request: None
user_cache: None
error_messages: Any = ...
required_css_class: str = ...
def confirm_login_allowed(self, user: User) -> None: ...
class AdminPasswordChangeForm(PasswordChangeForm):
auto_id: str
data: Dict[Any, Any]
empty_permitted: bool
error_class: type
fields: Dict[Any, Any]
files: Dict[Any, Any]
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
user: Any
required_css_class: str = ...

View File

@@ -1,27 +1,17 @@
import collections
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Type
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
from django import forms
from django.contrib.auth.forms import AdminPasswordChangeForm
from django.db.models.fields import AutoField
from django.forms.utils import ErrorDict, ErrorList
from django.forms.boundfield import BoundField
from django.forms.utils import ErrorDict
from django.forms.widgets import Media, Widget
from django.utils.safestring import SafeText
from django.forms.boundfield import BoundField
from django import forms
from django.db.models.fields import AutoField
ACTION_CHECKBOX_NAME: str
class ActionForm(forms.Form):
auto_id: None
data: Dict[Any, Any]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
action: Any = ...
select_across: Any = ...
@@ -36,8 +26,8 @@ class AdminForm:
form: AdminPasswordChangeForm,
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
prepopulated_fields: Dict[Any, Any],
readonly_fields: None = ...,
model_admin: None = ...,
readonly_fields: Any = ...,
model_admin: Any = ...,
) -> None: ...
def __iter__(self) -> Iterator[Fieldset]: ...
@property
@@ -137,7 +127,6 @@ class InlineAdminFormSet:
class InlineAdminForm(AdminForm):
formset: Any = ...
model_admin: Any = ...
original: Any = ...
show_url: Any = ...
absolute_url: Any = ...
@@ -152,7 +141,6 @@ class InlineAdminForm(AdminForm):
model_admin: Optional[Any] = ...,
view_on_site_url: Optional[Any] = ...,
) -> None: ...
def __iter__(self) -> Iterator[InlineFieldset]: ...
def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ...
def pk_field(self) -> AdminField: ...
def fk_field(self) -> AdminField: ...
@@ -162,9 +150,6 @@ class InlineAdminForm(AdminForm):
class InlineFieldset(Fieldset):
formset: Any = ...
def __init__(self, formset: Any, *args: Any, **kwargs: Any) -> None: ...
def __iter__(self) -> Iterator[Fieldline]: ...
class AdminErrorList(forms.utils.ErrorList):
data: List[Any]
error_class: str
def __init__(self, form: Any, inline_formsets: Any) -> None: ...

View File

@@ -1,20 +1,17 @@
import datetime
from typing import Any, Dict, List, Optional, Union
from typing import Any, Optional, Union
from uuid import UUID
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.db.models.base import Model
from django.db import models
ADDITION: int
CHANGE: int
DELETION: int
ACTION_FLAG_CHOICES: Any
class LogEntryManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
class LogEntryManager(models.Manager["LogEntry"]):
def log_action(
self,
user_id: int,
@@ -22,28 +19,18 @@ class LogEntryManager(models.Manager):
object_id: Union[int, str, UUID],
object_repr: str,
action_flag: int,
change_message: Union[
Dict[str, Dict[str, List[str]]], List[Dict[str, Dict[str, Union[List[str], str]]]], str
] = ...,
change_message: Any = ...,
) -> LogEntry: ...
class LogEntry(models.Model):
content_type_id: int
id: None
user_id: int
action_time: datetime.datetime = ...
user: Any = ...
content_type: Any = ...
object_id: str = ...
object_repr: str = ...
action_flag: int = ...
change_message: str = ...
objects: Any = ...
class Meta:
verbose_name: Any = ...
verbose_name_plural: Any = ...
db_table: str = ...
ordering: Any = ...
action_time: models.DateTimeField = ...
user: models.ForeignKey = ...
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id: models.TextField = ...
object_repr: models.CharField = ...
action_flag: models.PositiveSmallIntegerField = ...
change_message: models.TextField = ...
objects: LogEntryManager = ...
def is_addition(self) -> bool: ...
def is_change(self) -> bool: ...
def is_deletion(self) -> bool: ...

View File

@@ -1,28 +1,28 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
from django.contrib.admin.filters import SimpleListFilter
from django.contrib.admin.filters import ListFilter
from django.contrib.admin.models import LogEntry
from django.contrib.admin.sites import AdminSite
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.forms import AdminPasswordChangeForm
from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import Error
from django.core.handlers.wsgi import WSGIRequest
from django.core.paginator import Paginator
from django.db.models.base import Model
from django.forms.fields import TypedChoiceField
from django.db.models.fields import Field
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
from django.db.models.options import Options
from django.db.models.query import QuerySet
from django.forms.fields import TypedChoiceField
from django.forms.models import ModelChoiceField, ModelMultipleChoiceField
from django.forms.widgets import Media
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBase, HttpResponseRedirect, JsonResponse
from django.template.response import TemplateResponse
from django.urls.resolvers import URLPattern
from django.utils.safestring import SafeText
from django.db.models.options import Options
from django.db.models.fields import Field
IS_POPUP_VAR: str
TO_FIELD_VAR: str
@@ -55,60 +55,61 @@ class BaseModelAdmin:
view_on_site: bool = ...
show_full_result_count: bool = ...
checks_class: Any = ...
def check(self, **kwargs: Any) -> List[Error]: ...
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
def __init__(self) -> None: ...
def formfield_for_dbfield(self, db_field: Field, request: WSGIRequest, **kwargs: Any) -> Optional[Field]: ...
def formfield_for_choice_field(self, db_field: Field, request: WSGIRequest, **kwargs: Any) -> TypedChoiceField: ...
def get_field_queryset(self, db: None, db_field: RelatedField, request: WSGIRequest) -> Optional[QuerySet]: ...
def formfield_for_dbfield(
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
) -> Optional[Field]: ...
def formfield_for_choice_field(
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
) -> TypedChoiceField: ...
def get_field_queryset(
self, db: None, db_field: RelatedField, request: Optional[HttpRequest]
) -> Optional[QuerySet]: ...
def formfield_for_foreignkey(
self, db_field: ForeignKey, request: WSGIRequest, **kwargs: Any
self, db_field: ForeignKey, request: Optional[HttpRequest], **kwargs: Any
) -> Optional[ModelChoiceField]: ...
def formfield_for_manytomany(
self, db_field: ManyToManyField, request: WSGIRequest, **kwargs: Any
self, db_field: ManyToManyField, request: Optional[HttpRequest], **kwargs: Any
) -> ModelMultipleChoiceField: ...
def get_autocomplete_fields(self, request: WSGIRequest) -> Tuple: ...
def get_autocomplete_fields(self, request: HttpRequest) -> Tuple: ...
def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ...
def get_empty_value_display(self) -> SafeText: ...
def get_exclude(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
def get_fields(
self, request: WSGIRequest, obj: Optional[Model] = ...
) -> Union[List[Union[Callable, str]], Tuple[str, str]]: ...
def get_exclude(self, request: HttpRequest, obj: Optional[Model] = ...) -> Any: ...
def get_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Sequence[Union[Callable, str]]: ...
def get_fieldsets(
self, request: WSGIRequest, obj: Optional[Model] = ...
) -> Union[
List[Tuple[None, Dict[str, List[Union[Callable, str]]]]],
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
]: ...
def get_ordering(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
def get_readonly_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Union[List[str], Tuple]: ...
def get_prepopulated_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
def get_sortable_by(self, request: WSGIRequest) -> Union[List[Callable], List[str], Tuple]: ...
self, request: HttpRequest, obj: Optional[Model] = ...
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
def get_ordering(self, request: HttpRequest) -> Union[List[str], Tuple]: ...
def get_readonly_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Union[List[str], Tuple]: ...
def get_prepopulated_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
def get_queryset(self, request: HttpRequest) -> QuerySet: ...
def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ...
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
def to_field_allowed(self, request: WSGIRequest, to_field: str) -> bool: ...
def has_add_permission(self, request: WSGIRequest) -> bool: ...
def has_change_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_delete_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_view_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_module_permission(self, request: WSGIRequest) -> 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_change_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_module_permission(self, request: HttpRequest) -> bool: ...
class ModelAdmin(BaseModelAdmin):
formfield_overrides: Any
list_display: Any = ...
list_display_links: Any = ...
list_filter: Any = ...
list_select_related: bool = ...
list_display: Sequence[Union[str, Callable]] = ...
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
list_select_related: Union[bool, Sequence[str]] = ...
list_per_page: int = ...
list_max_show_all: int = ...
list_editable: Any = ...
search_fields: Any = ...
date_hierarchy: Any = ...
list_editable: Sequence[str] = ...
search_fields: Sequence[str] = ...
date_hierarchy: Optional[Any] = ...
save_as: bool = ...
save_as_continue: bool = ...
save_on_top: bool = ...
paginator: Any = ...
preserve_filters: bool = ...
inlines: Any = ...
inlines: Sequence[Type[InlineModelAdmin]] = ...
add_form_template: Any = ...
change_form_template: Any = ...
change_list_template: Any = ...
@@ -126,64 +127,54 @@ class ModelAdmin(BaseModelAdmin):
opts: Options = ...
admin_site: AdminSite = ...
def __init__(self, model: Type[Model], admin_site: Optional[AdminSite]) -> None: ...
def get_inline_instances(self, request: WSGIRequest, obj: Optional[Model] = ...) -> List[InlineModelAdmin]: ...
def get_inline_instances(self, request: HttpRequest, obj: Optional[Model] = ...) -> List[InlineModelAdmin]: ...
def get_urls(self) -> List[URLPattern]: ...
@property
def urls(self) -> List[URLPattern]: ...
@property
def media(self) -> Media: ...
def get_model_perms(self, request: WSGIRequest) -> Dict[str, bool]: ...
def get_model_perms(self, request: HttpRequest) -> Dict[str, bool]: ...
def get_form(self, request: Any, obj: Optional[Any] = ..., change: bool = ..., **kwargs: Any): ...
def get_changelist(self, request: WSGIRequest, **kwargs: Any) -> Type[ChangeList]: ...
def get_changelist_instance(self, request: WSGIRequest) -> ChangeList: ...
def get_object(self, request: WSGIRequest, object_id: str, from_field: None = ...) -> Optional[Model]: ...
def get_changelist(self, request: HttpRequest, **kwargs: Any) -> Type[ChangeList]: ...
def get_changelist_instance(self, request: HttpRequest) -> ChangeList: ...
def get_object(self, request: HttpRequest, object_id: str, from_field: None = ...) -> Optional[Model]: ...
def get_changelist_form(self, request: Any, **kwargs: Any): ...
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
def get_formsets_with_inlines(self, request: WSGIRequest, obj: Optional[Model] = ...) -> None: ...
def get_formsets_with_inlines(self, request: HttpRequest, obj: Optional[Model] = ...) -> Iterator[Any]: ...
def get_paginator(
self,
request: WSGIRequest,
request: HttpRequest,
queryset: QuerySet,
per_page: int,
orphans: int = ...,
allow_empty_first_page: bool = ...,
) -> Paginator: ...
def log_addition(
self,
request: WSGIRequest,
object: Model,
message: Union[Dict[str, Dict[Any, Any]], List[Dict[str, Dict[str, str]]]],
) -> LogEntry: ...
def log_change(
self,
request: WSGIRequest,
object: Model,
message: Union[Dict[str, Dict[str, List[str]]], List[Dict[str, Dict[str, Union[List[str], str]]]]],
) -> LogEntry: ...
def log_deletion(self, request: WSGIRequest, object: Model, object_repr: str) -> LogEntry: ...
def log_addition(self, request: HttpRequest, object: Model, message: Any) -> LogEntry: ...
def log_change(self, request: HttpRequest, object: Model, message: Any) -> LogEntry: ...
def log_deletion(self, request: HttpRequest, object: Model, object_repr: str) -> LogEntry: ...
def action_checkbox(self, obj: Model) -> SafeText: ...
def get_actions(self, request: WSGIRequest) -> OrderedDict: ...
def get_actions(self, request: HttpRequest) -> OrderedDict: ...
def get_action_choices(
self, request: WSGIRequest, default_choices: List[Tuple[str, str]] = ...
self, request: HttpRequest, default_choices: List[Tuple[str, str]] = ...
) -> List[Tuple[str, str]]: ...
def get_action(self, action: Union[Callable, str]) -> Tuple[Callable, str, str]: ...
def get_list_display(self, request: WSGIRequest) -> Union[List[Callable], List[str], Tuple[str]]: ...
def get_list_display_links(
self, request: WSGIRequest, list_display: Union[List[Callable], List[str], Tuple[str]]
) -> Optional[Union[List[Callable], List[str], Tuple[str]]]: ...
def get_list_filter(self, request: WSGIRequest) -> Union[List[Type[SimpleListFilter]], List[str], Tuple]: ...
def get_list_select_related(self, request: WSGIRequest) -> Union[Tuple, bool]: ...
def get_search_fields(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
def get_list_display(self, request: HttpRequest) -> Sequence[str]: ...
def get_list_display_links(self, request: HttpRequest, list_display: Sequence[str]) -> Optional[Sequence[str]]: ...
def get_list_filter(self, request: HttpRequest) -> Sequence[str]: ...
def get_list_select_related(self, request: HttpRequest) -> Sequence[str]: ...
def get_search_fields(self, request: HttpRequest) -> List[str]: ...
def get_search_results(
self, request: WSGIRequest, queryset: QuerySet, search_term: str
self, request: HttpRequest, queryset: QuerySet, search_term: str
) -> Tuple[QuerySet, bool]: ...
def get_preserved_filters(self, request: WSGIRequest) -> str: ...
def get_preserved_filters(self, request: HttpRequest) -> str: ...
def _get_edited_object_pks(self, request: HttpRequest, prefix: str) -> List[str]: ...
def _get_list_editable_queryset(self, request: HttpRequest, prefix: str) -> QuerySet: ...
def construct_change_message(
self, request: WSGIRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ...
self, request: HttpRequest, form: AdminPasswordChangeForm, formsets: None, add: bool = ...
) -> List[Dict[str, Dict[str, List[str]]]]: ...
def message_user(
self,
request: WSGIRequest,
request: HttpRequest,
message: str,
level: Union[int, str] = ...,
extra_tags: str = ...,
@@ -191,8 +182,8 @@ class ModelAdmin(BaseModelAdmin):
) -> None: ...
def save_form(self, request: Any, form: Any, change: Any): ...
def save_model(self, request: Any, obj: Any, form: Any, change: Any) -> None: ...
def delete_model(self, request: WSGIRequest, obj: Model) -> None: ...
def delete_queryset(self, request: WSGIRequest, queryset: QuerySet) -> None: ...
def delete_model(self, request: HttpRequest, obj: Model) -> None: ...
def delete_queryset(self, request: HttpRequest, queryset: QuerySet) -> None: ...
def save_formset(self, request: Any, form: Any, formset: Any, change: Any) -> None: ...
def save_related(self, request: Any, form: Any, formsets: Any, change: Any) -> None: ...
def render_change_form(
@@ -204,51 +195,52 @@ class ModelAdmin(BaseModelAdmin):
form_url: str = ...,
obj: Optional[Any] = ...,
): ...
def response_add(self, request: WSGIRequest, obj: Model, post_url_continue: None = ...) -> HttpResponse: ...
def response_change(self, request: WSGIRequest, obj: Model) -> HttpResponse: ...
def response_post_save_add(self, request: WSGIRequest, obj: Model) -> HttpResponseRedirect: ...
def response_post_save_change(self, request: WSGIRequest, obj: Model) -> HttpResponseRedirect: ...
def response_action(self, request: WSGIRequest, queryset: QuerySet) -> Optional[HttpResponseBase]: ...
def response_delete(self, request: WSGIRequest, obj_display: str, obj_id: int) -> HttpResponse: ...
def response_add(
self, request: HttpRequest, obj: Model, post_url_continue: Optional[str] = ...
) -> HttpResponse: ...
def response_change(self, request: HttpRequest, obj: Model) -> HttpResponse: ...
def response_post_save_add(self, request: HttpRequest, obj: Model) -> HttpResponseRedirect: ...
def response_post_save_change(self, request: HttpRequest, obj: Model) -> HttpResponseRedirect: ...
def response_action(self, request: HttpRequest, queryset: QuerySet) -> Optional[HttpResponseBase]: ...
def response_delete(self, request: HttpRequest, obj_display: str, obj_id: int) -> HttpResponse: ...
def render_delete_form(self, request: Any, context: Any): ...
def get_inline_formsets(
self, request: WSGIRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[Model] = ...
self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[Model] = ...
) -> List[Any]: ...
def get_changeform_initial_data(self, request: WSGIRequest) -> Dict[str, str]: ...
def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, str]: ...
def changeform_view(
self,
request: WSGIRequest,
request: HttpRequest,
object_id: Optional[str] = ...,
form_url: str = ...,
extra_context: Optional[Dict[str, bool]] = ...,
) -> Any: ...
def autocomplete_view(self, request: WSGIRequest) -> JsonResponse: ...
def add_view(self, request: WSGIRequest, form_url: str = ..., extra_context: None = ...) -> HttpResponse: ...
def autocomplete_view(self, request: HttpRequest) -> JsonResponse: ...
def add_view(self, request: HttpRequest, form_url: str = ..., extra_context: None = ...) -> HttpResponse: ...
def change_view(
self, request: WSGIRequest, object_id: str, form_url: str = ..., extra_context: Optional[Dict[str, bool]] = ...
self, request: HttpRequest, object_id: str, form_url: str = ..., extra_context: Optional[Dict[str, bool]] = ...
) -> HttpResponse: ...
def changelist_view(
self, request: WSGIRequest, extra_context: Optional[Dict[str, str]] = ...
) -> HttpResponseBase: ...
self, request: HttpRequest, extra_context: Optional[Dict[str, str]] = ...
) -> TemplateResponse: ...
def get_deleted_objects(
self, objs: QuerySet, request: WSGIRequest
self, objs: QuerySet, request: HttpRequest
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
def delete_view(self, request: WSGIRequest, object_id: str, extra_context: None = ...) -> Any: ...
def history_view(self, request: WSGIRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ...
def delete_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> Any: ...
def history_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ...
class InlineModelAdmin(BaseModelAdmin):
model: Any = ...
fk_name: Any = ...
formset: Any = ...
extra: int = ...
min_num: Any = ...
max_num: Any = ...
template: Any = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
min_num: Optional[int] = ...
max_num: Optional[int] = ...
template: str = ...
verbose_name: Optional[str] = ...
verbose_name_plural: Optional[str] = ...
can_delete: bool = ...
show_change_link: bool = ...
checks_class: Any = ...
classes: Any = ...
admin_site: Any = ...
parent_model: Any = ...
@@ -257,18 +249,10 @@ class InlineModelAdmin(BaseModelAdmin):
def __init__(self, parent_model: Union[Type[Model], Model], admin_site: AdminSite) -> None: ...
@property
def media(self) -> Media: ...
def get_extra(self, request: WSGIRequest, obj: Optional[Model] = ..., **kwargs: Any) -> int: ...
def get_min_num(self, request: WSGIRequest, obj: Optional[Model] = ..., **kwargs: Any) -> None: ...
def get_max_num(self, request: WSGIRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
fields: Any = ...
def get_extra(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> int: ...
def get_min_num(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
def get_max_num(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
def get_formset(self, request: Any, obj: Optional[Any] = ..., **kwargs: Any): ...
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
def has_change_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_delete_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
def has_view_permission(self, request: WSGIRequest, obj: Optional[Model] = ...) -> bool: ...
class StackedInline(InlineModelAdmin):
template: str = ...
class TabularInline(InlineModelAdmin):
template: str = ...
class StackedInline(InlineModelAdmin): ...
class TabularInline(InlineModelAdmin): ...

View File

@@ -26,8 +26,9 @@ class AdminSite:
password_change_template: Any = ...
password_change_done_template: Any = ...
name: str = ...
_registry: Dict[Type[Model], ModelAdmin]
def __init__(self, name: str = ...) -> None: ...
def check(self, app_configs: None) -> List[str]: ...
def check(self, app_configs: None) -> List[Any]: ...
def register(
self,
model_or_iterable: Union[List[Type[Model]], Tuple[Type[Model]], Type[Model]],
@@ -47,9 +48,9 @@ class AdminSite:
def empty_value_display(self, empty_value_display: Any) -> None: ...
def has_permission(self, request: WSGIRequest) -> bool: ...
def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ...
def get_urls(self) -> List[Union[URLPattern, URLResolver]]: ...
def get_urls(self) -> List[URLResolver]: ...
@property
def urls(self) -> Tuple[List[Union[URLPattern, URLResolver]], str, str]: ...
def urls(self) -> Tuple[List[URLResolver], str, str]: ...
def each_context(self, request: Any): ...
def password_change(self, request: WSGIRequest, extra_context: Dict[str, str] = ...) -> TemplateResponse: ...
def password_change_done(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Iterator, List, Optional, Union
from typing import Any, Dict, Iterator, List, Optional, Union, Iterable
from django.contrib.admin.filters import FieldListFilter
from django.contrib.admin.templatetags.base import InclusionAdminNode
@@ -15,7 +15,7 @@ register: Any
DOT: str
def paginator_number(cl: ChangeList, i: int) -> SafeText: ...
def pagination(cl: ChangeList) -> Dict[str, Union[List[Union[int, str]], ChangeList, int, range, str]]: ...
def pagination(cl: ChangeList) -> Dict[str, Iterable[Any]]: ...
def pagination_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def result_headers(cl: ChangeList) -> Iterator[Dict[str, Optional[Union[int, str]]]]: ...
def items_for_result(cl: ChangeList, result: Model, form: None) -> Iterator[SafeText]: ...
@@ -32,7 +32,7 @@ def result_list(
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
]: ...
def result_list_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Union[Dict[str, str], List[Dict[str, str]], bool]]]: ...
def date_hierarchy(cl: ChangeList) -> Optional[Dict[str, Any]]: ...
def date_hierarchy_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...
def search_form(cl: ChangeList) -> Dict[str, Union[bool, ChangeList, str]]: ...
def search_form_tag(parser: Parser, token: Token) -> InclusionAdminNode: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Optional
from typing import Any, Callable, Dict, List
from django.template.base import Parser, Token
from django.template.context import Context

View File

@@ -1,5 +1,6 @@
import collections
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
from uuid import UUID
from django.contrib.admin.options import BaseModelAdmin
@@ -8,28 +9,23 @@ from django.contrib.auth.forms import AdminPasswordChangeForm
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.deletion import Collector
from django.db.models.fields import Field
from django.db.models.fields.mixins import FieldCacheMixin
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel, OneToOneRel
from django.db.models.fields.reverse_related import ManyToOneRel
from django.db.models.options import Options
from django.db.models.query import QuerySet
from django.forms.forms import BaseForm
from django.utils.safestring import SafeText
from django.db.models.fields import Field, reverse_related
class FieldIsAForeignKeyColumnName(Exception): ...
def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ...
def prepare_lookup_value(key: str, value: Union[datetime, str]) -> Union[bool, datetime, str]: ...
def quote(s: Union[int, str, UUID]) -> Union[int, str, UUID]: ...
def quote(s: Union[int, str, UUID]) -> str: ...
def unquote(s: str) -> str: ...
def flatten(
fields: Union[List[Union[Callable, str]], List[Union[List[str], str]], List[Union[Tuple[str, str], str]], Tuple]
) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(
fieldsets: Union[
List[Tuple[Optional[str], Dict[str, Tuple[str]]]],
Tuple[Tuple[Optional[str], Dict[str, Tuple[Union[Tuple[str, str], str]]]]],
]
) -> List[Union[Callable, str]]: ...
def flatten(fields: Any) -> List[Union[Callable, str]]: ...
def flatten_fieldsets(fieldsets: Any) -> List[Union[Callable, str]]: ...
def get_deleted_objects(
objs: QuerySet, request: WSGIRequest, admin_site: AdminSite
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
@@ -47,7 +43,7 @@ class NestedObjects(Collector):
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
def collect(
self,
objs: Union[List[Model], QuerySet],
objs: Union[Sequence[Optional[Model]], QuerySet],
source: Optional[Type[Model]] = ...,
source_attr: Optional[str] = ...,
**kwargs: Any
@@ -62,7 +58,11 @@ def lookup_field(
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
) -> Tuple[Optional[Field], Callable, Callable]: ...
def label_for_field(
name: Union[Callable, str], model: Type[Model], model_admin: Optional[BaseModelAdmin] = ..., return_attr: bool = ...
name: Union[Callable, str],
model: Type[Model],
model_admin: Optional[BaseModelAdmin] = ...,
return_attr: bool = ...,
form: Optional[BaseForm] = ...,
) -> Union[Tuple[Optional[str], Union[Callable, Type[str]]], str]: ...
def help_text_for_field(name: str, model: Type[Model]) -> str: ...
def display_for_field(

View File

@@ -1,18 +1,10 @@
from typing import Any, Optional
from typing import Any
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.core.paginator import Paginator
from django.db.models.query import QuerySet
from django.http.response import JsonResponse
from django.views.generic.list import BaseListView
class AutocompleteJsonView(BaseListView):
paginate_by: int = ...
model_admin: ModelAdmin = ...
term: Any = ...
paginator_class: Any = ...
object_list: Any = ...
def get(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> JsonResponse: ...
def get_paginator(self, *args: Any, **kwargs: Any) -> Paginator: ...
def get_queryset(self) -> QuerySet: ...
def has_perm(self, request: WSGIRequest, obj: None = ...) -> bool: ...

View File

@@ -9,6 +9,7 @@ from django.db.models.expressions import Combinable, CombinedExpression, OrderBy
from django.db.models.query import QuerySet
from django.db.models.options import Options
from django.forms.formsets import BaseFormSet
ALL_VAR: str
ORDER_VAR: str
@@ -44,6 +45,7 @@ class ChangeList:
queryset: Any = ...
title: Any = ...
pk_attname: Any = ...
formset: Optional[BaseFormSet]
def __init__(
self,
request: WSGIRequest,

View File

@@ -1,16 +1,12 @@
from collections import OrderedDict
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
from typing import Any, Dict, List, Optional, Set, Tuple, Union
from uuid import UUID
from django import forms
from django.contrib.admin.sites import AdminSite
from django.db.models.fields.reverse_related import ForeignObjectRel
from django.db.models.query_utils import Q
from django.forms.fields import Field
from django.forms.widgets import ChoiceWidget, Media, Widget
from django.http.request import QueryDict
from django.utils.datastructures import MultiValueDict
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel
from django.forms.models import ModelChoiceIterator
from django.forms.widgets import ChoiceWidget, Media
from django import forms
class FilteredSelectMultiple(forms.SelectMultiple):
@property
@@ -18,112 +14,37 @@ class FilteredSelectMultiple(forms.SelectMultiple):
verbose_name: Any = ...
is_stacked: Any = ...
def __init__(self, verbose_name: str, is_stacked: bool, attrs: None = ..., choices: Tuple = ...) -> None: ...
def get_context(
self, name: str, value: Union[List[Any], str], attrs: Optional[Dict[str, str]]
) -> Dict[
str,
Union[
Dict[
str,
Union[
Dict[str, Union[int, str]],
List[Tuple[None, List[Dict[str, Union[Dict[Any, Any], int, str]]], int]],
bool,
str,
],
],
Dict[str, Union[Dict[str, Union[int, str]], List[str], bool, str]],
],
]: ...
class AdminDateWidget(forms.DateInput):
attrs: Dict[str, str]
input_type: str
@property
def media(self) -> Media: ...
def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ...
class AdminTimeWidget(forms.TimeInput):
attrs: Dict[str, str]
input_type: str
@property
def media(self) -> Media: ...
def __init__(self, attrs: Optional[Dict[str, Union[int, str]]] = ..., format: None = ...) -> None: ...
class AdminSplitDateTime(forms.SplitDateTimeWidget):
attrs: Dict[Any, Any]
widgets: List[DateTimeBaseInput]
template_name: str = ...
def __init__(self, attrs: None = ...) -> None: ...
def get_context(
self, name: str, value: Optional[Union[List[str], datetime]], attrs: Optional[Dict[str, Union[bool, str]]]
) -> Dict[
str,
Union[
Dict[
str,
Optional[
Union[
Dict[str, Union[bool, str]],
List[Dict[str, Optional[Union[Dict[str, Union[bool, str]], bool, str]]]],
bool,
str,
]
],
],
str,
],
]: ...
class AdminSplitDateTime(forms.SplitDateTimeWidget): ...
class AdminRadioSelect(forms.RadioSelect): ...
class AdminFileWidget(forms.ClearableFileInput): ...
class AdminRadioSelect(forms.RadioSelect):
attrs: Dict[str, str]
template_name: str = ...
class AdminFileWidget(forms.ClearableFileInput):
attrs: Dict[Any, Any]
template_name: str = ...
def url_params_from_lookup_dict(
lookups: Union[
Dict[str, Callable], Dict[str, List[str]], Dict[str, Tuple[str, str]], Dict[str, bool], Dict[str, str], Q
]
) -> Dict[str, str]: ...
def url_params_from_lookup_dict(lookups: Any) -> Dict[str, str]: ...
class ForeignKeyRawIdWidget(forms.TextInput):
attrs: Dict[Any, Any]
template_name: str = ...
rel: django.db.models.fields.reverse_related.ManyToOneRel = ...
rel: ManyToOneRel = ...
admin_site: AdminSite = ...
db: None = ...
def __init__(self, rel: ForeignObjectRel, admin_site: AdminSite, attrs: None = ..., using: None = ...) -> None: ...
def get_context(
self, name: str, value: Optional[Union[List[int], int, str, UUID]], attrs: Optional[Dict[str, Union[bool, str]]]
) -> Dict[str, Union[Dict[str, Optional[Union[Dict[str, Union[bool, str]], bool, str]]], str]]: ...
def base_url_parameters(self) -> Dict[str, str]: ...
def url_parameters(self) -> Dict[str, str]: ...
def label_and_url_for_value(self, value: Union[int, str, UUID]) -> Tuple[str, str]: ...
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
admin_site: AdminSite
attrs: Dict[Any, Any]
db: None
rel: django.db.models.fields.reverse_related.ManyToManyRel
template_name: str = ...
def get_context(
self, name: str, value: Optional[List[int]], attrs: Optional[Dict[str, str]]
) -> Dict[str, Union[Dict[str, Union[Dict[str, str], bool, str]], str]]: ...
def url_parameters(self) -> Dict[Any, Any]: ...
def label_and_url_for_value(self, value: List[int]) -> Tuple[str, str]: ...
def value_from_datadict(self, data: QueryDict, files: MultiValueDict, name: str) -> None: ...
def format_value(self, value: Optional[List[int]]) -> str: ...
class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): ...
class RelatedFieldWidgetWrapper(forms.Widget):
template_name: str = ...
needs_multipart_form: bool = ...
attrs: Dict[Any, Any] = ...
choices: ModelChoiceIterator = ...
widget: django.contrib.admin.widgets.AutocompleteSelect = ...
rel: django.db.models.fields.reverse_related.ManyToOneRel = ...
widget: AutocompleteSelect = ...
rel: ManyToOneRel = ...
can_add_related: bool = ...
can_change_related: bool = ...
can_delete_related: bool = ...
@@ -139,54 +60,19 @@ class RelatedFieldWidgetWrapper(forms.Widget):
can_delete_related: bool = ...,
can_view_related: bool = ...,
) -> None: ...
def __deepcopy__(
self, memo: Dict[int, Union[List[Union[Field, Widget]], OrderedDict, Field, Widget]]
) -> RelatedFieldWidgetWrapper: ...
@property
def is_hidden(self) -> bool: ...
@property
def media(self) -> Media: ...
def get_related_url(self, info: Tuple[str, str], action: str, *args: Any) -> str: ...
def get_context(
self, name: str, value: Optional[Union[int, str]], attrs: Optional[Dict[str, Union[bool, str]]]
) -> Dict[str, Union[bool, str]]: ...
def value_from_datadict(
self, data: QueryDict, files: MultiValueDict, name: str
) -> Optional[Union[List[str], str]]: ...
def value_omitted_from_data(self, data: Dict[Any, Any], files: Dict[Any, Any], name: str) -> bool: ...
def id_for_label(self, id_: str) -> str: ...
class AdminTextareaWidget(forms.Textarea):
attrs: Dict[str, str]
def __init__(self, attrs: None = ...) -> None: ...
class AdminTextInputWidget(forms.TextInput):
attrs: Dict[str, str]
input_type: str
def __init__(self, attrs: None = ...) -> None: ...
class AdminEmailInputWidget(forms.EmailInput):
attrs: Dict[str, str]
input_type: str
def __init__(self, attrs: None = ...) -> None: ...
class AdminURLFieldWidget(forms.URLInput):
attrs: Dict[str, str]
input_type: str
template_name: str = ...
def __init__(self, attrs: None = ...) -> None: ...
def get_context(
self, name: str, value: Optional[str], attrs: Optional[Dict[str, str]]
) -> Dict[str, Union[Dict[str, Optional[Union[Dict[str, str], bool, str]]], str]]: ...
class AdminTextareaWidget(forms.Textarea): ...
class AdminTextInputWidget(forms.TextInput): ...
class AdminEmailInputWidget(forms.EmailInput): ...
class AdminURLFieldWidget(forms.URLInput): ...
class AdminIntegerFieldWidget(forms.NumberInput):
attrs: Dict[str, str]
input_type: str
class_name: str = ...
def __init__(self, attrs: None = ...) -> None: ...
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget):
class_name: str = ...
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget): ...
SELECT2_TRANSLATIONS: Any
@@ -206,12 +92,6 @@ class AutocompleteMixin:
using: None = ...,
) -> None: ...
def get_url(self) -> str: ...
def build_attrs(
self, base_attrs: Dict[str, str], extra_attrs: Optional[Dict[str, Union[bool, str]]] = ...
) -> Dict[str, Union[bool, str]]: ...
def optgroups(
self, name: str, value: List[str], attr: Dict[str, Union[bool, str]] = ...
) -> List[Tuple[None, List[Dict[str, Union[Dict[str, bool], Set[str], int, str]]], int]]: ...
@property
def media(self) -> Media: ...

View File

@@ -8,7 +8,11 @@ from django.db.models.base import Model
from django.db.models.options import Options
from django.http.request import HttpRequest
from .signals import user_logged_in, user_logged_out, user_login_failed
from .signals import (
user_logged_in as user_logged_in,
user_logged_out as user_logged_out,
user_login_failed as user_login_failed,
)
SESSION_KEY: str
BACKEND_SESSION_KEY: str

View File

@@ -1,54 +1,18 @@
from typing import Any, Dict, List, Optional, Tuple, Type
from typing import Any
from django.contrib.auth.models import User, Group
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.fields.related import ManyToManyField
from django.forms.models import ModelMultipleChoiceField
from django.http.response import HttpResponse
from django.urls.resolvers import URLPattern
from django.contrib import admin
from django.contrib.admin.sites import AdminSite
csrf_protect_m: Any
sensitive_post_parameters_m: Any
class GroupAdmin(admin.ModelAdmin):
admin_site: AdminSite
formfield_overrides: Any
model: Type[Group]
opts: Options
search_fields: Any = ...
ordering: Any = ...
filter_horizontal: Any = ...
def formfield_for_manytomany(
self, db_field: ManyToManyField, request: WSGIRequest = ..., **kwargs: Any
) -> ModelMultipleChoiceField: ...
class GroupAdmin(admin.ModelAdmin): ...
class UserAdmin(admin.ModelAdmin):
admin_site: AdminSite
formfield_overrides: Dict[
Type[Union[django.db.models.fields.DateTimeCheckMixin, Field]],
Dict[str, Type[Union[django.forms.fields.SplitDateTimeField, Widget]]],
]
model: Type[User]
opts: Options
add_form_template: str = ...
change_user_password_template: Any = ...
fieldsets: Any = ...
add_fieldsets: Any = ...
form: Any = ...
add_form: Any = ...
change_password_form: Any = ...
list_display: Any = ...
list_filter: Any = ...
search_fields: Any = ...
ordering: Any = ...
filter_horizontal: Any = ...
def get_fieldsets(self, request: WSGIRequest, obj: None = ...) -> Tuple[Tuple[None, Dict[str, Tuple[str]]]]: ...
def get_form(self, request: Any, obj: Optional[Any] = ..., **kwargs: Any): ...
def get_urls(self) -> List[URLPattern]: ...
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
def add_view(self, request: WSGIRequest, form_url: str = ..., extra_context: None = ...) -> Any: ...
def user_change_password(self, request: WSGIRequest, id: str, form_url: str = ...) -> HttpResponse: ...
def response_add(self, request: WSGIRequest, obj: User, post_url_continue: None = ...) -> HttpResponse: ...

View File

@@ -1,18 +1,3 @@
from typing import Any, Optional
from django.apps import AppConfig
from .checks import check_models_permissions, check_user_model
from .management import create_permissions
from .signals import user_logged_in
class AuthConfig(AppConfig):
apps: None
label: str
models: None
models_module: None
module: Any
path: str
name: str = ...
verbose_name: Any = ...
def ready(self) -> None: ...
class AuthConfig(AppConfig): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional, Tuple, List
from typing import Any, Optional, Tuple, List, overload
from django.db import models
@@ -11,10 +11,9 @@ class BaseUserManager(models.Manager):
class AbstractBaseUser(models.Model):
password: models.CharField = ...
last_login: Optional[models.DateTimeField] = ...
is_active: bool = ...
is_active: models.BooleanField = ...
REQUIRED_FIELDS: List[str] = ...
class Meta:
abstract: bool = ...
class Meta: ...
def get_username(self) -> str: ...
def clean(self) -> None: ...
def save(self, *args: Any, **kwargs: Any) -> None: ...
@@ -31,4 +30,8 @@ class AbstractBaseUser(models.Model):
@classmethod
def get_email_field_name(cls) -> str: ...
@classmethod
@overload
def normalize_username(cls, username: str) -> str: ...
@classmethod
@overload
def normalize_username(cls, username: Any) -> Any: ...

View File

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

View File

@@ -1,22 +1,20 @@
from typing import Any, Dict, Optional, Union
from typing import Any, Dict
from django.contrib.auth.models import AnonymousUser, User
from django.http.request import HttpRequest
from django.utils.functional import SimpleLazyObject
class PermLookupDict:
app_label: django.utils.safestring.SafeText
user: SimpleLazyObject
def __init__(self, user: SimpleLazyObject, app_label: str) -> None: ...
app_label: str
user: Any
def __init__(self, user: Any, app_label: str) -> None: ...
def __getitem__(self, perm_name: str) -> bool: ...
def __iter__(self) -> Any: ...
def __bool__(self) -> bool: ...
class PermWrapper:
user: SimpleLazyObject = ...
def __init__(self, user: Union[AnonymousUser, User]) -> None: ...
user: Any = ...
def __init__(self, user: Any) -> None: ...
def __getitem__(self, app_label: str) -> PermLookupDict: ...
def __iter__(self) -> Any: ...
def __contains__(self, perm_name: Union[bool, str]) -> bool: ...
def __contains__(self, perm_name: Any) -> bool: ...
def auth(request: HttpRequest) -> Dict[str, Union[PermWrapper, AnonymousUser, User]]: ...
def auth(request: HttpRequest) -> Dict[str, Any]: ...

View File

@@ -1,5 +1,7 @@
from typing import Any, Callable, List, Optional, Set, Union
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME
def user_passes_test(
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...
) -> Callable: ...

View File

@@ -1,84 +1,36 @@
import collections
import datetime
from typing import Any, Dict, Iterator, List, Optional, Union, Type
from typing import Any, Dict, Iterator, Optional
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AbstractUser, User
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.core.exceptions import ValidationError
from django.core.handlers.wsgi import WSGIRequest
from django.forms.utils import ErrorList
from django.http.request import QueryDict
from django.utils.datastructures import MultiValueDict
from django import forms
UserModel: Any
class ReadOnlyPasswordHashWidget(forms.Widget):
attrs: Dict[Any, Any]
template_name: str = ...
class ReadOnlyPasswordHashField(forms.Field):
widget: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def bound_data(self, data: None, initial: str) -> str: ...
def has_changed(self, initial: str, data: Optional[str]) -> bool: ...
class UsernameField(forms.CharField):
def to_python(self, value: Optional[str]) -> str: ...
class UsernameField(forms.CharField): ...
class UserCreationForm(forms.ModelForm):
auto_id: str
data: Dict[str, str]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[Any, Any]
instance: User
is_bound: bool
label_suffix: str
error_messages: Any = ...
password1: Any = ...
password2: Any = ...
class Meta:
model: Any = ...
fields: Any = ...
field_classes: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password2(self) -> str: ...
def save(self, commit: bool = ...) -> User: ...
class UserChangeForm(forms.ModelForm):
auto_id: str
data: Dict[Any, Any]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[str, Optional[Union[List[Any], datetime.datetime, int, str]]]
instance: User
is_bound: bool
label_suffix: str
password: Any = ...
class Meta:
model: Any = ...
fields: str = ...
field_classes: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def clean_password(self) -> str: ...
class AuthenticationForm(forms.Form):
auto_id: str
data: QueryDict
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: MultiValueDict
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
username: Any = ...
password: Any = ...
error_messages: Any = ...
@@ -91,21 +43,12 @@ class AuthenticationForm(forms.Form):
def get_invalid_login_error(self) -> ValidationError: ...
class PasswordResetForm(forms.Form):
auto_id: str
data: Dict[Any, Any]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
email: Any = ...
def send_mail(
self,
subject_template_name: str,
email_template_name: str,
context: Dict[str, Union[AbstractBaseUser, str]],
context: Dict[str, Any],
from_email: Optional[str],
to_email: str,
html_email_template_name: Optional[str] = ...,
@@ -125,15 +68,6 @@ class PasswordResetForm(forms.Form):
) -> None: ...
class SetPasswordForm(forms.Form):
auto_id: str
data: Dict[Any, Any]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
error_messages: Any = ...
new_password1: Any = ...
new_password2: Any = ...
@@ -143,31 +77,10 @@ class SetPasswordForm(forms.Form):
def save(self, commit: bool = ...) -> AbstractBaseUser: ...
class PasswordChangeForm(SetPasswordForm):
auto_id: str
data: Dict[Any, Any]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
user: User
error_messages: Any = ...
old_password: Any = ...
field_order: Any = ...
def clean_old_password(self) -> str: ...
class AdminPasswordChangeForm(forms.Form):
auto_id: str
data: Dict[Any, Any]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[Any, Any]
is_bound: bool
label_suffix: str
error_messages: Any = ...
required_css_class: str = ...
password1: Any = ...
@@ -176,5 +89,3 @@ class AdminPasswordChangeForm(forms.Form):
def __init__(self, user: AbstractUser, *args: Any, **kwargs: Any) -> None: ...
def clean_password2(self) -> str: ...
def save(self, commit: bool = ...) -> AbstractUser: ...
@property
def changed_data(self) -> List[str]: ...

View File

@@ -1,4 +1,3 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional
UNUSABLE_PASSWORD_PREFIX: str
@@ -17,92 +16,30 @@ def identify_hasher(encoded: str) -> BasePasswordHasher: ...
def mask_hash(hash: str, show: int = ..., char: str = ...) -> str: ...
class BasePasswordHasher:
algorithm: Any = ...
library: Any = ...
algorithm: str = ...
library: str = ...
rounds: int = ...
time_cost: int = ...
memory_cost: int = ...
parallelism: int = ...
digest: Any = ...
iterations: Optional[int] = ...
def salt(self) -> str: ...
def verify(self, password: str, encoded: str) -> Any: ...
def verify(self, password: str, encoded: str) -> bool: ...
def encode(self, password: str, salt: str) -> Any: ...
def safe_summary(self, encoded: str) -> Any: ...
def must_update(self, encoded: str) -> bool: ...
def harden_runtime(self, password: str, encoded: str) -> None: ...
class PBKDF2PasswordHasher(BasePasswordHasher):
algorithm: str = ...
iterations: int = ...
digest: Any = ...
def encode(self, password: str, salt: str, iterations: Optional[int] = ...) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ...
def safe_summary(self, encoded: str) -> OrderedDict: ...
def must_update(self, encoded: str) -> bool: ...
def harden_runtime(self, password: str, encoded: str) -> None: ...
class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher):
algorithm: str = ...
digest: Any = ...
class Argon2PasswordHasher(BasePasswordHasher):
algorithm: str = ...
library: str = ...
time_cost: int = ...
memory_cost: int = ...
parallelism: int = ...
def encode(self, password: Any, salt: Any): ...
def verify(self, password: Any, encoded: Any): ...
def safe_summary(self, encoded: Any): ...
def must_update(self, encoded: Any): ...
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
class BCryptSHA256PasswordHasher(BasePasswordHasher):
algorithm: str = ...
digest: Any = ...
library: Any = ...
rounds: int = ...
def salt(self): ...
def encode(self, password: Any, salt: Any): ...
def verify(self, password: Any, encoded: Any): ...
def safe_summary(self, encoded: Any): ...
def must_update(self, encoded: Any): ...
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
class BCryptPasswordHasher(BCryptSHA256PasswordHasher):
algorithm: str = ...
digest: Any = ...
class SHA1PasswordHasher(BasePasswordHasher):
algorithm: str = ...
def encode(self, password: str, salt: str) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ...
def safe_summary(self, encoded: Any): ...
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
class MD5PasswordHasher(BasePasswordHasher):
algorithm: str = ...
def encode(self, password: str, salt: str) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ...
def safe_summary(self, encoded: str) -> OrderedDict: ...
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
class UnsaltedSHA1PasswordHasher(BasePasswordHasher):
algorithm: str = ...
def salt(self) -> str: ...
def encode(self, password: str, salt: str) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ...
def safe_summary(self, encoded: Any): ...
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
class UnsaltedMD5PasswordHasher(BasePasswordHasher):
algorithm: str = ...
def salt(self) -> str: ...
def encode(self, password: str, salt: str) -> str: ...
def verify(self, password: str, encoded: str) -> bool: ...
def safe_summary(self, encoded: Any): ...
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
class CryptPasswordHasher(BasePasswordHasher):
algorithm: str = ...
library: str = ...
def salt(self): ...
def encode(self, password: Any, salt: Any): ...
def verify(self, password: Any, encoded: Any): ...
def safe_summary(self, encoded: Any): ...
def harden_runtime(self, password: Any, encoded: Any) -> None: ...
class PBKDF2SHA1PasswordHasher(PBKDF2PasswordHasher): ...
class Argon2PasswordHasher(BasePasswordHasher): ...
class BCryptSHA256PasswordHasher(BasePasswordHasher): ...
class BCryptPasswordHasher(BCryptSHA256PasswordHasher): ...
class SHA1PasswordHasher(BasePasswordHasher): ...
class MD5PasswordHasher(BasePasswordHasher): ...
class UnsaltedSHA1PasswordHasher(BasePasswordHasher): ...
class UnsaltedMD5PasswordHasher(BasePasswordHasher): ...
class CryptPasswordHasher(BasePasswordHasher): ...

View File

@@ -13,8 +13,8 @@ class AuthenticationMiddleware(MiddlewareMixin):
class RemoteUserMiddleware(MiddlewareMixin):
header: str = ...
force_logout_if_no_header: bool = ...
def process_request(self, request: WSGIRequest) -> None: ...
def clean_username(self, username: str, request: WSGIRequest) -> str: ...
def process_request(self, request: HttpRequest) -> None: ...
def clean_username(self, username: str, request: HttpRequest) -> str: ...
class PersistentRemoteUserMiddleware(RemoteUserMiddleware):
force_logout_if_no_header: bool = ...

View File

@@ -1,6 +1,6 @@
from typing import Any, Callable, List, Optional
from django.core.handlers.wsgi import WSGIRequest
from django import http
from django.http.response import HttpResponse, HttpResponseRedirect
class AccessMixin:
@@ -14,15 +14,15 @@ class AccessMixin:
def handle_no_permission(self) -> HttpResponseRedirect: ...
class LoginRequiredMixin(AccessMixin):
def dispatch(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
class PermissionRequiredMixin(AccessMixin):
permission_required: Any = ...
def get_permission_required(self) -> List[str]: ...
def has_permission(self) -> bool: ...
def dispatch(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
class UserPassesTestMixin(AccessMixin):
def test_func(self) -> None: ...
def get_test_func(self) -> Callable: ...
def dispatch(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def dispatch(self, request: http.HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...

View File

@@ -1,46 +1,33 @@
import datetime
from typing import Any, List, Optional, Set, Tuple, Type, Union
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
from django.contrib.contenttypes.models import ContentType
from django.db.models.manager import EmptyManager
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.db import models
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
class PermissionManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ...
class Permission(models.Model):
content_type_id: int
id: int
name: str = ...
content_type: Any = ...
codename: str = ...
name: models.CharField = ...
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
codename: models.CharField = ...
def natural_key(self) -> Tuple[str, str, str]: ...
class GroupManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_by_natural_key(self, name: str) -> Group: ...
class Group(models.Model):
id: None
name: str = ...
permissions: Any = ...
name: models.CharField = ...
permissions: models.ManyToManyField = models.ManyToManyField(Permission)
def natural_key(self): ...
class UserManager(BaseUserManager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def create_user(
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
) -> AbstractUser: ...
@@ -49,24 +36,23 @@ class UserManager(BaseUserManager):
) -> AbstractBaseUser: ...
class PermissionsMixin(models.Model):
is_superuser: Any = ...
groups: Any = ...
user_permissions: Any = ...
is_superuser: models.BooleanField = ...
groups: models.ManyToManyField = models.ManyToManyField(Group)
user_permissions: models.ManyToManyField = models.ManyToManyField(Permission)
def get_group_permissions(self, obj: None = ...) -> Set[str]: ...
def get_all_permissions(self, obj: Optional[str] = ...) -> Set[str]: ...
def has_perm(self, perm: Union[Tuple[str, Any], str], obj: Optional[str] = ...) -> bool: ...
def has_perms(self, perm_list: Union[List[str], Set[str], Tuple[str]], obj: None = ...) -> bool: ...
def has_module_perms(self, app_label: str) -> bool: ...
class AbstractUser(AbstractBaseUser, PermissionsMixin):
is_superuser: bool
username_validator: Any = ...
username: str = ...
first_name: str = ...
last_name: str = ...
email: str = ...
is_staff: bool = ...
date_joined: datetime.datetime = ...
class AbstractUser(AbstractBaseUser, PermissionsMixin): # type: ignore
username_validator: UnicodeUsernameValidator = ...
username: models.CharField = ...
first_name: models.CharField = ...
last_name: models.CharField = ...
email: models.EmailField = ...
is_staff: models.BooleanField = ...
date_joined: models.DateTimeField = ...
EMAIL_FIELD: str = ...
USERNAME_FIELD: str = ...
def clean(self) -> None: ...

View File

@@ -1,46 +1,46 @@
from pathlib import PosixPath
from typing import Any, Dict, List, Optional, Tuple, Union
from pathlib import Path, PosixPath
from typing import Any, List, Mapping, Optional, Protocol, Sequence, Set, Union
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import User
def get_default_password_validators() -> Union[
List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]
]: ...
def get_password_validators(
validator_config: List[Dict[str, Union[Dict[str, int], str]]]
) -> Union[List[NumericPasswordValidator], List[UserAttributeSimilarityValidator]]: ...
class PasswordValidator(Protocol):
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...): ...
def get_default_password_validators() -> List[PasswordValidator]: ...
def get_password_validators(validator_config: Sequence[Mapping[str, Any]]) -> List[PasswordValidator]: ...
def validate_password(
password: str, user: Optional[AbstractBaseUser] = ..., password_validators: Optional[List[Any]] = ...
password: str,
user: Optional[AbstractBaseUser] = ...,
password_validators: Optional[Sequence[PasswordValidator]] = ...,
) -> None: ...
def password_changed(
password: str, user: Optional[AbstractBaseUser] = ..., password_validators: None = ...
password: str,
user: Optional[AbstractBaseUser] = ...,
password_validators: Optional[Sequence[PasswordValidator]] = ...,
) -> None: ...
def password_validators_help_texts(password_validators: Optional[List[Any]] = ...) -> List[str]: ...
def password_validators_help_texts(password_validators: Optional[Sequence[PasswordValidator]] = ...) -> List[str]: ...
password_validators_help_text_html: Any
class MinimumLengthValidator:
min_length: int = ...
def __init__(self, min_length: int = ...) -> None: ...
def validate(self, password: str, user: Optional[User] = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
def get_help_text(self) -> str: ...
class UserAttributeSimilarityValidator:
DEFAULT_USER_ATTRIBUTES: Any = ...
user_attributes: Tuple[str, str, str, str] = ...
DEFAULT_USER_ATTRIBUTES: Sequence[str] = ...
user_attributes: Sequence[str] = ...
max_similarity: float = ...
def __init__(
self, user_attributes: Union[List[str], Tuple[str, str, str, str]] = ..., max_similarity: float = ...
) -> None: ...
def validate(self, password: str, user: Optional[User] = ...) -> None: ...
def __init__(self, user_attributes: Sequence[str] = ..., max_similarity: float = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
def get_help_text(self) -> str: ...
class CommonPasswordValidator:
DEFAULT_PASSWORD_LIST_PATH: Any = ...
DEFAULT_PASSWORD_LIST_PATH: Path = ...
passwords: Set[str] = ...
def __init__(self, password_list_path: Union[PosixPath, str] = ...) -> None: ...
def validate(self, password: str, user: None = ...) -> None: ...
def validate(self, password: str, user: Optional[AbstractBaseUser] = ...) -> None: ...
def get_help_text(self) -> str: ...
class NumericPasswordValidator:

View File

@@ -0,0 +1,4 @@
from django.core import validators
class ASCIIUsernameValidator(validators.RegexValidator): ...
class UnicodeUsernameValidator(validators.RegexValidator): ...

View File

@@ -1,15 +1,10 @@
from typing import Any, Dict, Optional, Set, Type, Union
from typing import Any, Optional, Set
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.contrib.sites.requests import RequestSite
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseRedirect
from django.http.response import HttpResponseRedirect
from django.template.response import TemplateResponse
from django.utils.datastructures import MultiValueDict
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormView
@@ -20,31 +15,18 @@ class SuccessURLAllowedHostsMixin:
def get_success_url_allowed_hosts(self) -> Set[str]: ...
class LoginView(SuccessURLAllowedHostsMixin, FormView):
form_class: Any = ...
authentication_form: Any = ...
redirect_field_name: Any = ...
template_name: str = ...
redirect_authenticated_user: bool = ...
extra_context: Any = ...
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_success_url(self) -> str: ...
def get_redirect_url(self) -> str: ...
def get_form_class(self) -> Type[AuthenticationForm]: ...
def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[str, str], HttpRequest, MultiValueDict]]]: ...
def form_valid(self, form: AuthenticationForm) -> HttpResponseRedirect: ...
def get_context_data(
self, **kwargs: Any
) -> Dict[str, Union[AuthenticationForm, LoginView, Site, RequestSite, str]]: ...
class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
next_page: Any = ...
redirect_field_name: Any = ...
template_name: str = ...
extra_context: Any = ...
def dispatch(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ...
def post(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> TemplateResponse: ...
def get_next_page(self) -> Optional[str]: ...
def get_context_data(self, **kwargs: Any): ...
def logout_then_login(request: HttpRequest, login_url: Optional[str] = ...) -> HttpResponseRedirect: ...
def redirect_to_login(
@@ -58,55 +40,32 @@ class PasswordContextMixin:
class PasswordResetView(PasswordContextMixin, FormView):
email_template_name: str = ...
extra_email_context: Any = ...
form_class: Any = ...
from_email: Any = ...
html_email_template_name: Any = ...
subject_template_name: str = ...
success_url: Any = ...
template_name: str = ...
title: Any = ...
token_generator: Any = ...
def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
def form_valid(self, form: PasswordResetForm) -> HttpResponseRedirect: ...
INTERNAL_RESET_URL_TOKEN: str
INTERNAL_RESET_SESSION_TOKEN: str
class PasswordResetDoneView(PasswordContextMixin, TemplateView):
template_name: str = ...
title: Any = ...
class PasswordResetConfirmView(PasswordContextMixin, FormView):
form_class: Any = ...
post_reset_login: bool = ...
post_reset_login_backend: Any = ...
success_url: Any = ...
template_name: str = ...
title: Any = ...
token_generator: Any = ...
validlink: bool = ...
user: Any = ...
def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_user(self, uidb64: str) -> Optional[AbstractBaseUser]: ...
def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[Any, Any], AbstractBaseUser, MultiValueDict]]]: ...
def form_valid(self, form: SetPasswordForm) -> HttpResponseRedirect: ...
def get_context_data(self, **kwargs: Any): ...
class PasswordResetCompleteView(PasswordContextMixin, TemplateView):
template_name: str = ...
title: Any = ...
def get_context_data(self, **kwargs: Any): ...
class PasswordChangeView(PasswordContextMixin, FormView):
form_class: Any = ...
success_url: Any = ...
template_name: str = ...
title: Any = ...
def dispatch(self, *args: Any, **kwargs: Any) -> HttpResponse: ...
def get_form_kwargs(self) -> Dict[str, Optional[Union[Dict[Any, Any], User, MultiValueDict]]]: ...
def form_valid(self, form: PasswordChangeForm) -> HttpResponseRedirect: ...
class PasswordChangeDoneView(PasswordContextMixin, TemplateView):
template_name: str = ...
title: Any = ...
def dispatch(self, *args: Any, **kwargs: Any) -> TemplateResponse: ...

View File

@@ -1,6 +1,14 @@
from django.db.models.base import Model
from typing import Any, List, Type
from django.contrib.admin.options import InlineModelAdmin
from django.db.models.base import Model
class GenericInlineModelAdminChecks:
def _check_exclude_of_parent_model(self, obj: GenericTabularInline, parent_model: Type[Model]) -> List[Any]: ...
def _check_relation(self, obj: GenericTabularInline, parent_model: Type[Model]) -> List[Any]: ...
def _check_exclude_of_parent_model(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ...
def _check_relation(self, obj: GenericInlineModelAdmin, parent_model: Type[Model]) -> List[Any]: ...
class GenericInlineModelAdmin(InlineModelAdmin):
template: str = ...
class GenericStackedInline(GenericInlineModelAdmin): ...
class GenericTabularInline(GenericInlineModelAdmin): ...

View File

@@ -1,16 +1,3 @@
from typing import Any, Optional
from django.apps import AppConfig
from .management import create_contenttypes, inject_rename_contenttypes_operations
class ContentTypesConfig(AppConfig):
apps: None
label: str
models: None
models_module: None
module: Any
path: str
name: str = ...
verbose_name: Any = ...
def ready(self) -> None: ...
class ContentTypesConfig(AppConfig): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union, Generic
from django.contrib.contenttypes.models import ContentType
from django.core.checks.messages import Error
@@ -51,7 +51,7 @@ class GenericForeignKey(FieldCacheMixin):
class GenericRel(ForeignObjectRel):
field: GenericRelation
limit_choices_to: Dict[Any, Any]
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]]
model: Type[Model]
multiple: bool
on_delete: Callable
@@ -65,7 +65,7 @@ class GenericRel(ForeignObjectRel):
to: Union[Type[Model], str],
related_name: None = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: None = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
) -> None: ...
class GenericRelation(ForeignObject):
@@ -79,6 +79,7 @@ class GenericRelation(ForeignObject):
object_id_field_name: Any = ...
content_type_field_name: Any = ...
for_concrete_model: Any = ...
to_fields: Any = ...
def __init__(
self,
to: Union[Type[Model], str],
@@ -86,17 +87,15 @@ class GenericRelation(ForeignObject):
content_type_field: str = ...,
for_concrete_model: bool = ...,
related_query_name: Optional[str] = ...,
limit_choices_to: None = ...,
limit_choices_to: Optional[Union[Dict[str, Any], Callable[[], Any]]] = ...,
**kwargs: Any
) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
to_fields: Any = ...
def resolve_related_fields(self) -> List[Tuple[PositiveIntegerField, Field]]: ...
def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
def value_to_string(self, obj: Model) -> str: ...
model: Any = ...
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
def set_attributes_from_rel(self) -> None: ...
def get_internal_type(self) -> str: ...
def get_content_type(self) -> ContentType: ...

View File

@@ -1,20 +1,13 @@
from typing import Any, Optional
from typing import Any, Dict, List
from django.core.management import BaseCommand
from django.core.management.base import CommandParser
from django.db.models.deletion import Collector
from ...management import get_contenttypes_and_models
from django.core.management import BaseCommand
class Command(BaseCommand):
stderr: django.core.management.base.OutputWrapper
stdout: django.core.management.base.OutputWrapper
style: django.core.management.color.Style
def add_arguments(self, parser: CommandParser) -> None: ...
def handle(self, **options: Any) -> None: ...
class Command(BaseCommand): ...
class NoFastDeleteCollector(Collector):
data: collections.OrderedDict
data: Dict[str, Any]
dependencies: Dict[Any, Any]
fast_deletes: List[Any]
field_updates: Dict[Any, Any]

View File

@@ -4,12 +4,7 @@ from django.db import models
from django.db.models.base import Model
from django.db.models.query import QuerySet
class ContentTypeManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class ContentTypeManager(models.Manager["ContentType"]):
def get_by_natural_key(self, app_label: str, model: str) -> ContentType: ...
def get_for_model(self, model: Union[Type[Model], Model], for_concrete_model: bool = ...) -> ContentType: ...
def get_for_models(self, *models: Any, for_concrete_models: bool = ...) -> Dict[Type[Model], ContentType]: ...
@@ -18,14 +13,9 @@ class ContentTypeManager(models.Manager):
class ContentType(models.Model):
id: int
app_label: str = ...
model: str = ...
objects: Any = ...
class Meta:
verbose_name: Any = ...
verbose_name_plural: Any = ...
db_table: str = ...
unique_together: Any = ...
app_label: models.CharField = ...
model: models.CharField = ...
objects: ContentTypeManager = ...
@property
def name(self) -> str: ...
def model_class(self) -> Optional[Type[Model]]: ...

View File

@@ -1,22 +1,7 @@
from typing import Any, Dict, Optional, Union
from typing import Any
from django import forms
from django.db.models.query import QuerySet
class FlatpageForm(forms.ModelForm):
auto_id: str
data: Dict[str, Union[List[int], str]]
empty_permitted: bool
error_class: Type[ErrorList]
fields: collections.OrderedDict
files: Dict[Any, Any]
initial: Dict[str, Union[List[django.contrib.sites.models.Site], int, str]]
instance: django.contrib.flatpages.models.FlatPage
is_bound: bool
label_suffix: str
url: Any = ...
class Meta:
model: Any = ...
fields: str = ...
def clean_url(self) -> str: ...
def clean(self) -> Dict[str, Union[bool, QuerySet, str]]: ...

View File

@@ -1,19 +1,13 @@
from typing import Any, Optional
from django.contrib.sites.models import Site
from django.db import models
class FlatPage(models.Model):
id: None
url: str = ...
title: str = ...
content: str = ...
enable_comments: bool = ...
template_name: str = ...
registration_required: bool = ...
sites: Any = ...
class Meta:
db_table: str = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
ordering: Any = ...
url: models.CharField = ...
title: models.CharField = ...
content: models.TextField = ...
enable_comments: models.BooleanField = ...
template_name: models.CharField = ...
registration_required: models.BooleanField = ...
sites: models.ManyToManyField[Site, Site] = ...
def get_absolute_url(self) -> str: ...

View File

@@ -1,7 +1,3 @@
from typing import Optional
from django.contrib.sitemaps import Sitemap
from django.db.models.query import QuerySet
class FlatPageSitemap(Sitemap):
def items(self) -> QuerySet: ...
class FlatPageSitemap(Sitemap): ...

View File

@@ -1,4 +1,4 @@
from datetime import date, datetime
from datetime import date, datetime as datetime
from decimal import Decimal
from typing import Any, Optional, Union

View File

@@ -0,0 +1,24 @@
from .api import (
get_level as get_level,
set_level as set_level,
add_message as add_message,
debug as debug,
error as error,
success as success,
get_messages as get_messages,
MessageFailure as MessageFailure,
info as info,
warning as warning,
)
from .constants import (
DEBUG as DEBUG,
DEFAULT_LEVELS as DEFAULT_LEVELS,
DEFAULT_TAGS as DEFAULT_TAGS,
ERROR as ERROR,
INFO as INFO,
SUCCESS as SUCCESS,
WARNING as WARNING,
)
default_app_config: str = ...

View File

@@ -0,0 +1,11 @@
from typing import Dict
DEBUG: int = ...
INFO: int = ...
SUCCESS: int = ...
WARNING: int = ...
ERROR: int = ...
DEFAULT_TAGS: Dict[int, str] = ...
DEFAULT_LEVELS: Dict[str, int] = ...

View File

@@ -1,8 +1,7 @@
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase
from django.http.response import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class MessageMiddleware(MiddlewareMixin):
def process_request(self, request: WSGIRequest) -> None: ...
def process_response(self, request: HttpRequest, response: HttpResponseBase) -> HttpResponseBase: ...
def process_request(self, request: HttpRequest) -> None: ...
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...

View File

@@ -16,7 +16,7 @@ class Message:
def level_tag(self) -> str: ...
class BaseStorage:
request: Any = ...
request: HttpRequest = ...
used: bool = ...
added_new: bool = ...
def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...

View File

@@ -1,49 +1,20 @@
import json
from typing import Any, Dict, List, Optional, Union
from typing import Any
from django.contrib.messages.storage.base import BaseStorage, Message
from django.contrib.messages.storage.base import BaseStorage
class MessageEncoder(json.JSONEncoder):
allow_nan: bool
check_circular: bool
ensure_ascii: bool
indent: None
item_separator: str
key_separator: str
skipkeys: bool
sort_keys: bool
message_key: str = ...
def default(self, obj: Message) -> List[Union[int, str]]: ...
class MessageDecoder(json.JSONDecoder):
def process_messages(
self,
obj: Union[
Dict[
str, Union[List[Union[Dict[str, List[Union[int, str]]], List[Union[int, str]]]], List[Union[int, str]]]
],
List[Union[List[Union[int, str]], str]],
str,
],
) -> Union[
Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]],
List[Union[Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]], Message]],
List[Union[Message, str]],
Message,
str,
]: ...
def decode(
self, s: str, **kwargs: Any
) -> Union[
List[Union[Dict[str, Union[List[Union[Dict[str, Message], Message]], Message]], Message]],
List[Union[Message, str]],
Message,
]: ...
def process_messages(self, obj: Any) -> Any: ...
class CookieStorage(BaseStorage):
added_new: bool
request: WSGIRequest
used: bool
cookie_name: str = ...
max_cookie_size: int = ...
not_finished: str = ...

View File

@@ -1,11 +1,8 @@
from typing import Any, Optional
from typing import Any
from django.contrib.messages.storage.base import BaseStorage
class FallbackStorage(BaseStorage):
added_new: bool
request: WSGIRequest
used: bool
storage_classes: Any = ...
storages: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...

View File

@@ -1,15 +1,10 @@
from typing import Any, List, Optional, Union
from typing import Any, List, Optional, Sequence, Union
from django.contrib.messages.storage.base import BaseStorage, Message
from django.contrib.messages.storage.base import BaseStorage
from django.http.request import HttpRequest
class SessionStorage(BaseStorage):
added_new: bool
request: WSGIRequest
used: bool
session_key: str = ...
def __init__(self, request: HttpRequest, *args: Any, **kwargs: Any) -> None: ...
def serialize_messages(self, messages: Union[List[Message], List[str]]) -> str: ...
def deserialize_messages(
self, data: Optional[Union[List[Any], str]]
) -> Optional[Union[List[Message], List[str]]]: ...
def serialize_messages(self, messages: Sequence[Any]) -> str: ...
def deserialize_messages(self, data: Optional[Union[List[Any], str]]) -> Optional[List[Any]]: ...

View File

@@ -8,3 +8,4 @@ from .ranges import (
DateRangeField as DateRangeField,
DateTimeRangeField as DateTimeRangeField,
)
from .hstore import HStoreField as HStoreField

View File

@@ -1,34 +1,51 @@
from typing import Any, Dict, List, Optional, Tuple, Union, TypeVar, Generic, Sequence
from typing import Any, Iterable, List, Optional, Sequence, TypeVar, Union
from django.db.models.expressions import Combinable
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
from django.db.models.fields import Field
from .mixins import CheckFieldDefaultMixin
_T = TypeVar("_T", bound=Field)
# __set__ value type
_ST = TypeVar("_ST")
# __get__ return type
_GT = TypeVar("_GT")
class ArrayField(CheckFieldDefaultMixin, Field[_ST, _GT]):
_pyi_private_set_type: Union[Sequence[Any], Combinable]
_pyi_private_get_type: List[Any]
class ArrayField(CheckFieldDefaultMixin, Field, Generic[_T]):
empty_strings_allowed: bool = ...
default_error_messages: Any = ...
base_field: Any = ...
size: Any = ...
default_validators: Any = ...
from_db_value: Any = ...
def __init__(self, base_field: _T, size: None = ..., **kwargs: Any) -> None: ...
@property
def model(self): ...
@model.setter
def model(self, model: Any) -> None: ...
def check(self, **kwargs: Any) -> List[Any]: ...
def set_attributes_from_name(self, name: str) -> None: ...
def __init__(
self,
base_field: Field,
size: Optional[int] = ...,
verbose_name: Optional[Union[str, bytes]] = ...,
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] = ...,
) -> None: ...
@property
def description(self): ...
def db_type(self, connection: Any): ...
def get_db_prep_value(self, value: Any, connection: Any, prepared: bool = ...): ...
def deconstruct(self) -> Tuple[None, str, List[Any], Dict[str, Optional[Union[bool, Field]]]]: ...
def to_python(self, value: Any): ...
def value_to_string(self, obj: Any): ...
def get_transform(self, name: Any): ...
def validate(self, value: Any, model_instance: Any) -> None: ...
def run_validators(self, value: Any) -> None: ...
def formfield(self, **kwargs: Any): ...
def __set__(self, instance, value: Sequence[_T]): ...
def __get__(self, instance, owner) -> List[_T]: ...

View File

@@ -0,0 +1,17 @@
from typing import Any
from django.db.models import Field, Transform
from .mixins import CheckFieldDefaultMixin
class HStoreField(CheckFieldDefaultMixin, Field):
def get_transform(self, name) -> Any: ...
class KeyTransform(Transform):
def __init__(self, key_name: str, *args: Any, **kwargs: Any): ...
class KeyTransformFactory:
def __init__(self, key_name: str): ...
def __call__(self, *args, **kwargs) -> KeyTransform: ...
class KeysTransform(Transform): ...
class ValuesTransform(Transform): ...

View File

@@ -2,46 +2,27 @@ from typing import Any
from django.db import models
from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange # type: ignore
class RangeField(models.Field):
empty_strings_allowed: bool = ...
base_field: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@property
def model(self): ...
@model.setter
def model(self, model: Any) -> None: ...
range_type: Any = ...
def get_prep_value(self, value: Any): ...
def to_python(self, value: Any): ...
def set_attributes_from_name(self, name: str) -> None: ...
def value_to_string(self, obj: Any): ...
def formfield(self, **kwargs: Any): ...
class IntegerRangeField(RangeField):
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
def __get__(self, instance, owner) -> NumericRange: ...
class BigIntegerRangeField(RangeField):
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
def __get__(self, instance, owner) -> NumericRange: ...
class FloatRangeField(RangeField):
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
def __get__(self, instance, owner) -> NumericRange: ...
class DateTimeRangeField(RangeField):
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
def __get__(self, instance, owner) -> DateTimeTZRange: ...
class DateRangeField(RangeField):
base_field: Any = ...
range_type: Any = ...
form_field: Any = ...
def db_type(self, connection: Any): ...
def __get__(self, instance, owner) -> DateRange: ...

View File

@@ -1,10 +1,10 @@
from typing import Any
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.utils.deprecation import MiddlewareMixin
class RedirectFallbackMiddleware(MiddlewareMixin):
response_gone_class: Any = ...
response_redirect_class: Any = ...
def process_response(self, request: WSGIRequest, response: HttpResponse) -> HttpResponse: ...
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...

View File

@@ -1,16 +1,6 @@
from typing import Any, Optional
from django.db import models
class Redirect(models.Model):
id: None
site_id: int
site: Any = ...
old_path: str = ...
new_path: str = ...
class Meta:
verbose_name: Any = ...
verbose_name_plural: Any = ...
db_table: str = ...
unique_together: Any = ...
ordering: Any = ...
site: models.ForeignKey = ...
old_path: models.CharField = ...
new_path: models.CharField = ...

View File

@@ -1,33 +1,23 @@
from datetime import datetime
from typing import Any, Dict, Optional, Union
from django.db.models.base import Model
VALID_KEY_CHARS: Any
class CreateError(Exception): ...
class UpdateError(Exception): ...
class SessionBase:
class SessionBase(Dict[str, Any]):
TEST_COOKIE_NAME: str = ...
TEST_COOKIE_VALUE: str = ...
accessed: bool = ...
modified: bool = ...
serializer: Any = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ...
def __contains__(self, key: str) -> bool: ...
def __getitem__(self, key: str) -> Any: ...
def __setitem__(self, key: str, value: Any) -> None: ...
def __delitem__(self, key: str) -> None: ...
def get(self, key: str, default: Optional[str] = ...) -> Any: ...
def pop(self, key: str, default: Any = ...) -> Any: ...
def setdefault(self, key: str, value: str) -> str: ...
def set_test_cookie(self) -> None: ...
def test_cookie_worked(self) -> bool: ...
def delete_test_cookie(self) -> None: ...
def encode(self, session_dict: Dict[str, Model]) -> str: ...
def decode(self, session_data: Union[bytes, str]) -> Dict[str, Model]: ...
def update(self, dict_: Dict[str, int]) -> None: ...
def encode(self, session_dict: Dict[str, Any]) -> str: ...
def decode(self, session_data: Union[bytes, str]) -> Dict[str, Any]: ...
def has_key(self, key: Any): ...
def keys(self): ...
def values(self): ...
@@ -41,10 +31,10 @@ class SessionBase:
def get_expire_at_browser_close(self) -> bool: ...
def flush(self) -> None: ...
def cycle_key(self) -> None: ...
def exists(self, session_key: Any) -> None: ...
def exists(self, session_key: str) -> bool: ...
def create(self) -> None: ...
def save(self, must_create: bool = ...) -> None: ...
def delete(self, session_key: Optional[Any] = ...) -> None: ...
def load(self) -> None: ...
def load(self) -> Dict[str, Any]: ...
@classmethod
def clear_expired(cls) -> None: ...

View File

@@ -1,23 +1,11 @@
from typing import Any, Dict, Optional
from typing import Any, Optional
from django.contrib.sessions.backends.base import SessionBase
from django.contrib.sessions.serializers import JSONSerializer
KEY_PREFIX: str
class SessionStore(SessionBase):
accessed: bool
serializer: JSONSerializer
cache_key_prefix: Any = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ...
@property
def cache_key(self) -> str: ...
def load(self) -> Dict[str, str]: ...
modified: bool = ...
def create(self) -> None: ...
def save(self, must_create: bool = ...) -> None: ...
def exists(self, session_key: Optional[str]) -> bool: ...
def delete(self, session_key: Optional[str] = ...) -> None: ...
@classmethod
def clear_expired(cls) -> None: ...

View File

@@ -1,19 +1,11 @@
from typing import Any, Dict, Optional
from typing import Any, Optional
from django.contrib.sessions.backends.db import SessionStore as DBStore
KEY_PREFIX: str
class SessionStore(DBStore):
accessed: bool
modified: bool
serializer: Type[django.core.signing.JSONSerializer]
cache_key_prefix: Any = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ...
@property
def cache_key(self) -> str: ...
def load(self) -> Dict[str, str]: ...
def exists(self, session_key: Optional[str]) -> bool: ...
def save(self, must_create: bool = ...) -> None: ...
def delete(self, session_key: Optional[str] = ...) -> None: ...
def flush(self) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Type, Union
from typing import Dict, Optional, Type
from django.contrib.sessions.backends.base import SessionBase
from django.contrib.sessions.base_session import AbstractBaseSession
@@ -6,18 +6,8 @@ from django.contrib.sessions.models import Session
from django.db.models.base import Model
class SessionStore(SessionBase):
accessed: bool
serializer: Type[django.core.signing.JSONSerializer]
def __init__(self, session_key: Optional[str] = ...) -> None: ...
@classmethod
def get_model_class(cls) -> Type[Session]: ...
def model(self) -> Type[AbstractBaseSession]: ...
def load(self) -> Dict[str, Union[Model, int, str]]: ...
def exists(self, session_key: Optional[str]) -> bool: ...
modified: bool = ...
def create(self) -> None: ...
def create_model_instance(self, data: Dict[str, Model]) -> AbstractBaseSession: ...
def save(self, must_create: bool = ...) -> None: ...
def delete(self, session_key: Optional[str] = ...) -> None: ...
@classmethod
def clear_expired(cls) -> None: ...

View File

@@ -1,19 +1,9 @@
from typing import Any, Dict, Optional, Union
from typing import Optional
from django.contrib.sessions.backends.base import SessionBase
class SessionStore(SessionBase):
accessed: bool
serializer: Type[django.core.signing.JSONSerializer]
storage_path: str = ...
file_prefix: str = ...
def __init__(self, session_key: Optional[str] = ...) -> None: ...
def load(self) -> Dict[str, Union[int, str]]: ...
modified: bool = ...
def create(self) -> None: ...
def save(self, must_create: bool = ...) -> None: ...
def exists(self, session_key: Optional[str]) -> bool: ...
def delete(self, session_key: Optional[str] = ...) -> None: ...
def clean(self) -> None: ...
@classmethod
def clear_expired(cls) -> None: ...

View File

@@ -1,17 +1,3 @@
from datetime import datetime
from typing import Any, Dict, Optional, Union
from django.contrib.sessions.backends.base import SessionBase
class SessionStore(SessionBase):
accessed: bool
serializer: Type[django.core.signing.JSONSerializer]
def load(self) -> Dict[str, Union[datetime, str]]: ...
modified: bool = ...
def create(self) -> None: ...
def save(self, must_create: bool = ...) -> None: ...
def exists(self, session_key: Optional[str] = ...) -> bool: ...
def delete(self, session_key: Optional[str] = ...) -> None: ...
def cycle_key(self) -> None: ...
@classmethod
def clear_expired(cls) -> None: ...
class SessionStore(SessionBase): ...

View File

@@ -1,24 +1,19 @@
from datetime import datetime
from typing import Any, Dict, Optional
from typing import Any, Dict, Optional, Type
from django.contrib.sessions.backends.base import SessionBase
from django.db import models
class BaseSessionManager(models.Manager):
creation_counter: int
model: None
name: None
def encode(self, session_dict: Dict[str, int]) -> str: ...
def save(self, session_key: str, session_dict: Dict[str, int], expire_date: datetime) -> AbstractBaseSession: ...
class AbstractBaseSession(models.Model):
session_key: Any = ...
session_data: Any = ...
expire_date: Any = ...
expire_date: datetime
session_data: str
session_key: str
objects: Any = ...
class Meta:
abstract: bool = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
@classmethod
def get_session_store_class(cls) -> None: ...
def get_session_store_class(cls) -> Optional[Type[SessionBase]]: ...
def get_decoded(self) -> Dict[str, int]: ...

View File

@@ -1,10 +1,3 @@
from typing import Any, Optional
from django.core.management.base import BaseCommand
class Command(BaseCommand):
stderr: django.core.management.base.OutputWrapper
stdout: django.core.management.base.OutputWrapper
style: django.core.management.color.Style
help: str = ...
def handle(self, **options: Any) -> None: ...
class Command(BaseCommand): ...

View File

@@ -1,7 +1,6 @@
from typing import Type
from django.contrib.sessions.backends.base import SessionBase
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.utils.deprecation import MiddlewareMixin
@@ -9,4 +8,4 @@ from django.utils.deprecation import MiddlewareMixin
class SessionMiddleware(MiddlewareMixin):
SessionStore: Type[SessionBase] = ...
def process_request(self, request: HttpRequest) -> None: ...
def process_response(self, request: WSGIRequest, response: HttpResponse) -> HttpResponse: ...
def process_response(self, request: HttpRequest, response: HttpResponse) -> HttpResponse: ...

View File

@@ -1,20 +1,4 @@
from typing import Any, Optional, Type
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.sessions.base_session import AbstractBaseSession, BaseSessionManager
class SessionManager(BaseSessionManager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
class Session(AbstractBaseSession):
expire_date: datetime.datetime
session_data: str
session_key: str
objects: Any = ...
@classmethod
def get_session_store_class(cls) -> Type[SessionStore]: ...
class Meta(AbstractBaseSession.Meta):
db_table: str = ...
class SessionManager(BaseSessionManager): ...
class Session(AbstractBaseSession): ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Optional
from typing import Dict
from django.core.signing import JSONSerializer as BaseJSONSerializer
from django.db.models.base import Model

View File

@@ -11,25 +11,24 @@ PING_URL: str
class SitemapNotFound(Exception): ...
def ping_google(sitemap_url: None = ..., ping_url: str = ...) -> None: ...
def ping_google(sitemap_url: Optional[str] = ..., ping_url: str = ...) -> None: ...
class Sitemap:
limit: int = ...
protocol: Any = ...
protocol: Optional[str] = ...
def items(self) -> List[Any]: ...
def location(self, obj: Model) -> str: ...
@property
def paginator(self) -> Paginator: ...
def get_urls(
self, page: Union[int, str] = ..., site: Optional[Union[Site, RequestSite]] = ..., protocol: Optional[str] = ...
) -> List[Dict[str, Optional[Union[datetime, Model, str]]]]: ...
) -> List[Dict[str, Any]]: ...
class GenericSitemap(Sitemap):
priority: None = ...
changefreq: None = ...
priority: Optional[float] = ...
changefreq: Optional[str] = ...
queryset: QuerySet = ...
date_field: None = ...
protocol: None = ...
def __init__(
self,
info_dict: Dict[str, Union[datetime, QuerySet, str]],
@@ -37,7 +36,6 @@ class GenericSitemap(Sitemap):
changefreq: Optional[str] = ...,
protocol: Optional[str] = ...,
) -> None: ...
def items(self) -> QuerySet: ...
def lastmod(self, item: Model) -> Optional[datetime]: ...
default_app_config: str

View File

@@ -1,20 +1,21 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, Optional, Type, Union
from typing import Callable, Dict, Optional, Type, Union
from django.http.request import HttpRequest
from django.template.response import TemplateResponse
from django.contrib.sitemaps import GenericSitemap, Sitemap
from django.core.handlers.wsgi import WSGIRequest
from django.template.response import TemplateResponse
def x_robots_tag(func: Callable) -> Callable: ...
def index(
request: WSGIRequest,
request: HttpRequest,
sitemaps: Dict[str, Union[Type[Sitemap], Sitemap]],
template_name: str = ...,
content_type: str = ...,
sitemap_url_name: str = ...,
) -> TemplateResponse: ...
def sitemap(
request: WSGIRequest,
request: HttpRequest,
sitemaps: Union[Dict[str, Type[Sitemap]], Dict[str, GenericSitemap], OrderedDict],
section: Optional[str] = ...,
template_name: str = ...,

View File

@@ -1,14 +1,3 @@
from typing import Any
from django.apps import AppConfig
class SitesConfig(AppConfig):
apps: None
label: str
models: None
models_module: None
module: Any
path: str
name: str = ...
verbose_name: Any = ...
def ready(self) -> None: ...
class SitesConfig(AppConfig): ...

View File

@@ -7,24 +7,14 @@ from django.db import models
SITE_CACHE: Any
class SiteManager(models.Manager):
creation_counter: int
model: None
name: None
use_in_migrations: bool = ...
def get_current(self, request: Optional[HttpRequest] = ...) -> Site: ...
def clear_cache(self) -> None: ...
def get_by_natural_key(self, domain: str) -> Site: ...
class Site(models.Model):
id: int
domain: str = ...
name: str = ...
objects: Any = ...
class Meta:
db_table: str = ...
verbose_name: Any = ...
verbose_name_plural: Any = ...
ordering: Any = ...
domain: models.CharField = ...
name: models.CharField = ...
objects: SiteManager = ...
def natural_key(self) -> Tuple[str]: ...
def clear_site_cache(sender: Type[Site], **kwargs: Any) -> None: ...

View File

@@ -1,15 +1,6 @@
from typing import Any, Optional
from typing import Any
from django.apps import AppConfig
class StaticFilesConfig(AppConfig):
apps: None
label: str
models: None
models_module: None
module: Any
path: str
name: str = ...
verbose_name: Any = ...
ignore_patterns: Any = ...
def ready(self) -> None: ...

View File

@@ -1,45 +1,43 @@
from typing import Any, Iterator, List, Optional, Tuple, Union
from typing import Any, Iterable, Iterator, List, Mapping, Optional, Union, overload
from django.contrib.staticfiles.storage import StaticFilesStorage
from django.core.checks.messages import Error
from django.core.files.storage import DefaultStorage, FileSystemStorage
from django.core.files.storage import Storage
from typing_extensions import Literal
searched_locations: Any
class BaseFinder:
def check(self, **kwargs: Any) -> Any: ...
def find(self, path: Any, all: bool = ...) -> None: ...
def list(self, ignore_patterns: Any) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def find(self, path: str, all: bool = ...) -> Optional[Any]: ...
def list(self, ignore_patterns: Any) -> Iterable[Any]: ...
class FileSystemFinder(BaseFinder):
locations: List[Any] = ...
storages: collections.OrderedDict = ...
storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def check(self, **kwargs: Any) -> List[Error]: ...
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
def find_location(self, root: str, path: str, prefix: str = ...) -> Optional[str]: ...
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, FileSystemStorage]]: ...
class AppDirectoriesFinder(BaseFinder):
storage_class: Any = ...
source_dir: str = ...
apps: List[str] = ...
storages: collections.OrderedDict = ...
storages: Mapping[str, Any] = ...
def __init__(self, app_names: None = ..., *args: Any, **kwargs: Any) -> None: ...
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, FileSystemStorage]]: ...
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
def find_in_app(self, app: str, path: str) -> Optional[str]: ...
class BaseStorageFinder(BaseFinder):
storage: Any = ...
def __init__(self, storage: Optional[StaticFilesStorage] = ..., *args: Any, **kwargs: Any) -> None: ...
def find(self, path: str, all: bool = ...) -> Union[List[str], str]: ...
def list(self, ignore_patterns: List[str]) -> Iterator[Tuple[str, DefaultStorage]]: ...
storage: Storage = ...
def __init__(self, storage: Optional[Storage] = ..., *args: Any, **kwargs: Any) -> None: ...
class DefaultStorageFinder(BaseStorageFinder):
storage: django.contrib.staticfiles.storage.StaticFilesStorage = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class DefaultStorageFinder(BaseStorageFinder): ...
def find(path: str, all: bool = ...) -> Optional[Union[List[str], str]]: ...
def get_finders() -> Iterator[BaseFinder]: ...
@overload
def get_finder(import_path: Literal["django.contrib.staticfiles.finders.FileSystemFinder"]) -> FileSystemFinder: ...
@overload
def get_finder(
import_path: Literal["django.contrib.staticfiles.finders.AppDirectoriesFinder"]
) -> AppDirectoriesFinder: ...
@overload
def get_finder(import_path: str) -> BaseFinder: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
@@ -7,9 +7,6 @@ class StaticFilesHandler(WSGIHandler):
application: WSGIHandler = ...
base_url: Any = ...
def __init__(self, application: WSGIHandler) -> None: ...
def load_middleware(self) -> None: ...
def get_base_url(self) -> str: ...
def file_path(self, url: str) -> str: ...
def serve(self, request: WSGIRequest) -> Any: ...
def get_response(self, request: WSGIRequest) -> Any: ...
def __call__(self, environ: Any, start_response: Any): ...

View File

@@ -1,22 +1,16 @@
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List
from django.core.files.storage import FileSystemStorage
from django.core.management.base import BaseCommand, CommandParser
from django.core.management.base import BaseCommand
class Command(BaseCommand):
stderr: django.core.management.base.OutputWrapper
stdout: django.core.management.base.OutputWrapper
help: str = ...
requires_system_checks: bool = ...
copied_files: Any = ...
symlinked_files: Any = ...
unmodified_files: Any = ...
post_processed_files: Any = ...
storage: Any = ...
style: django.core.management.color.Style = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def local(self) -> bool: ...
def add_arguments(self, parser: CommandParser) -> None: ...
interactive: Any = ...
verbosity: Any = ...
symlink: Any = ...
@@ -26,7 +20,6 @@ class Command(BaseCommand):
post_process: Any = ...
def set_options(self, **options: Any) -> None: ...
def collect(self) -> Dict[str, List[str]]: ...
def handle(self, **options: Any) -> Optional[str]: ...
def log(self, msg: str, level: int = ...) -> None: ...
def is_local_storage(self) -> bool: ...
def clear_dir(self, path: str) -> None: ...

View File

@@ -1,12 +1,3 @@
from typing import Any, Optional
from django.core.management.base import LabelCommand
from django.core.management.base import CommandParser, LabelCommand
class Command(LabelCommand):
stderr: django.core.management.base.OutputWrapper
stdout: django.core.management.base.OutputWrapper
style: django.core.management.color.Style
help: str = ...
label: str = ...
def add_arguments(self, parser: CommandParser) -> None: ...
def handle_label(self, path: str, **options: Any) -> str: ...
class Command(LabelCommand): ...

View File

@@ -1,13 +1,3 @@
from typing import Any, Optional
from django.core.management.commands.runserver import Command as RunserverCommand # type: ignore
from django.contrib.staticfiles.handlers import StaticFilesHandler
from django.core.management.base import CommandParser
from django.core.management.commands.runserver import Command as RunserverCommand
class Command(RunserverCommand):
stderr: django.core.management.base.OutputWrapper
stdout: django.core.management.base.OutputWrapper
style: django.core.management.color.Style
help: str = ...
def add_arguments(self, parser: CommandParser) -> None: ...
def get_handler(self, *args: Any, **options: Any) -> StaticFilesHandler: ...
class Command(RunserverCommand): ...

View File

@@ -20,7 +20,6 @@ class HashedFilesMixin:
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def file_hash(self, name: str, content: File = ...) -> str: ...
def hashed_name(self, name: str, content: Optional[File] = ..., filename: Optional[str] = ...) -> str: ...
def url(self, name: SafeText, force: bool = ...) -> str: ...
def url_converter(self, name: str, hashed_files: OrderedDict, template: str = ...) -> Callable: ...
def post_process(
self, paths: OrderedDict, dry_run: bool = ..., **options: Any
@@ -33,16 +32,13 @@ class ManifestFilesMixin(HashedFilesMixin):
manifest_version: str = ...
manifest_name: str = ...
manifest_strict: bool = ...
hashed_files: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def read_manifest(self) -> Any: ...
def load_manifest(self) -> OrderedDict: ...
def post_process(self, *args: Any, **kwargs: Any) -> None: ...
def save_manifest(self) -> None: ...
def stored_name(self, name: str) -> str: ...
class _MappingCache:
cache: django.core.cache.DefaultCacheProxy = ...
cache: Any = ...
def __init__(self, cache: Any) -> None: ...
def __setitem__(self, key: Any, value: Any) -> None: ...
def __getitem__(self, key: Any): ...
@@ -51,9 +47,7 @@ class _MappingCache:
def get(self, key: Any, default: Optional[Any] = ...): ...
class CachedFilesMixin(HashedFilesMixin):
hashed_files: Any = ...
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
def hash_key(self, name: str) -> str: ...
class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage): ...
class ManifestStaticFilesStorage(ManifestFilesMixin, StaticFilesStorage): ...

View File

@@ -23,5 +23,5 @@ class Feed:
def feed_extra_kwargs(self, obj: None) -> Dict[Any, Any]: ...
def item_extra_kwargs(self, item: Model) -> Dict[Any, Any]: ...
def get_object(self, request: WSGIRequest, *args: Any, **kwargs: Any) -> None: ...
def get_context_data(self, **kwargs: Any) -> Dict[str, Model]: ...
def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: ...
def get_feed(self, obj: None, request: WSGIRequest) -> SyndicationFeed: ...

View File

@@ -1,7 +1,7 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, Union
from django.core.cache.backends.base import BaseCache as BaseCache
from .backends.base import BaseCache as BaseCache
DEFAULT_CACHE_ALIAS: str

View File

@@ -1,5 +1,4 @@
from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Union
from typing import Any, Callable, Dict, Iterable, List, Optional, Union
from django.core.exceptions import ImproperlyConfigured
@@ -9,7 +8,7 @@ class CacheKeyWarning(RuntimeWarning): ...
DEFAULT_TIMEOUT: Any
MEMCACHE_MAX_KEY_LENGTH: int
def default_key_func(key: Union[int, str], key_prefix: str, version: Union[int, str]) -> str: ...
def default_key_func(key: Any, key_prefix: str, version: Any) -> str: ...
def get_key_func(key_func: Optional[Union[Callable, str]]) -> Callable: ...
class BaseCache:
@@ -17,29 +16,24 @@ class BaseCache:
key_prefix: str = ...
version: int = ...
key_func: Callable = ...
def __init__(self, params: Dict[str, Optional[Union[Callable, Dict[str, int], int, str]]]) -> None: ...
def __init__(self, params: Dict[str, Any]) -> None: ...
def get_backend_timeout(self, timeout: Any = ...) -> Optional[float]: ...
def make_key(self, key: Union[int, str], version: Optional[Union[int, str]] = ...) -> 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 get(self, key: Any, default: Optional[Any] = ..., version: Optional[Any] = ...) -> None: ...
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 touch(self, key: Any, timeout: 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_or_set(
self, key: str, default: Optional[Union[Callable, int, str]], timeout: Any = ..., version: Optional[int] = ...
) -> Optional[Union[int, str]]: ...
self, key: Any, default: Optional[Any], timeout: Any = ..., version: Optional[int] = ...
) -> Optional[Any]: ...
def has_key(self, key: Any, version: Optional[Any] = ...): ...
def incr(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 set_many(
self,
data: Union[Dict[str, bytes], Dict[str, int], Dict[str, str], OrderedDict],
timeout: Any = ...,
version: Optional[Union[int, str]] = ...,
) -> List[Any]: ...
def delete_many(self, keys: Union[Dict[str, str], List[str]], version: None = ...) -> None: ...
def set_many(self, data: Dict[str, Any], timeout: Any = ..., version: Optional[Any] = ...) -> List[Any]: ...
def delete_many(self, keys: Iterable[Any], version: Optional[Any] = ...) -> None: ...
def clear(self) -> None: ...
def validate_key(self, key: str) -> None: ...
def incr_version(self, key: str, delta: int = ..., version: Optional[int] = ...) -> int: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, Dict, Optional, Union
from typing import Any, Dict
from django.core.cache.backends.base import BaseCache
@@ -16,24 +16,7 @@ class Options:
def __init__(self, table: str) -> None: ...
class BaseDatabaseCache(BaseCache):
default_timeout: int
key_func: Callable
key_prefix: str
version: int
cache_model_class: Any = ...
def __init__(self, table: str, params: Dict[str, Union[Callable, Dict[str, int], int, str]]) -> None: ...
def __init__(self, table: str, params: Dict[str, Any]) -> None: ...
class DatabaseCache(BaseDatabaseCache):
default_timeout: int
key_func: Callable
key_prefix: str
version: int
def get(self, key: str, default: Optional[Union[int, str]] = ..., version: Optional[int] = ...) -> Any: ...
def set(self, key: str, value: Any, timeout: Any = ..., version: Optional[int] = ...) -> None: ...
def add(
self, key: str, value: Union[Dict[str, int], bytes, int, str], timeout: Any = ..., version: Optional[int] = ...
) -> bool: ...
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
def delete(self, key: str, version: Optional[int] = ...) -> None: ...
def has_key(self, key: str, version: Optional[int] = ...) -> Any: ...
def clear(self) -> None: ...
class DatabaseCache(BaseDatabaseCache): ...

View File

@@ -1,19 +1,6 @@
from typing import Any, Dict, Optional, Union, Callable
from typing import Any
from django.core.cache.backends.base import BaseCache
class DummyCache(BaseCache):
default_timeout: int
key_func: Callable
key_prefix: str
version: int
def __init__(self, host: str, *args: Any, **kwargs: Any) -> None: ...
def add(self, key: str, value: str, timeout: Any = ..., version: None = ...) -> bool: ...
def get(self, key: str, default: Optional[str] = ..., version: Optional[int] = ...) -> Optional[str]: ...
def set(
self, key: str, value: Union[Dict[str, Any], int, str], timeout: Any = ..., version: Optional[str] = ...
) -> None: ...
def touch(self, key: str, timeout: Any = ..., version: None = ...) -> bool: ...
def delete(self, key: str, version: None = ...) -> None: ...
def has_key(self, key: str, version: None = ...) -> bool: ...
def clear(self) -> None: ...

View File

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

View File

@@ -1,5 +1,5 @@
from typing import Any, List, Optional, Union
from typing import Any, Iterable, Optional
TEMPLATE_FRAGMENT_KEY_TEMPLATE: str
def make_template_fragment_key(fragment_name: str, vary_on: Optional[Union[List[int], List[str]]] = ...) -> str: ...
def make_template_fragment_key(fragment_name: str, vary_on: Optional[Iterable[Any]] = ...) -> str: ...

View File

@@ -0,0 +1,3 @@
from .messages import Warning as Warning, Info as Info, Debug as Debug, Error as Error, Critical as Critical
from .registry import run_checks as run_checks, Tags as Tags, register as register

View File

@@ -1,4 +1,4 @@
from typing import Any, Optional, Union
from typing import Any, Optional
DEBUG: int
INFO: int

View File

@@ -1,4 +1,4 @@
from typing import Any, List, Optional
from typing import Any, List
from django.core.checks.messages import Warning

View File

@@ -1,6 +1,5 @@
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
from typing import Any, Dict, Iterator, List, Mapping, Optional, Tuple, Union
from django.db.models.base import Model
from django.forms.utils import ErrorDict
class FieldDoesNotExist(Exception): ...
@@ -31,20 +30,13 @@ class ValidationError(Exception):
message: Any = ...
code: Any = ...
params: Any = ...
def __init__(
self,
message: Any,
code: Optional[str] = ...,
params: Optional[
Union[Dict[str, Union[Tuple[str], Type[Model], Model, str]], Dict[str, Union[int, str]]]
] = ...,
) -> None: ...
def __init__(self, message: Any, code: Optional[str] = ..., params: Optional[Mapping[str, Any]] = ...) -> None: ...
@property
def message_dict(self) -> Dict[str, List[str]]: ...
@property
def messages(self) -> List[str]: ...
def update_error_dict(
self, error_dict: Union[Dict[str, List[ValidationError]], ErrorDict]
self, error_dict: Mapping[str, Any]
) -> Union[Dict[str, List[ValidationError]], ErrorDict]: ...
def __iter__(self) -> Iterator[Union[Tuple[str, List[str]], str]]: ...

View File

@@ -1,17 +1,15 @@
from ctypes import Structure, c_int64, c_ulong, c_void_p
from io import BufferedRandom, TextIOWrapper
from typing import Union
from ctypes import Structure, Union
from typing import Any
LOCK_SH: int
LOCK_NB: int
LOCK_EX: int
ULONG_PTR = c_int64
ULONG_PTR = c_ulong
PVOID = c_void_p
ULONG_PTR: Any = ...
PVOID: Any = ...
class _OFFSET(Structure): ...
class _OFFSET_UNION(Union): ...
class OVERLAPPED(Structure): ...
def lock(f: Union[BufferedRandom, TextIOWrapper, int], flags: int) -> bool: ...
def unlock(f: Union[BufferedRandom, int]) -> bool: ...
def lock(f: Any, flags: int) -> bool: ...
def unlock(f: Any) -> bool: ...

View File

@@ -1,15 +1,12 @@
from datetime import datetime
from io import StringIO, TextIOWrapper
from typing import Any, List, Optional, Tuple, Union
from typing import Any, IO, List, Optional, Tuple
from django.core.files.base import File
from django.utils.functional import LazyObject
class Storage:
def open(self, name: str, mode: str = ...) -> File: ...
def save(
self, name: Optional[str], content: Union[StringIO, TextIOWrapper, File], max_length: Optional[int] = ...
) -> str: ...
def save(self, name: Optional[str], content: IO[Any], max_length: Optional[int] = ...) -> str: ...
def get_valid_name(self, name: str) -> str: ...
def get_available_name(self, name: str, max_length: Optional[int] = ...) -> str: ...
def generate_filename(self, filename: str) -> str: ...
@@ -31,10 +28,15 @@ class FileSystemStorage(Storage):
file_permissions_mode: Optional[int] = ...,
directory_permissions_mode: Optional[int] = ...,
) -> None: ...
@property
def base_location(self) -> str: ...
@property
def location(self) -> str: ...
@property
def base_url(self) -> str: ...
@property
def file_permissions_mode(self) -> Optional[int]: ...
@property
def directory_permissions_mode(self) -> Optional[int]: ...
class DefaultStorage(LazyObject): ...

View File

@@ -1,45 +1,48 @@
# Stubs for django.core.files.uploadedfile (Python 3.5)
from typing import Any, Dict, IO, Iterator, Optional, Union
from django.core.files import temp as tempfile
from django.core.files.base import File
class UploadedFile(File):
content_type = ... # type: Optional[str]
charset = ... # type: Optional[str]
content_type_extra = ... # type: Optional[Dict[str, str]]
content_type: Optional[str] = ...
charset: Optional[str] = ...
content_type_extra: Optional[Dict[str, str]] = ...
def __init__(
self,
file: IO,
name: str = None,
content_type: str = None,
size: int = None,
charset: str = None,
content_type_extra: Dict[str, str] = None,
file: Optional[IO] = ...,
name: Optional[str] = ...,
content_type: Optional[str] = ...,
size: Optional[int] = ...,
charset: Optional[str] = ...,
content_type_extra: Optional[Dict[str, str]] = ...,
) -> None: ...
class TemporaryUploadedFile(UploadedFile):
def __init__(
self, name: str, content_type: str, size: int, charset: str, content_type_extra: Dict[str, str] = None
self,
name: Optional[str],
content_type: Optional[str],
size: Optional[int],
charset: Optional[str],
content_type_extra: Optional[Dict[str, str]] = ...,
) -> None: ...
def temporary_file_path(self) -> str: ...
class InMemoryUploadedFile(UploadedFile):
field_name = ... # type: Optional[str]
field_name: Optional[str] = ...
def __init__(
self,
file: IO,
field_name: Optional[str],
name: str,
name: Optional[str],
content_type: Optional[str],
size: int,
size: Optional[int],
charset: Optional[str],
content_type_extra: Dict[str, str] = None,
content_type_extra: Dict[str, str] = ...,
) -> None: ...
def chunks(self, chunk_size: int = None) -> Iterator[bytes]: ...
def multiple_chunks(self, chunk_size: int = None) -> bool: ...
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
class SimpleUploadedFile(InMemoryUploadedFile):
def __init__(self, name: str, content: bytes, content_type: str = "") -> None: ...
def __init__(self, name: str, content: Optional[Union[bytes, str]], content_type: str = ...) -> None: ...
@classmethod
def from_dict(cls: Any, file_dict: Dict[str, Union[str, bytes]]) -> None: ...

View File

@@ -1,13 +1,17 @@
from typing import Any, Callable
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse, HttpResponseBase
logger: Any
class BaseHandler:
_view_middleware: None = ...
_template_response_middleware: None = ...
_exception_middleware: None = ...
_middleware_chain: None = ...
def load_middleware(self) -> None: ...
def make_view_atomic(self, view: Callable) -> Callable: ...
def get_exception_response(self, request: Any, resolver: Any, status_code: Any, exception: Any): ...
def get_response(self, request: WSGIRequest) -> HttpResponseBase: ...
def process_exception_by_middleware(self, exception: Exception, request: WSGIRequest) -> HttpResponse: ...
def get_response(self, request: HttpRequest) -> HttpResponseBase: ...
def process_exception_by_middleware(self, exception: Exception, request: HttpRequest) -> HttpResponse: ...

View File

@@ -1,12 +1,12 @@
from typing import Any, Callable
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import HttpRequest
from django.http.response import HttpResponse
from django.urls.resolvers import URLResolver
def convert_exception_to_response(get_response: Callable) -> Callable: ...
def response_for_exception(request: WSGIRequest, exc: Exception) -> HttpResponse: ...
def response_for_exception(request: HttpRequest, exc: Exception) -> HttpResponse: ...
def get_exception_response(
request: WSGIRequest, resolver: URLResolver, status_code: int, exception: Exception, sender: None = ...
request: HttpRequest, resolver: URLResolver, status_code: int, exception: Exception, sender: None = ...
) -> HttpResponse: ...
def handle_uncaught_exception(request: Any, resolver: Any, exc_info: Any): ...

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