138 Commits

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

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

* add current directory to sys.path

* remove PYTHONPATH mention from the docs

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

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

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

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

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

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

* isort: use --diff

* known_first_party = mypy_django_plugin

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

* install gdal in ci

* add sudo to apt

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

* make typecheck_tests CI really work

* fix lints

* fix intentional error

* merge stderr in stdout to preserve order

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

Exit non-zero if it fails to run.

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

* exit on unexpected rc, and output on stderr

* Fix

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

Already in config, adding a final newline there.

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

* return corresponding descriptors for file fields in class access

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

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

* bump to 1.0.1

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

Closes #104

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

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

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

* Add missing 'get_candidate_relations_to_delete' function signature

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

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

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

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

* Improve type for CursorWrapper.execute(params)

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

Signed-off-by: aszlig <aszlig@nix.build>
2019-05-19 19:59:00 +03:00
Anthony Ricaud
b66727657d Type non-parametrised views.decorators.http (#80)
Fixes `error: Untyped decorator makes function "view" untyped`
2019-05-17 20:40:40 +03:00
289 changed files with 7518 additions and 5867 deletions

10
.editorconfig Normal file
View File

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

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

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

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

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

4
.gitignore vendored
View File

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

4
.gitmodules vendored Normal file
View File

@@ -0,0 +1,4 @@
[submodule "django-sources"]
path = django-sources
url = https://github.com/django/django.git
branch = stable/2.2.x

View File

@@ -6,43 +6,39 @@ jobs:
include:
- name: Run plugin test suite with python 3.7
python: 3.7
script: |
set -e
pytest
script: 'pytest'
- name: Run plugin test suite with python 3.6
python: 3.6
script: |
set -e
pytest
- name: Typecheck Django test suite
- name: Typecheck Django test suite with python 3.7
python: 3.7
script: 'python ./scripts/typecheck_tests.py'
- name: Typecheck Django test suite with python 3.6
python: 3.6
script: 'python ./scripts/typecheck_tests.py'
- name: Mypy for plugin code
python: 3.7
script: 'mypy ./mypy_django_plugin'
- name: Lint with black
python: 3.7
script: 'black --check --line-length=120 django-stubs/'
script: 'black --check django-stubs/'
- name: Lint plugin code with flake8
python: 3.7
script: 'flake8'
- name: Lint stubs with flake8-pyi and check for unused imports
python: 3.7
script: 'flake8 --config flake8-pyi.ini'
- name: Lint plugin code with isort
python: 3.7
script: 'isort --check'
script: 'isort --check --diff'
before_install: |
# Upgrade pip, setuptools, and wheel
sudo apt update
sudo apt install binutils libproj-dev gdal-bin
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

@@ -2,55 +2,83 @@
# pep484 stubs for Django framework
[![Build Status](https://travis-ci.org/mkurnikov/django-stubs.svg?branch=master)](https://travis-ci.org/mkurnikov/django-stubs)
[![Build Status](https://travis-ci.org/typeddjango/django-stubs.svg?branch=master)](https://travis-ci.org/typeddjango/django-stubs)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Gitter](https://badges.gitter.im/mypy-django/Lobby.svg)](https://gitter.im/mypy-django/Lobby)
This package contains type stubs and mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns.
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
```
```bash
pip install django-stubs
```
## Mypy compatibility
| django-stubs | mypy version | django version | python version
| ------------ | ---- | ---- | ---- |
| 1.2.0 | 0.730 | 2.2.x | ^3.6
| 1.1.0 | 0.720 | 2.2.x | ^3.6
| 0.12.x | old semantic analyzer (<0.711), dmypy support | 2.1.x | ^3.6
## Configuration
To make mypy aware of the plugin, you need to add
```
```ini
[mypy]
plugins =
mypy_django_plugin.main
```
in your `mypy.ini` file.
in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
Plugin also requires Django settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified.
## Configuration
```ini
[mypy]
strict_optional = True
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):
# This one is new:
[mypy.plugins.django-stubs]
django_settings_module = mysettings
```
[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
Where `mysettings` is a value of `DJANGO_SETTINGS_MODULE` (with or without quotes)
# 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
Current implementation uses Django runtime to extract models information, so it will crash, if your installed apps `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`.
# if True, unknown attributes on Model instances won't produce errors
ignore_missing_model_attributes = True
In other words, if your `manage.py runserver` crashes, mypy will crash too.
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
## Notes
Type implementation monkey-patches Django to add `__class_getitem__` to the `Manager` class.
If you would use Python3.7 and do that too in your code, you can make things like
```python
class MyUserManager(models.Manager['MyUser']):
pass
class MyUser(models.Model):
objects = UserManager()
```
work, which should make a error messages a bit better.
Otherwise, custom type will be created in mypy, named `MyUser__MyUserManager`, which will rewrite base manager as `models.Manager[User]` to make methods like `get_queryset()` and others return properly typed `QuerySet`.
## To get help
We have Gitter here https://gitter.im/mypy-django/Lobby.
We have Gitter here: <https://gitter.im/mypy-django/Lobby>
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.
If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.

View File

@@ -1,5 +1,7 @@
black
pytest-mypy-plugins
flake8
isort==4.3.4
pytest-mypy-plugins==1.1.0
psycopg2
flake8==3.7.8
flake8-pyi==19.3.0
isort==4.3.21
-e .

1
django-sources Submodule

Submodule django-sources added at f452d4232e

View File

@@ -1,5 +1,6 @@
import collections
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict
import threading
from collections import OrderedDict
from typing import Any, Callable, DefaultDict, Dict, Iterable, List, Optional, Tuple, Type, Union
from django.db.migrations.state import AppConfigStub
from django.db.models.base import Model
@@ -7,22 +8,24 @@ from django.db.models.base import Model
from .config import AppConfig
class Apps:
all_models: collections.defaultdict = ...
app_configs: collections.OrderedDict = ...
all_models: Dict[str, OrderedDict[str, Type[Model]]] = ...
app_configs: OrderedDict[str, AppConfig] = ...
stored_app_configs: List[Any] = ...
apps_ready: bool = ...
ready_event: threading.Event = ...
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 = ...
def __init__(self, installed_apps: Optional[Union[List[AppConfigStub], List[str], Tuple]] = ...) -> None: ...
def populate(self, installed_apps: Union[List[AppConfigStub], List[str], Tuple] = ...) -> None: ...
def check_apps_ready(self) -> None: ...
def check_models_ready(self) -> None: ...
def get_app_configs(self) -> Iterable[AppConfig]: ...
def get_app_config(self, app_label: str) -> AppConfig: ...
# it's not possible to support it in plugin properly now
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Model]]: ...
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Model]: ...
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ...
def register_model(self, app_label: str, model: Type[Model]) -> None: ...
def is_installed(self, app_name: str) -> bool: ...
def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ...

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
from typing import Any, List, Union
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin
from django.contrib.admin.options import BaseModelAdmin
from django.core.checks.messages import Error
_CheckError = Union[str, Error]

View File

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

View File

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

View File

@@ -56,7 +56,6 @@ class BaseModelAdmin:
show_full_result_count: bool = ...
checks_class: Any = ...
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
def __init__(self) -> None: ...
def formfield_for_dbfield(
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
) -> Optional[Field]: ...
@@ -94,7 +93,6 @@ class BaseModelAdmin:
def has_module_permission(self, request: HttpRequest) -> bool: ...
class ModelAdmin(BaseModelAdmin):
formfield_overrides: Any
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]]]] = ...
@@ -122,7 +120,6 @@ class ModelAdmin(BaseModelAdmin):
actions_on_top: bool = ...
actions_on_bottom: bool = ...
actions_selection_counter: bool = ...
checks_class: Any = ...
model: Type[Model] = ...
opts: Options = ...
admin_site: AdminSite = ...

