mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 22:11:54 +08:00
Compare commits
305 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1af3a12f2c | ||
|
|
7af89ee6a6 | ||
|
|
afa16bfb74 | ||
|
|
f77073157b | ||
|
|
fe3b95c611 | ||
|
|
d0f9730c53 | ||
|
|
0fdd678d65 | ||
|
|
2397065fa6 | ||
|
|
04023a9f31 | ||
|
|
95e6c94319 | ||
|
|
d96aee7a8b | ||
|
|
2489bb9b04 | ||
|
|
3a8f278c88 | ||
|
|
85b65b4578 | ||
|
|
150e8e862a | ||
|
|
5b3088a17a | ||
|
|
f89a0fbbaa | ||
|
|
438f8b5829 | ||
|
|
836d5acd8f | ||
|
|
bfae51e64c | ||
|
|
e3801918e3 | ||
|
|
6f296b0a91 | ||
|
|
7ba578f6b2 | ||
|
|
cb123de105 | ||
|
|
38135f2d1f | ||
|
|
998b659749 | ||
|
|
72f69e1c5e | ||
|
|
d666ecd36f | ||
|
|
c1af26c027 | ||
|
|
3c3dfcbc9f | ||
|
|
1196336e3b | ||
|
|
665f4d8ea1 | ||
|
|
b3ed9e4827 | ||
|
|
fb1593630a | ||
|
|
031d42a75d | ||
|
|
f7e1cfc6c7 | ||
|
|
d0c25e3bce | ||
|
|
1c31e71ffc | ||
|
|
6b3b6be3c1 | ||
|
|
5832605053 | ||
|
|
31e795016f | ||
|
|
0cba3f9fd6 | ||
|
|
f02050911f | ||
|
|
e8e6fca78c | ||
|
|
ade48b6546 | ||
|
|
b8f29027d8 | ||
|
|
eba3f6cb15 | ||
|
|
5a45544e76 | ||
|
|
8c2de7da56 | ||
|
|
d43c6dc7e2 | ||
|
|
f7e2109e06 | ||
|
|
cea62abf5a | ||
|
|
3b69ec6a72 | ||
|
|
7e794534c0 | ||
|
|
f5f33b061d | ||
|
|
58b26fdbd3 | ||
|
|
9ca79c24a2 | ||
|
|
540e28f4c6 | ||
|
|
4ac43c6ed6 | ||
|
|
cadd6c963b | ||
|
|
041754f817 | ||
|
|
c0c5d1e588 | ||
|
|
f824003cc4 | ||
|
|
58f1833cab | ||
|
|
cbb6a7a9ac | ||
|
|
2c4827bbaf | ||
|
|
5a151bf851 | ||
|
|
cbc7159995 | ||
|
|
df4c17a947 | ||
|
|
445abc046c | ||
|
|
557b7a4fa3 | ||
|
|
8343d76895 | ||
|
|
8d986a0f43 | ||
|
|
e9a90ebff0 | ||
|
|
7b74a6944a | ||
|
|
83f11a0fc6 | ||
|
|
2829faf1af | ||
|
|
d061e84cc7 | ||
|
|
3a9263dc62 | ||
|
|
14aea2b4d4 | ||
|
|
287c64d6fb | ||
|
|
6601121db2 | ||
|
|
87d59c7c1a | ||
|
|
8402e7c53e | ||
|
|
dceb075152 | ||
|
|
7e3f4bfa02 | ||
|
|
db9ff6aaf6 | ||
|
|
717be5940f | ||
|
|
b939bc96b7 | ||
|
|
02bdf5be95 | ||
|
|
4d4b0003bd | ||
|
|
e143ba568c | ||
|
|
32c0cbca45 | ||
|
|
acc3ca4205 | ||
|
|
be3fc259d5 | ||
|
|
7725b416b6 | ||
|
|
2c23d8e70f | ||
|
|
5910bd1b25 | ||
|
|
963d50c717 | ||
|
|
7407b93151 | ||
|
|
afcd0d9293 | ||
|
|
a85dbff793 | ||
|
|
68aebe2528 | ||
|
|
d3dca5b408 | ||
|
|
c69090ec5b | ||
|
|
29ac1c3017 | ||
|
|
23ad65033b | ||
|
|
64720f492c | ||
|
|
a8fdd4c673 | ||
|
|
813dd8cc1a | ||
|
|
2b53fa5a1a | ||
|
|
e3ea84143f | ||
|
|
82e3aa5464 | ||
|
|
5b9a467cf0 | ||
|
|
4a4dc53c4d | ||
|
|
77fd46987d | ||
|
|
9291164a6b | ||
|
|
0c3e06e875 | ||
|
|
b8379d4fe6 | ||
|
|
caa0e60743 | ||
|
|
de4fa92441 | ||
|
|
dce0c0e930 | ||
|
|
fc9a335dfd | ||
|
|
5fc39ff110 | ||
|
|
e95b40ef52 | ||
|
|
c91a6d1d5b | ||
|
|
d7e8222163 | ||
|
|
09767210ec | ||
|
|
656105bab2 | ||
|
|
ff7bf33e9c | ||
|
|
d94b7b0c6a | ||
|
|
7bf1664307 | ||
|
|
0545c2d3ea | ||
|
|
825931da9f | ||
|
|
737fd239b6 | ||
|
|
7f476057b0 | ||
|
|
d31512854a | ||
|
|
552de422dc | ||
|
|
a9978cc021 | ||
|
|
bb08212b20 | ||
|
|
5d2efdb80b | ||
|
|
27793ecd32 | ||
|
|
dddcb20fe4 | ||
|
|
ac40b80764 | ||
|
|
6b21a0476d | ||
|
|
735b58e9bf | ||
|
|
b4cd9757b0 | ||
|
|
1b6c337aef | ||
|
|
bc42cc2fa1 | ||
|
|
62dac1d468 | ||
|
|
409c01eb24 | ||
|
|
a0a2ecaf46 | ||
|
|
4c21855641 | ||
|
|
6466c57c69 | ||
|
|
0bb41bc791 | ||
|
|
8894de0a04 | ||
|
|
a019fe9715 | ||
|
|
a97d76020c | ||
|
|
ae8e42dd53 | ||
|
|
64049b60b0 | ||
|
|
b6a5ccabdf | ||
|
|
e6d7a570e8 | ||
|
|
6332620443 | ||
|
|
df021f6baa | ||
|
|
57796077c6 | ||
|
|
46c48b504f | ||
|
|
4dfa363521 | ||
|
|
5b2aacddba | ||
|
|
2c001fd8a7 | ||
|
|
a0db24c764 | ||
|
|
39fb48b08a | ||
|
|
d7d379e1cd | ||
|
|
6962b42cba | ||
|
|
df77299c2f | ||
|
|
b86d33c718 | ||
|
|
fa57fb0cbf | ||
|
|
248504c25a | ||
|
|
fee4aad3d0 | ||
|
|
fc9843bea6 | ||
|
|
5bb1bc250d | ||
|
|
1721c997be | ||
|
|
bba6f769b5 | ||
|
|
07a9bcd4cb | ||
|
|
6ece759ca0 | ||
|
|
caf69ec1c9 | ||
|
|
f2e79d3bfb | ||
|
|
bfa77efef5 | ||
|
|
4f935edd47 | ||
|
|
03b59b872d | ||
|
|
0e72b2e6fc | ||
|
|
b81fbdeaa9 | ||
|
|
dc6101b569 | ||
|
|
d53121baae | ||
|
|
3c3122a93f | ||
|
|
7b1b1b6bfe | ||
|
|
2cb1f257eb | ||
|
|
b11a9a85f9 | ||
|
|
9c5a6be9a7 | ||
|
|
a9c1bcbbc6 | ||
|
|
f365297baf | ||
|
|
6859ec94b6 | ||
|
|
335c5765c3 | ||
|
|
b397ec04a9 | ||
|
|
f7db296e8b | ||
|
|
2f6af159f7 | ||
|
|
2799646723 | ||
|
|
d8230a4147 | ||
|
|
861c6653fd | ||
|
|
db7b46589f | ||
|
|
90cab6c5bf | ||
|
|
25165de80f | ||
|
|
2295b14214 | ||
|
|
a77d5b27d8 | ||
|
|
4e1c32f6a3 | ||
|
|
ea1294bd30 | ||
|
|
79d691732d | ||
|
|
629ba954b4 | ||
|
|
0e60b70ae4 | ||
|
|
dd5b98faf0 | ||
|
|
e634a5d460 | ||
|
|
d7d7e6c66e | ||
|
|
b66727657d | ||
|
|
86642e3ddd | ||
|
|
952e1c3ee9 | ||
|
|
5dd6eccdb5 | ||
|
|
fd06816cbb | ||
|
|
aeb435c8b3 | ||
|
|
13d19017b7 | ||
|
|
28a3f126ee | ||
|
|
304cb19de6 | ||
|
|
c57f4f7152 | ||
|
|
8a826fee1e | ||
|
|
37d85c2ca6 | ||
|
|
71fb0432f3 | ||
|
|
9288c34648 | ||
|
|
70050f28b9 | ||
|
|
4338c17970 | ||
|
|
91f789c38c | ||
|
|
0f5b45fba1 | ||
|
|
5b455b729a | ||
|
|
5c6be7ad12 | ||
|
|
5d0ee40ada | ||
|
|
77f15d7478 | ||
|
|
4f83d8d1bb | ||
|
|
b1a04d2f7d | ||
|
|
7c57143310 | ||
|
|
c3d76f9a1e | ||
|
|
fde071b883 | ||
|
|
324b961d74 | ||
|
|
86c63d790b | ||
|
|
050c1b8887 | ||
|
|
8978ad471f | ||
|
|
f7dfbefbd6 | ||
|
|
627daa55f5 | ||
|
|
194489ee8d | ||
|
|
1d2c7fb805 | ||
|
|
18c908bf98 | ||
|
|
e0e8814804 | ||
|
|
53f5d2214b | ||
|
|
9e4ed70fc5 | ||
|
|
18445f686f | ||
|
|
c962b8ac68 | ||
|
|
70c3126348 | ||
|
|
af8ecc5520 | ||
|
|
64f8870d0b | ||
|
|
df5c70c703 | ||
|
|
c09a97e005 | ||
|
|
0e30821ad3 | ||
|
|
2dadd681ff | ||
|
|
2dec3b4325 | ||
|
|
3b8c5d08e8 | ||
|
|
eaee3d390f | ||
|
|
b686751f19 | ||
|
|
73ea682356 | ||
|
|
9ea25f3e56 | ||
|
|
dacf88c692 | ||
|
|
3d14d07e4e | ||
|
|
6e6d1645d3 | ||
|
|
cda703a94b | ||
|
|
2bd018951b | ||
|
|
14ea848dd7 | ||
|
|
2d3b5492f0 | ||
|
|
194258ab8e | ||
|
|
116aa2c539 | ||
|
|
67c99434e5 | ||
|
|
5d8cdbcf29 | ||
|
|
78810f55b6 | ||
|
|
36662896bc | ||
|
|
e54dbb79c9 | ||
|
|
41f283552a | ||
|
|
ab73d53ae5 | ||
|
|
d24be4b35f | ||
|
|
9d60b472df | ||
|
|
632e063e22 | ||
|
|
66224416b5 | ||
|
|
e5b2496eb5 | ||
|
|
f980311be0 | ||
|
|
400a0f0486 | ||
|
|
882ec71d23 | ||
|
|
e9f9202ed1 | ||
|
|
6763217a80 | ||
|
|
6da5ead6f0 | ||
|
|
c382d6aa2f | ||
|
|
63a14f7107 | ||
|
|
dc33dd9493 |
10
.editorconfig
Normal file
10
.editorconfig
Normal 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
35
.github/ISSUE_TEMPLATE/bug.md
vendored
Normal 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
29
.github/pull_request_template.md
vendored
Normal 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!
|
||||
-->
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -5,6 +5,10 @@ out/
|
||||
/django
|
||||
.idea/
|
||||
.mypy_cache/
|
||||
django-sources
|
||||
build/
|
||||
dist/
|
||||
dist/
|
||||
pip-wheel-metadata/
|
||||
.pytest_cache/
|
||||
/.envrc
|
||||
/.direnv
|
||||
django-sources/
|
||||
52
.travis.yml
52
.travis.yml
@@ -4,31 +4,49 @@ dist: xenial
|
||||
sudo: required
|
||||
jobs:
|
||||
include:
|
||||
- name: Typecheck Django test suite
|
||||
python: 3.7
|
||||
script: 'python ./scripts/typecheck_tests.py'
|
||||
|
||||
- name: Run plugin test suite with python 3.7
|
||||
python: 3.7
|
||||
script: 'pytest'
|
||||
|
||||
- name: Typecheck Django 3.0 test suite with python 3.7
|
||||
python: 3.7
|
||||
script: |
|
||||
set -e
|
||||
pytest
|
||||
python ./scripts/typecheck_tests.py --django_version=3.0
|
||||
|
||||
- name: Typecheck Django 3.0 test suite with python 3.6
|
||||
python: 3.6
|
||||
script: |
|
||||
python ./scripts/typecheck_tests.py --django_version=3.0
|
||||
|
||||
- name: Typecheck Django 2.2 test suite with python 3.7
|
||||
python: 3.7
|
||||
script: |
|
||||
python ./scripts/typecheck_tests.py --django_version=2.2
|
||||
|
||||
- name: Mypy for plugin code
|
||||
python: 3.7
|
||||
script: 'mypy ./mypy_django_plugin'
|
||||
|
||||
- name: Lint with black
|
||||
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 --diff'
|
||||
|
||||
before_install: |
|
||||
# Upgrade pip, setuptools, and wheel
|
||||
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y binutils libproj-dev gdal-bin
|
||||
pip install -U pip setuptools wheel
|
||||
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
|
||||
111
CONTRIBUTING.md
Normal file
111
CONTRIBUTING.md
Normal file
@@ -0,0 +1,111 @@
|
||||
# How to contribute
|
||||
|
||||
## Tutorials
|
||||
|
||||
If you want to start working on this project,
|
||||
you will need to get familiar with these projects:
|
||||
|
||||
- [Django docs](https://docs.djangoproject.com/en/dev/)
|
||||
- [Typing in Python](https://inventwithpython.com/blog/2019/11/24/type-hints-for-busy-python-programmers/)
|
||||
- [How to write custom mypy plugins](https://mypy.readthedocs.io/en/stable/extending_mypy.html)
|
||||
- [Typechecking Django and DRF](https://sobolevn.me/2019/08/typechecking-django-and-drf) guide
|
||||
- [Testing mypy stubs, plugins, and types](https://sobolevn.me/2019/08/testing-mypy-types) guide
|
||||
|
||||
It is also recommended to take a look at these resources:
|
||||
|
||||
- [Awesome Python Typing](https://github.com/typeddjango/awesome-python-typing)
|
||||
|
||||
|
||||
## Dev documentation
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
We use `pip` to manage the dependencies.
|
||||
|
||||
To install them you would need to activate your `virtualenv` and run `install` command:
|
||||
|
||||
```bash
|
||||
pip install -r ./dev-requirements.txt
|
||||
```
|
||||
|
||||
|
||||
## Tests and linters
|
||||
|
||||
We use `mypy`, `pytest`, `flake8`, and `black` for quality control.
|
||||
Here's [how we run our CI](https://github.com/typeddjango/django-stubs/blob/master/.travis.yml).
|
||||
|
||||
### Typechecking
|
||||
|
||||
To run typechecking use:
|
||||
|
||||
```bash
|
||||
mypy ./mypy_django_plugin
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
There are unit tests and type-related tests.
|
||||
|
||||
To run unit tests:
|
||||
|
||||
```bash
|
||||
pytest
|
||||
```
|
||||
|
||||
Type-related tests ensure that different Django versions do work correctly.
|
||||
To run type-related tests:
|
||||
|
||||
```bash
|
||||
python ./scripts/typecheck_tests.py --django_version=2.2
|
||||
python ./scripts/typecheck_tests.py --django_version=3.0
|
||||
```
|
||||
|
||||
Currently we only support two Django versions.
|
||||
|
||||
### Linting
|
||||
|
||||
To run auto-formatting:
|
||||
|
||||
```bash
|
||||
isort -rc .
|
||||
black django-stubs/
|
||||
```
|
||||
|
||||
To run linting:
|
||||
|
||||
```bash
|
||||
flake8
|
||||
flake8 --config flake8-pyi.ini
|
||||
```
|
||||
|
||||
|
||||
## Submitting your code
|
||||
|
||||
We use [trunk based](https://trunkbaseddevelopment.com/)
|
||||
development (we also sometimes call it `wemake-git-flow`).
|
||||
|
||||
What the point of this method?
|
||||
|
||||
1. We use protected `master` branch,
|
||||
so the only way to push your code is via pull request
|
||||
2. We use issue branches: to implement a new feature or to fix a bug
|
||||
create a new branch named `issue-$TASKNUMBER`
|
||||
3. Then create a pull request to `master` branch
|
||||
4. We use `git tag`s to make releases, so we can track what has changed
|
||||
since the latest release
|
||||
|
||||
So, this way we achieve an easy and scalable development process
|
||||
which frees us from merging hell and long-living branches.
|
||||
|
||||
In this method, the latest version of the app is always in the `master` branch.
|
||||
|
||||
|
||||
## Other help
|
||||
|
||||
You can contribute by spreading a word about this library.
|
||||
It would also be a huge contribution to write
|
||||
a short article on how you are using this project.
|
||||
You can also share your best practices with us.
|
||||
119
README.md
119
README.md
@@ -1,49 +1,118 @@
|
||||
<img src="http://mypy-lang.org/static/mypy_light.svg" alt="mypy logo" width="300px"/>
|
||||
|
||||
# pep484 stubs for Django framework
|
||||
# Typesafe Django Framework
|
||||
|
||||
[](https://travis-ci.org/mkurnikov/django-stubs)
|
||||
[](https://travis-ci.com/typeddjango/django-stubs)
|
||||
[](http://mypy-lang.org/)
|
||||
[](https://gitter.im/mypy-django/Lobby)
|
||||
|
||||
This package contains [type stubs](https://www.python.org/dev/peps/pep-0561/) and a custom mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need this project. The final goal is to be able to get precise types for most common patterns.
|
||||
|
||||
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.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
```bash
|
||||
pip install django-stubs
|
||||
```
|
||||
|
||||
To make mypy aware of the plugin, you need to add
|
||||
|
||||
```
|
||||
[mypy]
|
||||
plugins =
|
||||
mypy_django_plugin.main
|
||||
```
|
||||
|
||||
in your `mypy.ini` file.
|
||||
See [Configuration](#configuration) section to get started.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
In order to specify config file, set `MYPY_DJANGO_CONFIG` environment variable with path to the config file. Default is `./mypy_django.ini`
|
||||
To make `mypy` happy, you will need to add:
|
||||
|
||||
Config file format (.ini):
|
||||
```ini
|
||||
[mypy]
|
||||
plugins =
|
||||
mypy_django_plugin.main
|
||||
|
||||
[mypy.plugins.django-stubs]
|
||||
django_settings_module = "myproject.settings"
|
||||
```
|
||||
[mypy_django_plugin]
|
||||
|
||||
# specify settings module to use for django.conf.settings, this setting
|
||||
# could also be specified with DJANGO_SETTINGS_MODULE environment variable
|
||||
# (it also takes priority over config file)
|
||||
django_settings = mysettings.local
|
||||
in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
|
||||
|
||||
# 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
|
||||
Two things happeining here:
|
||||
|
||||
1. We need to explicitly list our plugin to be loaded by `mypy`
|
||||
2. Our plugin also requires `django` settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified
|
||||
|
||||
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
|
||||
|
||||
|
||||
## Version compatibility
|
||||
|
||||
We rely on different `django` and `mypy` versions:
|
||||
|
||||
| django-stubs | mypy version | django version | python version
|
||||
| ------------ | ---- | ---- | ---- |
|
||||
| 1.3.0 | 0.750 | 2.2.x | ^3.6
|
||||
| 1.2.0 | 0.730 | 2.2.x | ^3.6
|
||||
| 1.1.0 | 0.720 | 2.2.x | ^3.6
|
||||
| 0.12.x | old semantic analyzer (<0.711), dmypy support | 2.1.x | ^3.6
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
### Is this an official Django project?
|
||||
|
||||
No, it is not. We are indendepent from Django at the moment.
|
||||
There's a [proposal](https://github.com/django/deps/pull/65) to merge our project into the Django itself.
|
||||
You show your support by linking the PR.
|
||||
|
||||
### Is it safe to use this in production?
|
||||
|
||||
Yes, it is! This project does not affect your runtime at all.
|
||||
It only affects `mypy` type checking process.
|
||||
|
||||
But, it does not make any sense to use this project without `mypy`.
|
||||
|
||||
### mypy crashes when I run it with this plugin installed
|
||||
|
||||
Current implementation uses Django runtime to extract models information, so it will crash, if your installed apps or `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`.
|
||||
|
||||
In other words, if your `manage.py runserver` crashes, mypy will crash too.
|
||||
You can also run `mypy` with [`--tb`](https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-show-traceback)
|
||||
option to get extra information about the error.
|
||||
|
||||
### I cannot use QuerySet or Manager with type annotations
|
||||
|
||||
You can get a `TypeError: 'type' object is not subscriptable`
|
||||
when you will try to use `QuerySet[MyModel]` or `Manager[MyModel]`.
|
||||
|
||||
This happens because Django classes do not support [`__class_getitem__`](https://www.python.org/dev/peps/pep-0560/#class-getitem) magic method.
|
||||
|
||||
You can use strings instead: `'QuerySet[MyModel]'` and `'Manager[MyModel]'`, this way it will work as a type for `mypy` and as a regular `str` in runtime.
|
||||
|
||||
Currently we [are working](https://github.com/django/django/pull/12405) on providing `__class_getitem__` to the classes where we need them.
|
||||
|
||||
### How can I use HttpRequest with custom user model?
|
||||
|
||||
You can subclass standard request like so:
|
||||
|
||||
```python
|
||||
from django.http import HttpRequest
|
||||
from my_user_app.models import MyUser
|
||||
|
||||
class MyRequest(HttpRequest):
|
||||
user: MyUser
|
||||
```
|
||||
|
||||
And then use `MyRequest` instead of standard `HttpRequest` inside your project.
|
||||
|
||||
|
||||
## Related projects
|
||||
|
||||
- [`awesome-python-typing`](https://github.com/typeddjango/awesome-python-typing) - Awesome list of all typing-related things in Python.
|
||||
- [`djangorestframework-stubs`](https://github.com/typeddjango/djangorestframework-stubs) - Stubs for Django REST Framework.
|
||||
- [`pytest-mypy-plugins`](https://github.com/typeddjango/pytest-mypy-plugins) - `pytest` plugin that we use for testing `mypy` stubs and plugins.
|
||||
- [`wemake-django-template`](https://github.com/wemake-services/wemake-django-template) - Create new typed Django projects in seconds.
|
||||
|
||||
|
||||
|
||||
## To get help
|
||||
|
||||
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.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
black
|
||||
-e git+https://github.com/mkurnikov/pytest-mypy-plugins.git#egg=pytest-mypy-plugins
|
||||
pytest-mypy-plugins==1.2.0
|
||||
psycopg2
|
||||
flake8==3.7.9
|
||||
flake8-pyi==19.3.0
|
||||
isort==4.3.21
|
||||
gitpython==3.1.0
|
||||
-e .
|
||||
|
||||
@@ -1,7 +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: ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from typing import Any, Iterator, Type, Optional, Dict
|
||||
|
||||
from django.apps.registry import Apps
|
||||
from django.db.models.base import Model
|
||||
|
||||
MODELS_MODULE_NAME: str
|
||||
@@ -7,12 +8,12 @@ MODELS_MODULE_NAME: str
|
||||
class AppConfig:
|
||||
name: str = ...
|
||||
module: Optional[Any] = ...
|
||||
apps: None = ...
|
||||
apps: Optional[Apps] = ...
|
||||
label: str = ...
|
||||
verbose_name: str = ...
|
||||
path: str = ...
|
||||
models_module: None = ...
|
||||
models: Optional[Dict[str, Type[Model]]] = ...
|
||||
models_module: Optional[str] = ...
|
||||
models: Dict[str, Type[Model]] = ...
|
||||
def __init__(self, app_name: str, app_module: Optional[Any]) -> None: ...
|
||||
@classmethod
|
||||
def create(cls, entry: str) -> AppConfig: ...
|
||||
|
||||
@@ -1,36 +1,37 @@
|
||||
import collections
|
||||
from typing import Any, Callable, List, Optional, Tuple, Type, Union, Iterable, DefaultDict
|
||||
import threading
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.db.migrations.state import AppConfigStub
|
||||
from django.db.models.base import Model
|
||||
|
||||
from .config import AppConfig
|
||||
|
||||
class Apps:
|
||||
all_models: collections.defaultdict = ...
|
||||
app_configs: collections.OrderedDict = ...
|
||||
all_models: Dict[str, Dict[str, Type[Model]]] = ...
|
||||
app_configs: Dict[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: ...
|
||||
_pending_operations: Dict[Tuple[str, str], List]
|
||||
models_ready: bool = ...
|
||||
ready: bool = ...
|
||||
def populate(self, installed_apps: Union[List[AppConfigStub], List[str], Tuple] = ...) -> None: ...
|
||||
def __init__(self, installed_apps: Optional[Iterable[Union[AppConfig, str]]] = ...) -> None: ...
|
||||
def populate(self, installed_apps: Iterable[Union[AppConfig, str]] = ...) -> None: ...
|
||||
def check_apps_ready(self) -> None: ...
|
||||
def check_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]: ...
|
||||
def get_registered_model(self, app_label: str, model_name: str) -> Type[Model]: ...
|
||||
def get_swappable_settings_name(self, to_string: str) -> Optional[str]: ...
|
||||
def set_available_apps(self, available: List[str]) -> None: ...
|
||||
def set_available_apps(self, available: Iterable[str]) -> None: ...
|
||||
def unset_available_apps(self) -> None: ...
|
||||
def set_installed_apps(self, installed: Union[List[str], Tuple[str]]) -> None: ...
|
||||
def set_installed_apps(self, installed: Iterable[str]) -> None: ...
|
||||
def unset_installed_apps(self) -> None: ...
|
||||
def clear_cache(self) -> None: ...
|
||||
def lazy_model_operation(self, function: Callable, *model_keys: Any) -> None: ...
|
||||
|
||||
@@ -2,10 +2,16 @@ from typing import Any
|
||||
|
||||
from django.utils.functional import LazyObject
|
||||
|
||||
# explicit dependency on standard settings to make it loaded
|
||||
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): ...
|
||||
class _DjangoConfLazyObject(LazyObject):
|
||||
def __getattr__(self, item: Any) -> Any: ...
|
||||
|
||||
class LazySettings(_DjangoConfLazyObject):
|
||||
configured: bool
|
||||
@@ -18,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: ...
|
||||
|
||||
@@ -5,14 +5,11 @@ 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
|
||||
from typing import Any, Dict, List, Optional, Pattern, Protocol, Sequence, Tuple, Union
|
||||
|
||||
####################
|
||||
# CORE #
|
||||
####################
|
||||
if TYPE_CHECKING:
|
||||
from django.db.models.base import Model
|
||||
|
||||
DEBUG: bool = ...
|
||||
|
||||
# Whether the framework should propagate raw exceptions rather than catching
|
||||
@@ -153,7 +150,7 @@ FORCE_SCRIPT_NAME = None
|
||||
# ]
|
||||
DISALLOWED_USER_AGENTS: List[Pattern] = ...
|
||||
|
||||
ABSOLUTE_URL_OVERRIDES: Dict[str, Callable[[Model], str]] = ...
|
||||
ABSOLUTE_URL_OVERRIDES: Dict[str, Any] = ...
|
||||
|
||||
# List of compiled regular expression objects representing URLs that need not
|
||||
# be reported by BrokenLinkEmailsMiddleware. Here are a few examples:
|
||||
@@ -348,7 +345,7 @@ SESSION_COOKIE_PATH = "/"
|
||||
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"
|
||||
SESSION_COOKIE_SAMESITE: Optional[str] = ...
|
||||
# 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.
|
||||
@@ -377,7 +374,7 @@ CACHE_MIDDLEWARE_ALIAS = "default"
|
||||
|
||||
AUTH_USER_MODEL: str = ...
|
||||
|
||||
AUTHENTICATION_BACKENDS: List[str] = ...
|
||||
AUTHENTICATION_BACKENDS: Sequence[str] = ...
|
||||
|
||||
LOGIN_URL = "/accounts/login/"
|
||||
|
||||
@@ -416,7 +413,7 @@ CSRF_COOKIE_DOMAIN = None
|
||||
CSRF_COOKIE_PATH = "/"
|
||||
CSRF_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
CSRF_COOKIE_SAMESITE = "Lax"
|
||||
CSRF_COOKIE_SAMESITE: Optional[str] = ...
|
||||
CSRF_HEADER_NAME = "HTTP_X_CSRFTOKEN"
|
||||
CSRF_TRUSTED_ORIGINS: List[str] = ...
|
||||
CSRF_USE_SESSIONS = False
|
||||
|
||||
3
django-stubs/conf/locale/__init__.pyi
Normal file
3
django-stubs/conf/locale/__init__.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Dict, Any
|
||||
|
||||
LANG_INFO: Dict[str, Any] = ...
|
||||
@@ -5,10 +5,10 @@ from django.http.response import HttpResponse, HttpResponseBase
|
||||
|
||||
from django.urls import URLResolver, URLPattern
|
||||
|
||||
handler400: Callable[..., HttpResponse] = ...
|
||||
handler403: Callable[..., HttpResponse] = ...
|
||||
handler404: Callable[..., HttpResponse] = ...
|
||||
handler500: Callable[..., HttpResponse] = ...
|
||||
handler400: Union[str, Callable[..., HttpResponse]] = ...
|
||||
handler403: Union[str, Callable[..., HttpResponse]] = ...
|
||||
handler404: Union[str, Callable[..., HttpResponse]] = ...
|
||||
handler500: Union[str, Callable[..., HttpResponse]] = ...
|
||||
|
||||
IncludedURLConf = Tuple[List[URLResolver], Optional[str], Optional[str]]
|
||||
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from typing import Any, List, Union
|
||||
from typing import Any, List, Union, Iterable, Optional
|
||||
|
||||
from django.contrib.admin.options import BaseModelAdmin, InlineModelAdmin, ModelAdmin
|
||||
from django.contrib.admin.options import BaseModelAdmin
|
||||
from django.core.checks.messages import Error
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
_CheckError = Union[str, Error]
|
||||
|
||||
def check_admin_app(app_configs: None, **kwargs: Any) -> List[_CheckError]: ...
|
||||
def check_admin_app(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[_CheckError]: ...
|
||||
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
|
||||
|
||||
class BaseModelAdminChecks:
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -24,7 +24,7 @@ class SimpleListFilter(ListFilter):
|
||||
parameter_name: Any = ...
|
||||
lookup_choices: Any = ...
|
||||
def value(self) -> Optional[str]: ...
|
||||
def lookups(self, request: Any, model_admin: Any) -> None: ...
|
||||
def lookups(self, request: Any, model_admin: Any) -> List[Tuple[Any, str]]: ...
|
||||
|
||||
class FieldListFilter(ListFilter):
|
||||
field: Field = ...
|
||||
|
||||
@@ -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 = ...
|
||||
|
||||
@@ -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, Iterable
|
||||
|
||||
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: Optional[Iterable[Any]] = ...,
|
||||
model_admin: Any = ...,
|
||||
) -> None: ...
|
||||
def __iter__(self) -> Iterator[Fieldset]: ...
|
||||
@property
|
||||
@@ -57,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] = ...,
|
||||
@@ -74,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: ...
|
||||
@@ -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: ...
|
||||
|
||||
@@ -25,7 +25,7 @@ class LogEntryManager(models.Manager["LogEntry"]):
|
||||
class LogEntry(models.Model):
|
||||
action_time: models.DateTimeField = ...
|
||||
user: models.ForeignKey = ...
|
||||
content_type: models.ForeignKey[ContentType] = ...
|
||||
content_type: models.ForeignKey = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id: models.TextField = ...
|
||||
object_repr: models.CharField = ...
|
||||
action_flag: models.PositiveSmallIntegerField = ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Callable, Dict, List, Optional, Sequence, Set, Tuple, Type, Union, Iterator
|
||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
|
||||
|
||||
from django.contrib.admin.filters import ListFilter
|
||||
from django.contrib.admin.models import LogEntry
|
||||
@@ -8,7 +8,6 @@ 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.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
|
||||
@@ -17,12 +16,13 @@ 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.fields import Field
|
||||
from django.template.response import TemplateResponse
|
||||
|
||||
IS_POPUP_VAR: str
|
||||
TO_FIELD_VAR: str
|
||||
@@ -56,41 +56,45 @@ 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: 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] = ...) -> Any: ...
|
||||
def get_fields(self, request: WSGIRequest, obj: Optional[Model] = ...) -> Sequence[Union[Callable, 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] = ...
|
||||
self, request: HttpRequest, obj: Optional[Model] = ...
|
||||
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
|
||||
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]: ...
|
||||
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, obj: Optional[Model] = ...) -> 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) -> 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: Sequence[Union[str, Callable]] = ...
|
||||
list_display_links: 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 = ...
|
||||
@@ -116,59 +120,58 @@ 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 = ...
|
||||
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] = ...) -> Iterator[Any]: ...
|
||||
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: Any) -> LogEntry: ...
|
||||
def log_change(self, request: WSGIRequest, object: Model, message: Any) -> 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) -> Sequence[str]: ...
|
||||
def get_list_display_links(self, request: WSGIRequest, list_display: Sequence[str]) -> Optional[Sequence[str]]: ...
|
||||
def get_list_filter(self, request: WSGIRequest) -> Sequence[str]: ...
|
||||
def get_list_select_related(self, request: WSGIRequest) -> Sequence[str]: ...
|
||||
def get_search_fields(self, request: WSGIRequest) -> List[str]: ...
|
||||
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_edited_object_pks(self, request: WSGIRequest, prefix: str) -> List[str]: ...
|
||||
def _get_list_editable_queryset(self, request: WSGIRequest, prefix: str) -> QuerySet: ...
|
||||
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 = ...,
|
||||
@@ -176,8 +179,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(
|
||||
@@ -190,52 +193,51 @@ class ModelAdmin(BaseModelAdmin):
|
||||
obj: Optional[Any] = ...,
|
||||
): ...
|
||||
def response_add(
|
||||
self, request: WSGIRequest, obj: Model, post_url_continue: Optional[str] = ...
|
||||
self, request: HttpRequest, obj: Model, post_url_continue: Optional[str] = ...
|
||||
) -> 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_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]] = ...
|
||||
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 = ...
|
||||
@@ -244,18 +246,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): ...
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from django.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
|
||||
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
all_sites: Any
|
||||
|
||||
class AlreadyRegistered(Exception): ...
|
||||
@@ -28,16 +30,16 @@ class AdminSite:
|
||||
name: str = ...
|
||||
_registry: Dict[Type[Model], ModelAdmin]
|
||||
def __init__(self, name: str = ...) -> None: ...
|
||||
def check(self, app_configs: None) -> List[Any]: ...
|
||||
def check(self, app_configs: Optional[Iterable[AppConfig]]) -> List[Any]: ...
|
||||
def register(
|
||||
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 add_action(self, action: Callable, name: Optional[str] = ...) -> None: ...
|
||||
def disable_action(self, name: str) -> None: ...
|
||||
def get_action(self, name: str) -> Callable: ...
|
||||
@property
|
||||
@@ -52,14 +54,20 @@ class AdminSite:
|
||||
@property
|
||||
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: ...
|
||||
def password_change(
|
||||
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
||||
) -> TemplateResponse: ...
|
||||
def password_change_done(
|
||||
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
||||
) -> TemplateResponse: ...
|
||||
def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[Any, Any]] = ...) -> HttpResponse: ...
|
||||
def logout(self, request: WSGIRequest, extra_context: None = ...) -> TemplateResponse: ...
|
||||
def login(self, request: WSGIRequest, extra_context: None = ...) -> HttpResponse: ...
|
||||
def logout(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
|
||||
def login(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
|
||||
def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
|
||||
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, str]] = ...) -> TemplateResponse: ...
|
||||
def app_index(self, request: WSGIRequest, app_label: str, extra_context: None = ...) -> TemplateResponse: ...
|
||||
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
|
||||
def app_index(
|
||||
self, request: WSGIRequest, app_label: str, extra_context: Optional[Dict[str, Any]] = ...
|
||||
) -> TemplateResponse: ...
|
||||
|
||||
class DefaultAdminSite(LazyObject): ...
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class ResultList(list):
|
||||
def results(cl: ChangeList) -> Iterator[ResultList]: ...
|
||||
def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ...
|
||||
def result_list(
|
||||
cl: ChangeList
|
||||
cl: ChangeList,
|
||||
) -> Dict[
|
||||
str, Union[List[Dict[str, Optional[Union[int, str]]]], List[ResultList], List[BoundField], ChangeList, int]
|
||||
]: ...
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
register: Any
|
||||
|
||||
|
||||
23
django-stubs/contrib/admin/tests.pyi
Normal file
23
django-stubs/contrib/admin/tests.pyi
Normal 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: ...
|
||||
@@ -9,12 +9,10 @@ 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.mixins import FieldCacheMixin
|
||||
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
|
||||
|
||||
@@ -27,7 +25,7 @@ def unquote(s: str) -> 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
|
||||
objs: Sequence[Optional[Model]], request: WSGIRequest, admin_site: AdminSite
|
||||
) -> Tuple[List[Any], Dict[Any, Any], Set[Any], List[Any]]: ...
|
||||
|
||||
class NestedObjects(Collector):
|
||||
@@ -41,22 +39,14 @@ class NestedObjects(Collector):
|
||||
model_objs: Any = ...
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def add_edge(self, source: Optional[Model], target: Model) -> None: ...
|
||||
def collect(
|
||||
self,
|
||||
objs: Union[Sequence[Model], QuerySet],
|
||||
source: Optional[Type[Model]] = ...,
|
||||
source_attr: Optional[str] = ...,
|
||||
**kwargs: Any
|
||||
) -> None: ...
|
||||
def related_objects(self, related: ManyToOneRel, objs: List[Model]) -> QuerySet: ...
|
||||
def nested(self, format_callback: Callable = ...) -> Union[List[SafeText], List[int]]: ...
|
||||
def can_fast_delete(self, *args: Any, **kwargs: Any) -> bool: ...
|
||||
def related_objects(self, related: ManyToOneRel, objs: Sequence[Optional[Model]]) -> QuerySet: ...
|
||||
def nested(self, format_callback: Callable = ...) -> List[Any]: ...
|
||||
|
||||
def model_format_dict(obj: Any): ...
|
||||
def model_ngettext(obj: Union[Options, QuerySet], n: Optional[int] = ...) -> str: ...
|
||||
def lookup_field(
|
||||
name: Union[Callable, str], obj: Model, model_admin: BaseModelAdmin = ...
|
||||
) -> Tuple[Optional[Field], Callable, Callable]: ...
|
||||
) -> Tuple[Optional[Field], Any, Any]: ...
|
||||
def label_for_field(
|
||||
name: Union[Callable, str],
|
||||
model: Type[Model],
|
||||
@@ -65,16 +55,14 @@ def label_for_field(
|
||||
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(
|
||||
value: Any, field: Union[Field, reverse_related.OneToOneRel], empty_value_display: str
|
||||
) -> str: ...
|
||||
def display_for_field(value: Any, field: Field, empty_value_display: str) -> str: ...
|
||||
def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ...
|
||||
|
||||
class NotRelationField(Exception): ...
|
||||
|
||||
def get_model_from_relation(field: Union[Field, reverse_related.ForeignObjectRel]) -> Type[Model]: ...
|
||||
def reverse_field_path(model: Type[Model], path: str) -> Tuple[Type[Model], str]: ...
|
||||
def get_fields_from_path(model: Type[Model], path: str) -> List[Union[Field, FieldCacheMixin]]: ...
|
||||
def get_fields_from_path(model: Type[Model], path: str) -> List[Field]: ...
|
||||
def construct_change_message(
|
||||
form: AdminPasswordChangeForm, formsets: None, add: bool
|
||||
) -> List[Dict[str, Dict[str, List[str]]]]: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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
|
||||
@@ -77,9 +81,7 @@ class ChangeList:
|
||||
paginator: Any = ...
|
||||
def get_results(self, request: WSGIRequest) -> None: ...
|
||||
def get_ordering_field(self, field_name: Union[Callable, str]) -> Optional[Union[CombinedExpression, str]]: ...
|
||||
def get_ordering(
|
||||
self, request: WSGIRequest, queryset: QuerySet
|
||||
) -> Union[List[Union[Combinable, str]], List[Union[OrderBy, str]]]: ...
|
||||
def get_ordering(self, request: WSGIRequest, queryset: QuerySet) -> List[Union[OrderBy, Combinable, str]]: ...
|
||||
def get_ordering_field_columns(self) -> OrderedDict: ...
|
||||
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
|
||||
def apply_select_related(self, qs: QuerySet) -> QuerySet: ...
|
||||
|
||||
@@ -1,18 +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, 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 Media
|
||||
|
||||
from django import forms
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
from django.db.models.fields.reverse_related import ForeignObjectRel, ManyToOneRel, ManyToManyRel
|
||||
from django.db.models.query_utils import Q
|
||||
from django.forms.fields import Field
|
||||
from django.forms.widgets import ChoiceWidget, Media, Widget, DateTimeBaseInput
|
||||
from django.http.request import QueryDict
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
|
||||
class FilteredSelectMultiple(forms.SelectMultiple):
|
||||
@property
|
||||
@@ -20,111 +14,36 @@ 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: 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: 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: AutocompleteSelect = ...
|
||||
widget: forms.Widget = ...
|
||||
rel: ManyToOneRel = ...
|
||||
can_add_related: bool = ...
|
||||
can_change_related: bool = ...
|
||||
@@ -133,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] = ...,
|
||||
@@ -141,54 +60,22 @@ 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): ...
|
||||
|
||||
class AdminUUIDInputWidget(forms.TextInput):
|
||||
def __init__(self, attrs: Optional[Dict[str, str]] = ...) -> None: ...
|
||||
|
||||
SELECT2_TRANSLATIONS: Any
|
||||
|
||||
@@ -208,12 +95,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: ...
|
||||
|
||||
|
||||
3
django-stubs/contrib/admindocs/urls.pyi
Normal file
3
django-stubs/contrib/admindocs/urls.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Any, List
|
||||
|
||||
urlpatterns: List[Any] = ...
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
from typing import Any, Optional, Set, Union
|
||||
|
||||
from django.contrib.auth.base_user import AbstractBaseUser
|
||||
from django.contrib.auth.models import AnonymousUser, User
|
||||
from django.contrib.auth.models import AnonymousUser, User, Permission
|
||||
|
||||
from django.db.models.base import Model
|
||||
|
||||
_AnyUser = Union[Model, AnonymousUser]
|
||||
|
||||
UserModel: Any
|
||||
|
||||
class ModelBackend:
|
||||
class BaseBackend:
|
||||
def authenticate(
|
||||
self, request: Any, username: Optional[Union[int, str]] = ..., password: Optional[str] = ..., **kwargs: Any
|
||||
self, request: Any, username: Optional[str] = ..., password: Optional[str] = ..., **kwargs: Any
|
||||
) -> Optional[AbstractBaseUser]: ...
|
||||
def user_can_authenticate(self, user: Optional[AbstractBaseUser]) -> bool: ...
|
||||
def get_user_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, user_obj: AbstractBaseUser, obj: None = ...) -> Set[str]: ...
|
||||
def get_all_permissions(self, user_obj: AbstractBaseUser, obj: Optional[str] = ...) -> Set[str]: ...
|
||||
def has_perm(
|
||||
self, user_obj: Union[AbstractBaseUser, AnonymousUser], perm: str, obj: Optional[str] = ...
|
||||
) -> bool: ...
|
||||
def has_module_perms(self, user_obj: Union[AbstractBaseUser, AnonymousUser], app_label: str) -> bool: ...
|
||||
def get_user(self, user_id: int) -> AbstractBaseUser: ...
|
||||
def get_user(self, user_id: int) -> Optional[AbstractBaseUser]: ...
|
||||
def get_user_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
|
||||
def get_all_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
|
||||
def has_perm(self, user_obj: _AnyUser, perm: str, obj: Optional[Model] = ...) -> bool: ...
|
||||
|
||||
class ModelBackend(BaseBackend):
|
||||
def has_module_perms(self, user_obj: _AnyUser, app_label: str) -> bool: ...
|
||||
def user_can_authenticate(self, user: Optional[_AnyUser]) -> bool: ...
|
||||
def with_perm(
|
||||
self,
|
||||
perm: Union[str, Permission],
|
||||
is_active: bool = ...,
|
||||
include_superusers: bool = ...,
|
||||
obj: Optional[Model] = ...,
|
||||
): ...
|
||||
|
||||
class AllowAllUsersModelBackend(ModelBackend): ...
|
||||
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
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 = ...
|
||||
REQUIRED_FIELDS: List[str] = ...
|
||||
class Meta: ...
|
||||
|
||||
password = models.CharField(max_length=128)
|
||||
last_login = models.DateTimeField(blank=True, null=True)
|
||||
def get_username(self) -> str: ...
|
||||
def clean(self) -> None: ...
|
||||
def save(self, *args: Any, **kwargs: Any) -> None: ...
|
||||
def natural_key(self) -> Tuple[str]: ...
|
||||
@property
|
||||
def is_anonymous(self) -> bool: ...
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import Any, List, Optional
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
from django.core.checks.messages import CheckMessage
|
||||
|
||||
from .management import _get_builtin_permissions
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def check_user_model(app_configs: None = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def check_models_permissions(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
def check_user_model(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||
def check_models_permissions(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||
|
||||
@@ -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]: ...
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
from typing import Any, Callable, List, Optional, Set, Union
|
||||
from typing import Callable, List, Optional, Set, Union, TypeVar, overload
|
||||
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
|
||||
from django.http.response import HttpResponseBase
|
||||
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
|
||||
_VIEW = TypeVar("_VIEW", bound=Callable[..., HttpResponseBase])
|
||||
|
||||
def user_passes_test(
|
||||
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...
|
||||
) -> Callable: ...
|
||||
def login_required(
|
||||
function: Optional[Callable] = ..., redirect_field_name: str = ..., login_url: Optional[str] = ...
|
||||
) -> Callable: ...
|
||||
test_func: Callable[[AbstractUser], bool], login_url: Optional[str] = ..., redirect_field_name: str = ...
|
||||
) -> Callable[[_VIEW], _VIEW]: ...
|
||||
|
||||
# There are two ways of calling @login_required: @with(arguments) and @bare
|
||||
@overload
|
||||
def login_required(redirect_field_name: str = ..., login_url: Optional[str] = ...) -> Callable[[_VIEW], _VIEW]: ...
|
||||
@overload
|
||||
def login_required(function: _VIEW, redirect_field_name: str = ..., login_url: Optional[str] = ...) -> _VIEW: ...
|
||||
def permission_required(
|
||||
perm: Union[List[str], Set[str], str], login_url: None = ..., raise_exception: bool = ...
|
||||
) -> Callable: ...
|
||||
) -> Callable[[_VIEW], _VIEW]: ...
|
||||
|
||||
@@ -1,76 +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 = ...
|
||||
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 = ...
|
||||
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 = ...
|
||||
@@ -83,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] = ...,
|
||||
@@ -117,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 = ...
|
||||
@@ -135,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 = ...
|
||||
@@ -168,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]: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Dict
|
||||
|
||||
UserModel: Any
|
||||
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 test_func(self) -> Optional[bool]: ...
|
||||
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: ...
|
||||
|
||||
@@ -1,61 +1,82 @@
|
||||
from typing import Any, List, Optional, Set, Tuple, Type, Union
|
||||
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar, Union
|
||||
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
from django.contrib.auth.base_user import AbstractBaseUser as AbstractBaseUser, BaseUserManager as BaseUserManager
|
||||
from django.contrib.auth.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
|
||||
|
||||
_AnyUser = Union[Model, "AnonymousUser"]
|
||||
|
||||
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
|
||||
|
||||
class PermissionManager(models.Manager):
|
||||
class PermissionManager(models.Manager["Permission"]):
|
||||
def get_by_natural_key(self, codename: str, app_label: str, model: str) -> Permission: ...
|
||||
|
||||
class Permission(models.Model):
|
||||
content_type_id: int
|
||||
name: models.CharField = ...
|
||||
content_type: models.ForeignKey[ContentType] = ...
|
||||
codename: models.CharField = ...
|
||||
objects: PermissionManager
|
||||
|
||||
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):
|
||||
class GroupManager(models.Manager["Group"]):
|
||||
def get_by_natural_key(self, name: str) -> Group: ...
|
||||
|
||||
class Group(models.Model):
|
||||
name: models.CharField = ...
|
||||
permissions: models.ManyToManyField[Permission] = ...
|
||||
objects: GroupManager
|
||||
|
||||
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: ...
|
||||
def with_perm(
|
||||
self,
|
||||
perm: Union[str, Permission],
|
||||
is_active: bool = ...,
|
||||
include_superusers: bool = ...,
|
||||
backend: Optional[Union[Type[ModelBackend], str]] = ...,
|
||||
obj: Optional[Model] = ...,
|
||||
): ...
|
||||
|
||||
class PermissionsMixin(models.Model):
|
||||
is_superuser: models.BooleanField = ...
|
||||
groups: models.ManyToManyField[Group] = ...
|
||||
user_permissions: 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: ...
|
||||
is_superuser = models.BooleanField()
|
||||
groups = models.ManyToManyField(Group)
|
||||
user_permissions = models.ManyToManyField(Permission)
|
||||
def get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_module_perms(self, app_label: str) -> bool: ...
|
||||
|
||||
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: ...
|
||||
@@ -77,10 +98,11 @@ class AnonymousUser:
|
||||
def groups(self) -> EmptyManager: ...
|
||||
@property
|
||||
def user_permissions(self) -> EmptyManager: ...
|
||||
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 get_user_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def get_group_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[Any]: ...
|
||||
def get_all_permissions(self, obj: Optional[_AnyUser] = ...) -> Set[str]: ...
|
||||
def has_perm(self, perm: str, obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||
def has_module_perms(self, module: str) -> bool: ...
|
||||
@property
|
||||
def is_anonymous(self) -> bool: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
3
django-stubs/contrib/auth/urls.pyi
Normal file
3
django-stubs/contrib/auth/urls.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Any, List
|
||||
|
||||
urlpatterns: List[Any] = ...
|
||||
@@ -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,29 +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, Any]: ...
|
||||
|
||||
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(
|
||||
@@ -56,55 +40,33 @@ 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 = ...
|
||||
reset_url_token: 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: ...
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from typing import Any, List, Optional
|
||||
from typing import Any, List, Iterable, Optional
|
||||
|
||||
def check_generic_foreign_keys(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
def check_model_name_lengths(app_configs: None = ..., **kwargs: Any) -> List[Any]: ...
|
||||
from django.apps.config import AppConfig
|
||||
|
||||
def check_generic_foreign_keys(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||
def check_model_name_lengths(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||
|
||||
@@ -3,17 +3,22 @@ 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): ...
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,19 +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 = ...
|
||||
def clean_url(self) -> str: ...
|
||||
def clean(self) -> Dict[str, Union[bool, QuerySet, str]]: ...
|
||||
|
||||
@@ -9,5 +9,5 @@ class FlatPage(models.Model):
|
||||
enable_comments: models.BooleanField = ...
|
||||
template_name: models.CharField = ...
|
||||
registration_required: models.BooleanField = ...
|
||||
sites: models.ManyToManyField[Site] = ...
|
||||
sites: models.ManyToManyField[Site, Site] = ...
|
||||
def get_absolute_url(self) -> str: ...
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
3
django-stubs/contrib/flatpages/urls.pyi
Normal file
3
django-stubs/contrib/flatpages/urls.pyi
Normal file
@@ -0,0 +1,3 @@
|
||||
from typing import Any, List
|
||||
|
||||
urlpatterns: List[Any] = ...
|
||||
@@ -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
|
||||
|
||||
0
django-stubs/contrib/gis/db/__init__.pyi
Normal file
0
django-stubs/contrib/gis/db/__init__.pyi
Normal file
13
django-stubs/contrib/gis/db/models/__init__.pyi
Normal file
13
django-stubs/contrib/gis/db/models/__init__.pyi
Normal 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,
|
||||
)
|
||||
91
django-stubs/contrib/gis/db/models/fields.pyi
Normal file
91
django-stubs/contrib/gis/db/models/fields.pyi
Normal 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): ...
|
||||
@@ -1,15 +1,14 @@
|
||||
from datetime import date, datetime as datetime
|
||||
from decimal import Decimal
|
||||
from typing import Any, Optional, Union
|
||||
from typing import Any, Optional, SupportsInt, Union
|
||||
|
||||
register: Any
|
||||
|
||||
def ordinal(value: Optional[str]) -> Optional[str]: ...
|
||||
def intcomma(value: Optional[Union[Decimal, float, str]], use_l10n: bool = ...) -> str: ...
|
||||
def ordinal(value: Optional[Union[str, SupportsInt]]) -> Optional[str]: ...
|
||||
def intcomma(value: Optional[Union[str, SupportsInt]], use_l10n: bool = ...) -> str: ...
|
||||
|
||||
intword_converters: Any
|
||||
|
||||
def intword(value: Optional[str]) -> Optional[Union[int, str]]: ...
|
||||
def apnumber(value: Optional[str]) -> Optional[Union[int, str]]: ...
|
||||
def intword(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
||||
def apnumber(value: Optional[Union[str, SupportsInt]]) -> Optional[Union[int, str]]: ...
|
||||
def naturalday(value: Optional[Union[date, str]], arg: None = ...) -> Optional[str]: ...
|
||||
def naturaltime(value: datetime) -> str: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
11
django-stubs/contrib/messages/constants.pyi
Normal file
11
django-stubs/contrib/messages/constants.pyi
Normal 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] = ...
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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 = ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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]]: ...
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from typing import Dict, Optional
|
||||
from typing import Dict
|
||||
|
||||
def get_level_tags() -> Dict[int, str]: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
24
django-stubs/contrib/postgres/aggregates/__init__.pyi
Normal file
24
django-stubs/contrib/postgres/aggregates/__init__.pyi
Normal 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,
|
||||
)
|
||||
11
django-stubs/contrib/postgres/aggregates/general.pyi
Normal file
11
django-stubs/contrib/postgres/aggregates/general.pyi
Normal 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): ...
|
||||
1
django-stubs/contrib/postgres/aggregates/mixins.pyi
Normal file
1
django-stubs/contrib/postgres/aggregates/mixins.pyi
Normal file
@@ -0,0 +1 @@
|
||||
class OrderableAggMixin: ...
|
||||
14
django-stubs/contrib/postgres/aggregates/statistics.pyi
Normal file
14
django-stubs/contrib/postgres/aggregates/statistics.pyi
Normal 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): ...
|
||||
18
django-stubs/contrib/postgres/constraints.pyi
Normal file
18
django-stubs/contrib/postgres/constraints.pyi
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import Optional, Sequence, Tuple, Union
|
||||
|
||||
from django.db.models.constraints import BaseConstraint
|
||||
from django.db.models.expressions import Combinable
|
||||
from django.db.models.query_utils import Q
|
||||
|
||||
class ExclusionConstraint(BaseConstraint):
|
||||
expressions: Sequence[Tuple[Union[str, Combinable], str]]
|
||||
index_type: str
|
||||
condition: Optional[Q]
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
name: str,
|
||||
expressions: Sequence[Tuple[Union[str, Combinable], str]],
|
||||
condition: Optional[Q] = ...,
|
||||
index_type: Optional[str] = ...,
|
||||
): ...
|
||||
@@ -4,8 +4,17 @@ from .ranges import (
|
||||
RangeField as RangeField,
|
||||
IntegerRangeField as IntegerRangeField,
|
||||
BigIntegerRangeField as BigIntegerRangeField,
|
||||
DecimalRangeField as DecimalRangeField,
|
||||
FloatRangeField as FloatRangeField,
|
||||
DateRangeField as DateRangeField,
|
||||
DateTimeRangeField as DateTimeRangeField,
|
||||
RangeOperators as RangeOperators,
|
||||
RangeBoundary as RangeBoundary,
|
||||
)
|
||||
from .hstore import HStoreField as HStoreField
|
||||
from .citext import (
|
||||
CICharField as CICharField,
|
||||
CIEmailField as CIEmailField,
|
||||
CIText as CIText,
|
||||
CITextField as CITextField,
|
||||
)
|
||||
|
||||
@@ -1,20 +1,51 @@
|
||||
from typing import Any, Generic, List, Optional, Sequence, TypeVar
|
||||
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: Optional[int] = ..., **kwargs: Any) -> 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 get_transform(self, name: Any): ...
|
||||
def __set__(self, instance, value: Sequence[_T]) -> None: ...
|
||||
def __get__(self, instance, owner) -> List[_T]: ...
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -26,3 +29,20 @@ class DateTimeRangeField(RangeField):
|
||||
|
||||
class DateRangeField(RangeField):
|
||||
def __get__(self, instance, owner) -> DateRange: ...
|
||||
|
||||
class RangeOperators:
|
||||
EQUAL: str
|
||||
NOT_EQUAL: str
|
||||
CONTAINS: str
|
||||
CONTAINED_BY: str
|
||||
OVERLAPS: str
|
||||
FULLY_LT: str
|
||||
FULLY_GT: str
|
||||
NOT_LT: str
|
||||
NOT_GT: str
|
||||
ADJACENT_TO: str
|
||||
|
||||
class RangeBoundary(models.Expression):
|
||||
lower: str
|
||||
upper: str
|
||||
def __init__(self, inclusive_lower: bool = ..., inclusive_upper: bool = ...): ...
|
||||
|
||||
4
django-stubs/contrib/postgres/functions.pyi
Normal file
4
django-stubs/contrib/postgres/functions.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from django.db.models import Func
|
||||
|
||||
class RandomUUID(Func): ...
|
||||
class TransactionNow(Func): ...
|
||||
82
django-stubs/contrib/postgres/indexes.pyi
Normal file
82
django-stubs/contrib/postgres/indexes.pyi
Normal 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: ...
|
||||
18
django-stubs/contrib/postgres/lookups.pyi
Normal file
18
django-stubs/contrib/postgres/lookups.pyi
Normal 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): ...
|
||||
63
django-stubs/contrib/postgres/search.pyi
Normal file
63
django-stubs/contrib/postgres/search.pyi
Normal 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): ...
|
||||
5
django-stubs/contrib/postgres/signals.pyi
Normal file
5
django-stubs/contrib/postgres/signals.pyi
Normal 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: ...
|
||||
17
django-stubs/contrib/postgres/validators.pyi
Normal file
17
django-stubs/contrib/postgres/validators.pyi
Normal 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): ...
|
||||
@@ -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: ...
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
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): ...
|
||||
@@ -18,8 +16,8 @@ class SessionBase(Dict[str, Any]):
|
||||
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 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): ...
|
||||
@@ -33,7 +31,7 @@ class SessionBase(Dict[str, Any]):
|
||||
def get_expire_at_browser_close(self) -> bool: ...
|
||||
def flush(self) -> None: ...
|
||||
def cycle_key(self) -> None: ...
|
||||
def exists(self, session_key: str) -> 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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
from typing import 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
|
||||
from django.contrib.sessions.models import Session
|
||||
from django.core.signing import Serializer
|
||||
from django.db.models.base import Model
|
||||
|
||||
class SessionStore(SessionBase):
|
||||
accessed: bool
|
||||
serializer: Type[Serializer]
|
||||
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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
@@ -1,20 +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 = ...
|
||||
@classmethod
|
||||
def get_session_store_class(cls) -> None: ...
|
||||
def get_session_store_class(cls) -> Optional[Type[SessionBase]]: ...
|
||||
def get_decoded(self) -> Dict[str, int]: ...
|
||||
|
||||
4
django-stubs/contrib/sessions/exceptions.pyi
Normal file
4
django-stubs/contrib/sessions/exceptions.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from django.core.exceptions import SuspiciousOperation
|
||||
|
||||
class InvalidSessionKey(SuspiciousOperation): ...
|
||||
class SuspiciousSession(SuspiciousOperation): ...
|
||||
@@ -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): ...
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user