View File

@@ -1,11 +1,11 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
from django.contrib.admin.options import ModelAdmin
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.http.response import HttpResponse
from django.template.response import TemplateResponse
from django.urls.resolvers import URLPattern, URLResolver
from django.urls.resolvers import URLResolver
from django.utils.functional import LazyObject
all_sites: Any
@@ -31,11 +31,11 @@ class AdminSite:
def check(self, app_configs: None) -> List[Any]: ...
def register(
self,
model_or_iterable: Union[List[Type[Model]], Tuple[Type[Model]], Type[Model]],
model_or_iterable: Union[Type[Model], Iterable[Type[Model]]],
admin_class: Optional[Type[ModelAdmin]] = ...,
**options: Any
) -> None: ...
def unregister(self, model_or_iterable: Type[Model]) -> None: ...
def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ...
def is_registered(self, model: Type[Model]) -> bool: ...
def add_action(self, action: Callable, name: None = ...) -> None: ...
def disable_action(self, name: str) -> None: ...

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,11 @@ from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
from django.contrib.admin.filters import ListFilter, SimpleListFilter
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.options import ( # noqa: F401
ModelAdmin,
IS_POPUP_VAR as IS_POPUP_VAR,
TO_FIELD_VAR as TO_FIELD_VAR,
)
from django.core.handlers.wsgi import WSGIRequest
from django.db.models.base import Model
from django.db.models.expressions import Combinable, CombinedExpression, OrderBy

View File

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

View File

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

View File

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

View File

@@ -1,22 +1,24 @@
from typing import Any, Optional, Tuple, List, overload
from typing import Any, Optional, Tuple, List, overload, TypeVar
from django.db.models.base import Model
from django.db import models
class BaseUserManager(models.Manager):
_T = TypeVar("_T", bound=Model)
class BaseUserManager(models.Manager[_T]):
@classmethod
def normalize_email(cls, email: Optional[str]) -> str: ...
def make_random_password(self, length: int = ..., allowed_chars: str = ...) -> str: ...
def get_by_natural_key(self, username: Optional[str]) -> AbstractBaseUser: ...
def get_by_natural_key(self, username: Optional[str]) -> _T: ...
class AbstractBaseUser(models.Model):
password: models.CharField = ...
last_login: Optional[models.DateTimeField] = ...
is_active: models.BooleanField = ...
password = models.CharField(max_length=128)
last_login = models.DateTimeField(blank=True, null=True)
REQUIRED_FIELDS: List[str] = ...
class Meta: ...
def get_username(self) -> str: ...
def clean(self) -> None: ...
def save(self, *args: Any, **kwargs: Any) -> None: ...
def natural_key(self) -> Tuple[str]: ...
@property
def is_anonymous(self) -> bool: ...

View File

@@ -1,6 +1,6 @@
from typing import Any, Callable, List, Optional, Set, Union
from typing import Callable, List, Optional, Set, Union
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
def user_passes_test(
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, List, Optional
from typing import Any, Callable, List
from django import http
from django.http.response import HttpResponse, HttpResponseRedirect

View File

@@ -1,10 +1,11 @@
from typing import Any, List, Optional, Set, Tuple, Type, Union
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.contrib.contenttypes.models import ContentType
from django.db.models.base import Model
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: ...
@@ -14,48 +15,52 @@ class PermissionManager(models.Manager):
class Permission(models.Model):
content_type_id: int
name: models.CharField = ...
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
codename: models.CharField = ...
name = models.CharField(max_length=255)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
codename = models.CharField(max_length=100)
def natural_key(self) -> Tuple[str, str, str]: ...
class GroupManager(models.Manager):
def get_by_natural_key(self, name: str) -> Group: ...
class Group(models.Model):
name: models.CharField = ...
permissions: models.ManyToManyField = models.ManyToManyField(Permission)
name = models.CharField(max_length=150)
permissions = models.ManyToManyField(Permission)
def natural_key(self): ...
class UserManager(BaseUserManager):
_T = TypeVar("_T", bound=Model)
class UserManager(BaseUserManager[_T]):
def create_user(
self, username: str, email: Optional[str] = ..., password: Optional[str] = ..., **extra_fields: Any
) -> AbstractUser: ...
) -> _T: ...
def create_superuser(
self, username: str, email: Optional[str], password: Optional[str], **extra_fields: Any
) -> AbstractBaseUser: ...
) -> _T: ...
class PermissionsMixin(models.Model):
is_superuser: models.BooleanField = ...
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_perm(self, perm: str, obj: Optional[str] = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: None = ...) -> bool: ...
def has_module_perms(self, app_label: str) -> bool: ...
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 = ...
username = models.CharField(max_length=150)
first_name = models.CharField(max_length=30, blank=True)
last_name = models.CharField(max_length=150, blank=True)
email = models.EmailField(blank=True)
is_staff = models.BooleanField()
is_active = models.BooleanField()
date_joined = models.DateTimeField()
EMAIL_FIELD: str = ...
USERNAME_FIELD: str = ...
def clean(self) -> None: ...
def get_full_name(self) -> str: ...
def get_short_name(self) -> str: ...
def email_user(self, subject: str, message: str, from_email: str = ..., **kwargs: Any) -> None: ...
@@ -80,7 +85,7 @@ class AnonymousUser:
def get_group_permissions(self, obj: None = ...) -> Set[Any]: ...
def get_all_permissions(self, obj: Any = ...) -> Set[str]: ...
def has_perm(self, perm: str, obj: None = ...) -> bool: ...
def has_perms(self, perm_list: Union[List[str], Tuple[str]], obj: None = ...) -> bool: ...
def has_perms(self, perm_list: Collection[str], obj: None = ...) -> bool: ...
def has_module_perms(self, module: str) -> bool: ...
@property
def is_anonymous(self) -> bool: ...

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

View File

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,6 +18,9 @@ class IntegerRangeField(RangeField):
class BigIntegerRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class DecimalRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...
class FloatRangeField(RangeField):
def __get__(self, instance, owner) -> NumericRange: ...

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
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
from . import model_checks as model_checks

View File

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

View File

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

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,4 +1,4 @@
from typing import Any, List, Optional
from typing import Any, List
from django.core.checks.messages import Warning

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,4 +1,4 @@
from typing import Any, List, Optional
from typing import Any, List
from django.core.checks.messages import Error

View File

@@ -0,0 +1,7 @@
from typing import Any, List
from . import Error
E001: Error = ...
def check_setting_language_code(app_configs: Any, **kwargs: Any) -> List[Error]: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, List, Optional, Tuple, Union
from typing import Any, Callable, List, Tuple, Union
from django.core.checks.messages import CheckMessage, Error, Warning
from django.urls.resolvers import URLPattern, URLResolver

View File

@@ -1,32 +1,39 @@
import types
from io import StringIO
from typing import Any, Iterator, Optional, Union
from typing import Any, IO, Iterator, Optional, Type, TypeVar, Union
from django.core.files.utils import FileProxyMixin
class File(FileProxyMixin):
_T = TypeVar("_T", bound="File")
class File(FileProxyMixin, IO[Any]):
DEFAULT_CHUNK_SIZE: Any = ...
file: StringIO = ...
name: Optional[str] = ...
name: str = ...
mode: str = ...
def __init__(self, file: Any, name: Optional[str] = ...) -> None: ...
def __bool__(self) -> bool: ...
def __len__(self) -> int: ...
@property
def size(self) -> int: ...
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[Union[bytes, bytearray]]: ...
def multiple_chunks(self, chunk_size: Optional[Any] = ...): ...
def chunks(self, chunk_size: Optional[int] = ...) -> Iterator[bytes]: ...
def multiple_chunks(self, chunk_size: Optional[int] = ...) -> bool: ...
def __iter__(self) -> Iterator[Union[bytes, str]]: ...
def __enter__(self) -> File: ...
def __exit__(self, exc_type: None, exc_value: None, tb: None) -> None: ...
def open(self, mode: Optional[str] = ...) -> File: ...
def __next__(self) -> Union[bytes, str]: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_value: Optional[BaseException],
tb: Optional[types.TracebackType],
) -> bool: ...
def open(self: _T, mode: Optional[str] = ...) -> _T: ...
def close(self) -> None: ...
class ContentFile(File):
file: StringIO
size: Any = ...
def __init__(self, content: Union[bytes, str], name: Optional[str] = ...) -> None: ...
def __bool__(self) -> bool: ...
def open(self, mode: Optional[str] = ...) -> ContentFile: ...
def close(self) -> None: ...
def write(self, data: str) -> int: ...
def endswith_cr(line: bytes) -> bool: ...

View File

@@ -1,5 +1,4 @@
from io import BytesIO
from typing import Any, Union
from typing import Any, IO, Union
from django.core.files import File
@@ -11,4 +10,4 @@ class ImageFile(File):
@property
def height(self) -> int: ...
def get_image_dimensions(file_or_path: Union[BytesIO, str], close: bool = ...) -> Any: ...
def get_image_dimensions(file_or_path: Union[str, IO[bytes]], close: bool = ...) -> Any: ...

View File

@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, IO, List, Optional, Tuple
from typing import Any, IO, List, Optional, Tuple, Type
from django.core.files.base import File
from django.utils.functional import LazyObject
@@ -13,7 +13,7 @@ class Storage:
def path(self, name: str) -> str: ...
def delete(self, name: str) -> None: ...
def exists(self, name: str) -> bool: ...
def listdir(self, path: Any) -> Optional[Tuple[List[str], List[str]]]: ...
def listdir(self, path: str) -> Tuple[List[str], List[str]]: ...
def size(self, name: str) -> int: ...
def url(self, name: Optional[str]) -> str: ...
def get_accessed_time(self, name: str) -> datetime: ...
@@ -21,6 +21,7 @@ class Storage:
def get_modified_time(self, name: str) -> datetime: ...
class FileSystemStorage(Storage):
OS_OPEN_FLAGS: int = ...
def __init__(
self,
location: Optional[str] = ...,
@@ -42,3 +43,5 @@ class FileSystemStorage(Storage):
class DefaultStorage(LazyObject): ...
default_storage: Any
def get_storage_class(import_path: Optional[str] = ...) -> Type[Storage]: ...

View File

@@ -1,5 +1,5 @@
from typing import Any, Dict, IO, Iterator, Optional, Union
from django.core.files import temp as tempfile
from typing import Any, Dict, IO, Optional, Union
from django.core.files.base import File
class UploadedFile(File):
@@ -39,8 +39,6 @@ class InMemoryUploadedFile(UploadedFile):
charset: Optional[str],
content_type_extra: Dict[str, str] = ...,
) -> None: ...
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: Optional[Union[bytes, str]], content_type: str = ...) -> None: ...

View File

@@ -8,8 +8,8 @@ from django.utils.datastructures import MultiValueDict
class UploadFileException(Exception): ...
class StopUpload(UploadFileException):
connection_reset = ... # type: bool
def __init__(self, connection_reset: bool = False) -> None: ...
connection_reset: bool = ...
def __init__(self, connection_reset: bool = ...) -> None: ...
class SkipFile(UploadFileException): ...
class StopFutureHandlers(UploadFileException): ...
@@ -23,9 +23,14 @@ class FileUploadHandler:
content_type_extra = ... # type: Optional[Dict[str, str]]
request = ... # type: Optional[HttpRequest]
field_name = ... # type: str
def __init__(self, request: HttpRequest = None) -> None: ...
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
def handle_raw_input(
self, input_data: IO[bytes], META: Dict[str, str], content_length: int, boundary: str, encoding: str = None
self,
input_data: IO[bytes],
META: Dict[str, str],
content_length: int,
boundary: str,
encoding: Optional[str] = ...,
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
def new_file(
self,
@@ -33,15 +38,15 @@ class FileUploadHandler:
file_name: str,
content_type: str,
content_length: Optional[int],
charset: str = None,
content_type_extra: Dict[str, str] = None,
charset: Optional[str] = ...,
content_type_extra: Optional[Dict[str, str]] = ...,
) -> None: ...
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
def upload_complete(self) -> None: ...
class TemporaryFileUploadHandler(FileUploadHandler):
def __init__(self, request: HttpRequest = None) -> None: ...
def __init__(self, request: Optional[HttpRequest] = ...) -> None: ...
file = ... # type: TemporaryUploadedFile
def new_file(
self,
@@ -49,8 +54,8 @@ class TemporaryFileUploadHandler(FileUploadHandler):
file_name: str,
content_type: str,
content_length: Optional[int],
charset: str = None,
content_type_extra: Dict[str, str] = None,
charset: Optional[str] = ...,
content_type_extra: Optional[Dict[str, str]] = ...,
) -> None: ...
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...
@@ -59,7 +64,12 @@ class MemoryFileUploadHandler(FileUploadHandler):
activated = ... # type: bool
file = ... # type: IO[bytes]
def handle_raw_input(
self, input_data: IO[bytes], META: Dict[str, str], content_length: int, boundary: str, encoding: str = None
self,
input_data: IO[bytes],
META: Dict[str, str],
content_length: int,
boundary: str,
encoding: Optional[str] = ...,
) -> Optional[Tuple[QueryDict, MultiValueDict[str, UploadedFile]]]: ...
def new_file(
self,
@@ -67,8 +77,8 @@ class MemoryFileUploadHandler(FileUploadHandler):
file_name: str,
content_type: str,
content_length: Optional[int],
charset: str = None,
content_type_extra: Dict[str, str] = None,
charset: Optional[str] = ...,
content_type_extra: Optional[Dict[str, str]] = ...,
) -> None: ...
def receive_data_chunk(self, raw_data: bytes, start: int) -> Optional[bytes]: ...
def file_complete(self, file_size: int) -> Optional[UploadedFile]: ...

View File

@@ -6,10 +6,6 @@ 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): ...

View File

@@ -0,0 +1,16 @@
import types
from typing import Any, TypeVar, Type, Iterable
from django.core.mail.message import EmailMessage
_T = TypeVar("_T", bound="BaseEmailBackend")
class BaseEmailBackend:
def __init__(self, fail_silently: bool = ..., **kwargs: Any) -> None: ...
def open(self) -> bool: ...
def close(self) -> None: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self, exc_type: Type[BaseException], exc_value: BaseException, traceback: types.TracebackType
) -> None: ...
def send_messages(self, email_messages: Iterable[EmailMessage]) -> int: ...

View File

@@ -65,13 +65,14 @@ class EmailMessage:
to: Optional[Union[Sequence[str], str]] = ...,
bcc: Optional[Union[Sequence[str], str]] = ...,
connection: Optional[Any] = ...,
attachments: Optional[Union[List[Tuple[str, str]], List[MIMEText]]] = ...,
attachments: Optional[Union[List[Tuple[str, Union[str, bytes], str]], List[MIMEText]]] = ...,
headers: Optional[Dict[str, str]] = ...,
cc: Optional[Union[Sequence[str], str]] = ...,
reply_to: Optional[Union[List[Optional[str]], str]] = ...,
) -> None: ...
def get_connection(self, fail_silently: bool = ...) -> Any: ...
def message(self) -> MIMEMixin: ...
# TODO: when typeshed gets more types for email.Message, move it to MIMEMessage, now it has too many false-positives
def message(self) -> Any: ...
def recipients(self) -> List[str]: ...
def send(self, fail_silently: bool = ...) -> int: ...
def attach(

View File

@@ -1,11 +1,11 @@
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Tuple, Union
from django.core.management.base import BaseCommand as BaseCommand, CommandError as CommandError
from .base import BaseCommand as BaseCommand, CommandError as CommandError
def find_commands(management_dir: str) -> List[str]: ...
def load_command_class(app_name: str, name: str) -> BaseCommand: ...
def get_commands() -> Dict[str, str]: ...
def call_command(command_name: Union[Tuple[str], BaseCommand, str], *args: Any, **options: Any) -> Optional[str]: ...
def call_command(command_name: Union[Tuple[str], BaseCommand, str], *args: Any, **options: Any) -> str: ...
class ManagementUtility:
argv: List[str] = ...

View File

@@ -1,6 +1,6 @@
from argparse import ArgumentParser, HelpFormatter, Namespace
from io import StringIO, TextIOBase, TextIOWrapper
from typing import Any, Callable, List, Optional, Union
from typing import Any, Callable, List, Optional, Union, Tuple
from django.apps.config import AppConfig
from django.core.management.color import Style
@@ -36,16 +36,20 @@ class BaseCommand:
output_transaction: bool = ...
requires_migrations_checks: bool = ...
requires_system_checks: bool = ...
base_stealth_options: Any = ...
stealth_options: Any = ...
base_stealth_options: Tuple[str, ...] = ...
stealth_options: Tuple[str, ...] = ...
stdout: OutputWrapper = ...
stderr: OutputWrapper = ...
style: Style = ...
def __init__(
self, stdout: Optional[StringIO] = ..., stderr: Optional[StringIO] = ..., no_color: bool = ...
self,
stdout: Optional[StringIO] = ...,
stderr: Optional[StringIO] = ...,
no_color: bool = ...,
force_color: bool = ...,
) -> None: ...
def get_version(self) -> str: ...
def create_parser(self, prog_name: str, subcommand: str) -> CommandParser: ...
def create_parser(self, prog_name: str, subcommand: str, **kwargs: Any) -> CommandParser: ...
def add_arguments(self, parser: CommandParser) -> None: ...
def print_help(self, prog_name: str, subcommand: str) -> None: ...
def run_from_argv(self, argv: List[str]) -> None: ...
@@ -59,7 +63,7 @@ class BaseCommand:
fail_level: int = ...,
) -> None: ...
def check_migrations(self) -> None: ...
def handle(self, *args: Any, **options: Any) -> None: ...
def handle(self, *args: Any, **options: Any) -> Optional[str]: ...
class AppCommand(BaseCommand):
missing_args_message: str = ...

View File

@@ -1,7 +1,12 @@
def supports_color() -> bool: ...
class Style: ...
class Style:
def DEBUG(self, text: str) -> str: ...
def INFO(self, text: str) -> str: ...
def SUCCESS(self, text: str) -> str: ...
def WARNING(self, text: str) -> str: ...
def ERROR(self, text: str) -> str: ...
def make_style(config_string: str = ...) -> Style: ...
def no_style(): ...
def no_style() -> Style: ...
def color_style() -> Style: ...

View File

@@ -0,0 +1,4 @@
from django.core.management.base import BaseCommand
class ProxyModelWarning(Warning): ...
class Command(BaseCommand): ...

View File

@@ -0,0 +1,19 @@
import zipfile
from typing import Iterable, List, Optional, Tuple
from django.core.management.base import BaseCommand
READ_STDIN: str = ...
class Command(BaseCommand):
missing_args_message: str = ...
def loaddata(self, fixture_labels: Iterable[str]) -> None: ...
def load_label(self, fixture_label: str) -> None: ...
def find_fixtures(self, fixture_label: str) -> List[Optional[str]]: ...
@property
def fixture_dirs(self) -> List[str]: ...
def parse_name(self, fixture_name: str) -> Tuple[str, str, str]: ...
class SingleZipReader(zipfile.ZipFile): ...
def humanize(dirname: str) -> str: ...

View File

@@ -0,0 +1,38 @@
from typing import Any, Optional, Pattern, Type
from django.core.management.base import BaseCommand
plural_forms_re: Pattern = ...
STATUS_OK: int = ...
NO_LOCALE_DIR: Any = ...
def check_programs(*programs: str) -> None: ...
class TranslatableFile:
dirpath: str
file_name: str
locale_dir: str
def __init__(self, dirpath: str, file_name: str, locale_dir: Optional[str]) -> None: ...
class BuildFile:
"""
Represent the state of a translatable file during the build process.
"""
def __init__(self, command: BaseCommand, domain: str, translatable: TranslatableFile) -> None: ...
@property
def is_templatized(self) -> bool: ...
@property
def path(self) -> str: ...
@property
def work_path(self) -> str: ...
def preprocess(self) -> None: ...
def postprocess_messages(self, msgs: str) -> str: ...
def cleanup(self) -> None: ...
def normalize_eols(raw_contents: str) -> str: ...
def write_pot_file(potfile: str, msgs: str) -> None: ...
class Command(BaseCommand):
translatable_file_class: Type[TranslatableFile] = ...
build_file_class: Type[BuildFile] = ...

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