mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-10 22:11:54 +08:00
Compare commits
139 Commits
new-readme
...
jedi-v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28afe59881 | ||
|
|
54e5ecc16a | ||
|
|
418437b00c | ||
|
|
eb195b61e9 | ||
|
|
993dd816a4 | ||
|
|
e6dcfe4fc6 | ||
|
|
8f9e77ce39 | ||
|
|
a1334a70b9 | ||
|
|
a8d8561d0e | ||
|
|
bdc7db1154 | ||
|
|
49ed9c957f | ||
|
|
4829ce2200 | ||
|
|
9fe1a76779 | ||
|
|
153613eddb | ||
|
|
b6cb50e729 | ||
|
|
344dea06b5 | ||
|
|
01a9ad12e1 | ||
|
|
0a0e1985d7 | ||
|
|
f07477260f | ||
|
|
11c3f8cd11 | ||
|
|
159f8b95ba | ||
|
|
58c087f7f5 | ||
|
|
2e9adce5eb | ||
|
|
47bd07758b | ||
|
|
36d1778e2a | ||
|
|
caaa23ab8f | ||
|
|
cfd9379b58 | ||
|
|
362342d998 | ||
|
|
d3ff5415db | ||
|
|
eecf13a2fe | ||
|
|
d9c851abce | ||
|
|
896cbe4752 | ||
|
|
f3e0872d6e | ||
|
|
4cb13a6ac5 | ||
|
|
19d695b1da | ||
|
|
16326e999c | ||
|
|
517ae648e5 | ||
|
|
3e0f144148 | ||
|
|
8a68111ce5 | ||
|
|
9f966a8056 | ||
|
|
0c41d0c6e9 | ||
|
|
e798b496c0 | ||
|
|
01af2ff588 | ||
|
|
aab8acf2ea | ||
|
|
1c4a7d25c7 | ||
|
|
a0d61c0de3 | ||
|
|
e837dac26a | ||
|
|
bbdf15a6ec | ||
|
|
f08b428027 | ||
|
|
44151c485d | ||
|
|
a3624dec36 | ||
|
|
9a9a0123c7 | ||
|
|
d3d854dac8 | ||
|
|
6dc2c32382 | ||
|
|
695cdb16ca | ||
|
|
cb1fa08a82 | ||
|
|
e2f6abe579 | ||
|
|
ffb6551eb4 | ||
|
|
40c8bfa510 | ||
|
|
402b7d563f | ||
|
|
92eb068a04 | ||
|
|
9d4d06f8b3 | ||
|
|
d746e3f5e4 | ||
|
|
8729a74f81 | ||
|
|
56361b353e | ||
|
|
b71c9ad282 | ||
|
|
ce370ea79f | ||
|
|
2a732fd257 | ||
|
|
645ee97e78 | ||
|
|
5bc3759ea2 | ||
|
|
534a028ea2 | ||
|
|
87856754ea | ||
|
|
2f7fac2eaf | ||
|
|
5ff99fd047 | ||
|
|
f77ebcd22c | ||
|
|
34b126e3da | ||
|
|
6e5f5f2cdb | ||
|
|
95252cde60 | ||
|
|
6ef2cf0331 | ||
|
|
9f3b95841b | ||
|
|
e764b1cf4c | ||
|
|
8a64d87917 | ||
|
|
60f3f9dd9f | ||
|
|
ca10ee9242 | ||
|
|
f651f27ddf | ||
|
|
3915aa0639 | ||
|
|
97ec2ee43b | ||
|
|
19c73a106d | ||
|
|
92ef5d9d95 | ||
|
|
f16d1b8cb6 | ||
|
|
c3cdc1c2d5 | ||
|
|
3704d0ab98 | ||
|
|
b1d619edb2 | ||
|
|
e680326c72 | ||
|
|
574a87e68c | ||
|
|
82ae1751ed | ||
|
|
69042783b1 | ||
|
|
391bbc59d5 | ||
|
|
28c76df3b2 | ||
|
|
3d2534ea8d | ||
|
|
54f5f63e71 | ||
|
|
4c5723d368 | ||
|
|
7e0e43135d | ||
|
|
e05b84e32d | ||
|
|
71751d3795 | ||
|
|
25f92e8e56 | ||
|
|
28d47c7e93 | ||
|
|
197cb4058e | ||
|
|
dac2b31fb2 | ||
|
|
8d2600136a | ||
|
|
570772f973 | ||
|
|
d5c1bfb12a | ||
|
|
64cbb0f70e | ||
|
|
6f5a39625e | ||
|
|
bf604a0398 | ||
|
|
92c8dfc93f | ||
|
|
c10c55052c | ||
|
|
96914e466b | ||
|
|
90ed7f332d | ||
|
|
a801501151 | ||
|
|
8ea59985df | ||
|
|
2964ed53d7 | ||
|
|
1b9176f994 | ||
|
|
54d0d018c6 | ||
|
|
1af3a12f2c | ||
|
|
7af89ee6a6 | ||
|
|
afa16bfb74 | ||
|
|
f77073157b | ||
|
|
fe3b95c611 | ||
|
|
d0f9730c53 | ||
|
|
0fdd678d65 | ||
|
|
2397065fa6 | ||
|
|
04023a9f31 | ||
|
|
95e6c94319 | ||
|
|
d96aee7a8b | ||
|
|
2489bb9b04 | ||
|
|
3a8f278c88 | ||
|
|
85b65b4578 | ||
|
|
150e8e862a |
20
.github/workflows/misspel.yml
vendored
Normal file
20
.github/workflows/misspel.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: misspell
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: sobolevn/misspell-fixer-action@0.1.0
|
||||||
|
- uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
commit-message: 'Fixes by misspell-fixer'
|
||||||
|
title: 'Typos fix by misspell-fixer'
|
||||||
85
.github/workflows/test.yml
vendored
Normal file
85
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
name: test
|
||||||
|
|
||||||
|
on: [push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.9']
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-lint-${{ hashFiles('./dev-requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-${{ matrix.python-version }}-lint-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -U pip setuptools wheel
|
||||||
|
pip install -r ./dev-requirements.txt
|
||||||
|
|
||||||
|
- name: Run pre-commit
|
||||||
|
run: pre-commit install && pre-commit run --all-files
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.7']
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup system dependencies
|
||||||
|
run: sudo apt-get install binutils libproj-dev gdal-bin
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-test-${{ hashFiles('./dev-requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-${{ matrix.python-version }}-test-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -U pip setuptools wheel
|
||||||
|
pip install -r ./dev-requirements.txt
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pytest
|
||||||
|
|
||||||
|
typecheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ['3.6', '3.7', '3.8', '3.9']
|
||||||
|
django-version: ['2.2', '3.0']
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup system dependencies
|
||||||
|
run: sudo apt-get install binutils libproj-dev gdal-bin
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.django-version }}-typecheck-${{ hashFiles('./dev-requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ matrix.django-version }}-typecheck-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -U pip setuptools wheel
|
||||||
|
pip install -r ./dev-requirements.txt
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: python ./scripts/typecheck_tests.py --django_version="${{ matrix.django-version }}"
|
||||||
18
.gitignore
vendored
18
.gitignore
vendored
@@ -1,14 +1,12 @@
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
__pycache__/
|
.DS_Store
|
||||||
out/
|
|
||||||
/test_sqlite.py
|
|
||||||
/django
|
|
||||||
.idea/
|
.idea/
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
build/
|
|
||||||
dist/
|
|
||||||
pip-wheel-metadata/
|
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
/.envrc
|
.venv/
|
||||||
/.direnv
|
__pycache__/
|
||||||
django-sources/
|
django-source/
|
||||||
|
out/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
stubgen/
|
||||||
|
build/
|
||||||
|
|||||||
46
.pre-commit-config.yaml
Normal file
46
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# See https://pre-commit.com for more information
|
||||||
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
|
default_language_version:
|
||||||
|
python: python3.9
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v3.3.0
|
||||||
|
hooks:
|
||||||
|
- id: check-yaml
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: debug-statements
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
|
rev: v2.7.3
|
||||||
|
hooks:
|
||||||
|
- id: pyupgrade
|
||||||
|
args: ["--py36-plus"]
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-isort
|
||||||
|
rev: v5.6.4
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 20.8b1
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
|
rev: 3.8.4
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: mypy
|
||||||
|
name: mypy
|
||||||
|
entry: mypy
|
||||||
|
language: system
|
||||||
|
types: [ python ]
|
||||||
|
exclude: "scripts/|django_stubs_ext/"
|
||||||
|
args: [ "--config=mypy.ini", "--cache-dir=/dev/null", "--no-incremental" ]
|
||||||
|
- id: mypy
|
||||||
|
name: mypy (django_stubs_ext)
|
||||||
|
entry: mypy
|
||||||
|
language: system
|
||||||
|
types: [ python ]
|
||||||
|
files: "django_stubs_ext/|django_stubs_ext/tests/"
|
||||||
|
args: [ "--config=mypy.ini", "--cache-dir=/dev/null", "--no-incremental", "--strict" ]
|
||||||
52
.travis.yml
52
.travis.yml
@@ -1,52 +0,0 @@
|
|||||||
language: python
|
|
||||||
cache: pip
|
|
||||||
dist: xenial
|
|
||||||
sudo: required
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- 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: |
|
|
||||||
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 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: |
|
|
||||||
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
|
|
||||||
112
CONTRIBUTING.md
Normal file
112
CONTRIBUTING.md
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
# Contribution Guide
|
||||||
|
|
||||||
|
This project is open source and community driven. As such we encourage code contributions of all kinds. Some areas you can contribute in:
|
||||||
|
|
||||||
|
1. Improve the stubs
|
||||||
|
2. Sync stubs with the latest version of Django
|
||||||
|
3. Improve plugin code and extend its capabilities
|
||||||
|
4. Write tests
|
||||||
|
5. Update dependencies
|
||||||
|
|
||||||
|
## Tutorials
|
||||||
|
|
||||||
|
If you want to start working on this project, you will need to get familiar with python typings.
|
||||||
|
The Mypy documentation offers an excellent resource for this, as well as the python official documentation:
|
||||||
|
|
||||||
|
- [Mypy typing documentation](https://mypy.readthedocs.io/en/stable/#overview-type-system-reference)
|
||||||
|
- [Python official typing documentation](https://docs.python.org/3/library/typing.html)
|
||||||
|
- [Typing in Python](https://inventwithpython.com/blog/2019/11/24/type-hints-for-busy-python-programmers/) article
|
||||||
|
|
||||||
|
Additionally, the following resources might be useful:
|
||||||
|
|
||||||
|
- [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
|
||||||
|
- [Awesome Python Typing](https://github.com/typeddjango/awesome-python-typing) list
|
||||||
|
|
||||||
|
## Dev setup
|
||||||
|
|
||||||
|
### Repository Setup
|
||||||
|
|
||||||
|
As a first step you will need to fork this repository and clone your fork locally.
|
||||||
|
In order to be able to continously sync your fork with the origin repository's master branch, you will need to set up an upstream master. To do so follow this [official github guide](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/syncing-a-fork).
|
||||||
|
|
||||||
|
### Dependency Setup
|
||||||
|
|
||||||
|
After your repository is setup you will then need to create and activate a git ignored virtual env, e.g.:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
```
|
||||||
|
|
||||||
|
Then install the dev requirements:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r ./dev-requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, install the pre-commit hooks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pre-commit install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Testing and Linting
|
||||||
|
|
||||||
|
We use `mypy`, `pytest`, `flake8`, and `black` for quality control. All tools except pytest are executed using pre-commit when you make a commit.
|
||||||
|
To ensure there are not formatting or typing issues in the entire repository you can run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pre-commit run --all-files
|
||||||
|
```
|
||||||
|
|
||||||
|
NOTE: This command will not only lint but also modify files - so make sure to commit whatever changes you've made before hand.
|
||||||
|
You can also run pre-commit per file or for a specific path, simply replace "--all-files" with a target (see [this guide](https://codeburst.io/tool-your-django-project-pre-commit-hooks-e1799d84551f) for more info).
|
||||||
|
|
||||||
|
To execute the unit tests, simply run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pytest
|
||||||
|
```
|
||||||
|
|
||||||
|
We also test the stubs against the Django's own test suite. This is done in CI but you can also do this locally.
|
||||||
|
To execute the script run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python ./scripts/typecheck_tests.py --django_version 3.0
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Generating Stubs using Stubgen
|
||||||
|
|
||||||
|
The stubs are based on auto-generated code created by Mypy's stubgen tool (see: [the stubgen docs](https://mypy.readthedocs.io/en/stable/stubgen.html)).
|
||||||
|
To make life easier we have a helper script that auto generates these stubs. To use it you can run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python ./scripts/stubgen-django.py --django_version 3.1
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also pass an optional commit hash as a second kwarg to checkout a specific commit, e.g.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python ./scripts/stubgen-django.py --django_version 3.1 --commit_sha <commit_sha>
|
||||||
|
```
|
||||||
|
|
||||||
|
The output for this is a gitignored folder called "stubgen" in the repo's root.
|
||||||
|
|
||||||
|
## Submission Guidelines
|
||||||
|
|
||||||
|
The workflow for contributions is fairly simple:
|
||||||
|
|
||||||
|
1. fork and setup the repository as in the previous step.
|
||||||
|
2. create a local branch.
|
||||||
|
3. make whatever changes you want to contribute.
|
||||||
|
4. ensure your contribution does not introduce linting issues or breaks the tests by linting and testing the code.
|
||||||
|
5. make a pull request with an adequate description.
|
||||||
|
|
||||||
|
## A Note About Generics
|
||||||
|
|
||||||
|
As Django uses a lot of the more dynamic features of Python (i.e. metaobjects), statically typing it requires heavy use of generics. Unfortunately, the syntax for generics is also valid python syntax. For instance, the statement `class SomeClass(SuperType[int])` implicitly translates to `class SomeClass(SuperType.__class_getitem__(int))`. If `SuperType` doesn't define the `__class_getitem__` method, this causes a runtime error, even if the code typechecks.
|
||||||
|
|
||||||
|
When adding a new generic class, or changing an existing class to use generics, run a quick test to see if it causes a runtime error. If it does, please add the new generic class to the `_need_generic` list in the [django_stubs_ext monkeypatch function](https://github.com/typeddjango/django-stubs/tree/master/django_stubs_ext/django_stubs_ext/monkeypatch.py)
|
||||||
191
README.md
191
README.md
@@ -1,14 +1,13 @@
|
|||||||
<img src="http://mypy-lang.org/static/mypy_light.svg" alt="mypy logo" width="300px"/>
|
<img src="http://mypy-lang.org/static/mypy_light.svg" alt="mypy logo" width="300px"/>
|
||||||
|
|
||||||
# pep484 stubs for Django framework
|
# pep484 stubs for Django
|
||||||
|
|
||||||
[](https://travis-ci.com/typeddjango/django-stubs)
|
[](https://github.com/typeddjango/django-stubs/actions?query=workflow%3Atest)
|
||||||
[](http://mypy-lang.org/)
|
[](http://mypy-lang.org/)
|
||||||
[](https://gitter.im/mypy-django/Lobby)
|
[](https://gitter.im/mypy-django/Lobby)
|
||||||
|
|
||||||
This package contains type stubs and mypy plugin to provide more precise static types and type inference for Django framework. Django uses some Python "magic" that makes having precise types for some code patterns problematic. This is why we need to accompany the stubs with mypy plugins. The final goal is to be able to get precise types for most common patterns.
|
|
||||||
|
|
||||||
Could be run on earlier versions of Django, but expect some missing imports warnings.
|
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.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -17,69 +16,175 @@ Could be run on earlier versions of Django, but expect some missing imports warn
|
|||||||
pip install django-stubs
|
pip install django-stubs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Mypy compatibility
|
|
||||||
|
|
||||||
| 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
|
|
||||||
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
To make mypy aware of the plugin, you need to add
|
To make mypy aware of the plugin, you need to add
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[mypy]
|
[mypy]
|
||||||
plugins =
|
plugins =
|
||||||
mypy_django_plugin.main
|
mypy_django_plugin.main
|
||||||
|
|
||||||
|
[mypy.plugins.django-stubs]
|
||||||
|
django_settings_module = "myproject.settings"
|
||||||
```
|
```
|
||||||
|
|
||||||
in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
|
in your `mypy.ini` or `setup.cfg` [file](https://mypy.readthedocs.io/en/latest/config_file.html).
|
||||||
|
|
||||||
Plugin also requires Django settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified.
|
Two things happeining here:
|
||||||
|
|
||||||
```ini
|
1. We need to explicitly list our plugin to be loaded by `mypy`
|
||||||
[mypy]
|
2. Our plugin also requires `django` settings module (what you put into `DJANGO_SETTINGS_MODULE` variable) to be specified
|
||||||
strict_optional = True
|
|
||||||
|
|
||||||
# This one is new:
|
|
||||||
[mypy.plugins.django-stubs]
|
|
||||||
django_settings_module = mysettings
|
|
||||||
```
|
|
||||||
|
|
||||||
Where `mysettings` is a value of `DJANGO_SETTINGS_MODULE` (with or without quotes)
|
|
||||||
|
|
||||||
Current implementation uses Django runtime to extract models information, so it will crash, if your installed apps `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`.
|
|
||||||
|
|
||||||
In other words, if your `manage.py runserver` crashes, mypy will crash too.
|
|
||||||
|
|
||||||
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
|
This fully working [typed boilerplate](https://github.com/wemake-services/wemake-django-template) can serve you as an example.
|
||||||
|
|
||||||
|
## Version compatibility
|
||||||
|
|
||||||
## Notes
|
We rely on different `django` and `mypy` versions:
|
||||||
|
|
||||||
Type implementation monkey-patches Django to add `__class_getitem__` to the `Manager` class.
|
| django-stubs | mypy version | django version | python version
|
||||||
If you would use Python3.7 and do that too in your code, you can make things like
|
| ------------ | ---- | ---- | ---- |
|
||||||
|
| 1.7.0 | 0.790 | 2.2.x \|\| 3.x | ^3.6
|
||||||
|
| 1.6.0 | 0.780 | 2.2.x \|\| 3.x | ^3.6
|
||||||
|
| 1.5.0 | 0.770 | 2.2.x \|\| 3.x | ^3.6
|
||||||
|
| 1.4.0 | 0.760 | 2.2.x \|\| 3.x | ^3.6
|
||||||
|
| 1.3.0 | 0.750 | 2.2.x \|\| 3.x | ^3.6
|
||||||
|
| 1.2.0 | 0.730 | 2.2.x | ^3.6
|
||||||
|
| 1.1.0 | 0.720 | 2.2.x | ^3.6
|
||||||
|
| 0.12.x | old semantic analyzer (<0.711), dmypy support | 2.1.x | ^3.6
|
||||||
|
|
||||||
```python
|
|
||||||
class MyUserManager(models.Manager['MyUser']):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class MyUser(models.Model):
|
## FAQ
|
||||||
objects = MyUserManager()
|
|
||||||
|
### Is this an official Django project?
|
||||||
|
|
||||||
|
No, it is not. We are independent 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 can show your support by liking 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]`, `Manager[MyModel]` or some other Django-based Generic types.
|
||||||
|
|
||||||
|
This happens because these Django classes do not support [`__class_getitem__`](https://www.python.org/dev/peps/pep-0560/#class-getitem) magic method in runtime.
|
||||||
|
|
||||||
|
1. You can go with our [`django_stubs_ext`](https://github.com/typeddjango/django-stubs/tree/master/django_stubs_ext) helper, that patches all the types we use as Generic in django.
|
||||||
|
|
||||||
|
Install it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install django-stubs-ext # as a production dependency
|
||||||
```
|
```
|
||||||
|
|
||||||
work, which should make a error messages a bit better.
|
And then place in your top-level settings:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import django_stubs_ext
|
||||||
|
|
||||||
|
django_stubs_ext.monkeypatch()
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 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.
|
||||||
|
|
||||||
|
### How can I create a HttpRequest that's guaranteed to have an authenticated user?
|
||||||
|
|
||||||
|
Django's built in `HttpRequest` has the attribute `user` that resolves to the type
|
||||||
|
```python
|
||||||
|
Union[User, AnonymousUser]
|
||||||
|
```
|
||||||
|
where `User` is the user model specified by the `AUTH_USER_MODEL` setting.
|
||||||
|
|
||||||
|
If you want a `HttpRequest` that you can type-annotate with where you know that the user is authenticated you can subclass the normal `HttpRequest` class like so:
|
||||||
|
```python
|
||||||
|
from django.http import HttpRequest
|
||||||
|
from my_user_app.models import MyUser
|
||||||
|
|
||||||
|
class AuthenticatedHttpRequest(HttpRequest):
|
||||||
|
user: MyUser
|
||||||
|
```
|
||||||
|
|
||||||
|
And then use `AuthenticatedHttpRequest` instead of the standard `HttpRequest` for when you know that the user is authenticated. For example in views using the `@login_required` decorator.
|
||||||
|
|
||||||
|
|
||||||
|
### My QuerySet methods are returning Any rather than my Model
|
||||||
|
|
||||||
|
`QuerySet.as_manager()` is not currently supported.
|
||||||
|
|
||||||
|
If you are using `MyQuerySet.as_manager()`, then your `Manager`/`QuerySet` methods will all not be linked to your model.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
class MyModelQuerySet(models.QuerySet):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class MyModel(models.Model):
|
||||||
|
bar = models.IntegerField()
|
||||||
|
objects = MyModelQuerySet.as_manager()
|
||||||
|
|
||||||
|
def use_my_model():
|
||||||
|
foo = MyModel.objects.get(id=1) # This is `Any` but it should be `MyModel`
|
||||||
|
return foo.xyz # No error, but there should be
|
||||||
|
```
|
||||||
|
|
||||||
|
There is a workaround: use `Manager.from_queryset` instead.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
class MyModelQuerySet(models.QuerySet):
|
||||||
|
pass
|
||||||
|
|
||||||
|
MyModelManager = models.Manager.from_queryset(MyModelQuerySet)
|
||||||
|
|
||||||
|
class MyModel(models.Model):
|
||||||
|
bar = models.IntegerField()
|
||||||
|
objects = MyModelManager()
|
||||||
|
|
||||||
|
def use_my_model():
|
||||||
|
foo = MyModel.objects.get(id=1)
|
||||||
|
return foo.xyz # Gives an error
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
Otherwise, custom type will be created in mypy, named `MyUser__MyUserManager`, which will rewrite base manager as `models.Manager[User]` to make methods like `get_queryset()` and others return properly typed `QuerySet`.
|
|
||||||
|
|
||||||
|
|
||||||
## To get help
|
## 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.
|
## Contributing
|
||||||
|
|
||||||
|
This project is open source and community driven. As such we encourage contributions big and small. You can contribute by doing any of the following:
|
||||||
|
|
||||||
|
1. Contribute code (e.g. improve stubs, add plugin capabilities, write tests etc) - to do so please follow the [contribution guide](./CONTRIBUTING.md).
|
||||||
|
2. Assist in code reviews and discussions in issues.
|
||||||
|
3. Identify bugs and issues and report these
|
||||||
|
|
||||||
|
You can always also reach out in gitter to discuss your contributions!
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
black
|
wheel
|
||||||
pytest-mypy-plugins==1.2.0
|
mypy==0.790
|
||||||
psycopg2
|
requests==2.24.0
|
||||||
flake8==3.7.9
|
coreapi==2.3.3
|
||||||
flake8-pyi==19.3.0
|
typing-extensions==3.7.4.3
|
||||||
isort==4.3.21
|
gitpython==3.1.9
|
||||||
gitpython==3.0.5
|
pre-commit==2.7.1
|
||||||
|
pytest==6.1.1
|
||||||
|
pytest-mypy-plugins==1.6.1
|
||||||
|
psycopg2-binary
|
||||||
|
-e ./django_stubs_ext
|
||||||
-e .
|
-e .
|
||||||
|
|||||||
1
django-sources
Submodule
1
django-sources
Submodule
Submodule django-sources added at aa28213eb5
@@ -1,17 +1,17 @@
|
|||||||
from typing import Any, List, Union, Iterable, Optional
|
from typing import Any, List, Union, Optional, Sequence
|
||||||
|
|
||||||
from django.contrib.admin.options import BaseModelAdmin
|
from django.contrib.admin.options import BaseModelAdmin
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import CheckMessage, Error
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
_CheckError = Union[str, Error]
|
_CheckError = Union[str, Error]
|
||||||
|
|
||||||
def check_admin_app(app_configs: Optional[Iterable[AppConfig]], **kwargs: Any) -> List[_CheckError]: ...
|
def check_admin_app(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[_CheckError]: ...
|
||||||
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
|
def check_dependencies(**kwargs: Any) -> List[_CheckError]: ...
|
||||||
|
|
||||||
class BaseModelAdminChecks:
|
class BaseModelAdminChecks:
|
||||||
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[_CheckError]: ...
|
def check(self, admin_obj: BaseModelAdmin, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
|
|
||||||
class ModelAdminChecks(BaseModelAdminChecks): ...
|
class ModelAdminChecks(BaseModelAdminChecks): ...
|
||||||
class InlineModelAdminChecks(BaseModelAdminChecks): ...
|
class InlineModelAdminChecks(BaseModelAdminChecks): ...
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from typing import Any, Callable, Optional, Type
|
from typing import Any, Callable, Optional, Type
|
||||||
|
|
||||||
|
from django.contrib.admin.sites import AdminSite
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
|
||||||
def register(*models: Type[Model], site: Optional[Any] = ...) -> Callable: ...
|
def register(*models: Type[Model], site: Optional[AdminSite] = ...) -> Callable: ...
|
||||||
|
|||||||
4
django-stubs/contrib/admin/exceptions.pyi
Normal file
4
django-stubs/contrib/admin/exceptions.pyi
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from django.core.exceptions import SuspiciousOperation as SuspiciousOperation
|
||||||
|
|
||||||
|
class DisallowedModelAdminLookup(SuspiciousOperation): ...
|
||||||
|
class DisallowedModelAdminToField(SuspiciousOperation): ...
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Iterable
|
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, Iterable
|
||||||
|
|
||||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
|
||||||
from django.forms.boundfield import BoundField
|
from django.forms.boundfield import BoundField
|
||||||
|
from django.forms.forms import BaseForm
|
||||||
from django.forms.utils import ErrorDict
|
from django.forms.utils import ErrorDict
|
||||||
from django.forms.widgets import Media, Widget
|
from django.forms.widgets import Media, Widget
|
||||||
from django.utils.safestring import SafeText
|
from django.utils.safestring import SafeText
|
||||||
@@ -23,7 +23,7 @@ class AdminForm:
|
|||||||
readonly_fields: Any = ...
|
readonly_fields: Any = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
form: AdminPasswordChangeForm,
|
form: BaseForm,
|
||||||
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
|
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
|
||||||
prepopulated_fields: Dict[Any, Any],
|
prepopulated_fields: Dict[Any, Any],
|
||||||
readonly_fields: Optional[Iterable[Any]] = ...,
|
readonly_fields: Optional[Iterable[Any]] = ...,
|
||||||
|
|||||||
0
django-stubs/contrib/admin/migrations/__init__.pyi
Normal file
0
django-stubs/contrib/admin/migrations/__init__.pyi
Normal file
@@ -1,5 +1,24 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Set, Tuple, Type, Union
|
from typing import (
|
||||||
|
Any,
|
||||||
|
Callable,
|
||||||
|
Dict,
|
||||||
|
Generic,
|
||||||
|
Iterator,
|
||||||
|
List,
|
||||||
|
Optional,
|
||||||
|
Sequence,
|
||||||
|
Set,
|
||||||
|
Tuple,
|
||||||
|
Type,
|
||||||
|
Union,
|
||||||
|
Mapping,
|
||||||
|
TypeVar,
|
||||||
|
)
|
||||||
|
|
||||||
|
from django.forms.forms import BaseForm
|
||||||
|
from django.forms.models import BaseInlineFormSet
|
||||||
|
from typing_extensions import Literal, TypedDict
|
||||||
|
|
||||||
from django.contrib.admin.filters import ListFilter
|
from django.contrib.admin.filters import ListFilter
|
||||||
from django.contrib.admin.models import LogEntry
|
from django.contrib.admin.models import LogEntry
|
||||||
@@ -7,7 +26,7 @@ from django.contrib.admin.sites import AdminSite
|
|||||||
from django.contrib.admin.views.main import ChangeList
|
from django.contrib.admin.views.main import ChangeList
|
||||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import CheckMessage
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
|
from django.db.models.fields.related import ForeignKey, ManyToManyField, RelatedField
|
||||||
@@ -26,8 +45,10 @@ from django.db.models.fields import Field
|
|||||||
|
|
||||||
IS_POPUP_VAR: str
|
IS_POPUP_VAR: str
|
||||||
TO_FIELD_VAR: str
|
TO_FIELD_VAR: str
|
||||||
HORIZONTAL: Any
|
HORIZONTAL: Literal[1] = ...
|
||||||
VERTICAL: Any
|
VERTICAL: Literal[2] = ...
|
||||||
|
|
||||||
|
_Direction = Union[Literal[1], Literal[2]]
|
||||||
|
|
||||||
def get_content_type_for_model(obj: Union[Type[Model], Model]) -> ContentType: ...
|
def get_content_type_for_model(obj: Union[Type[Model], Model]) -> ContentType: ...
|
||||||
def get_ul_class(radio_style: int) -> str: ...
|
def get_ul_class(radio_style: int) -> str: ...
|
||||||
@@ -37,25 +58,43 @@ class IncorrectLookupParameters(Exception): ...
|
|||||||
FORMFIELD_FOR_DBFIELD_DEFAULTS: Any
|
FORMFIELD_FOR_DBFIELD_DEFAULTS: Any
|
||||||
csrf_protect_m: Any
|
csrf_protect_m: Any
|
||||||
|
|
||||||
class BaseModelAdmin:
|
class _OptionalFieldOpts(TypedDict, total=False):
|
||||||
autocomplete_fields: Any = ...
|
classes: Sequence[str]
|
||||||
raw_id_fields: Any = ...
|
description: str
|
||||||
fields: Any = ...
|
|
||||||
exclude: Any = ...
|
class _FieldOpts(_OptionalFieldOpts, total=True):
|
||||||
fieldsets: Any = ...
|
fields: Sequence[Union[str, Sequence[str]]]
|
||||||
form: Any = ...
|
|
||||||
filter_vertical: Any = ...
|
# Workaround for mypy issue, a Sequence type should be preferred here.
|
||||||
filter_horizontal: Any = ...
|
# https://github.com/python/mypy/issues/8921
|
||||||
radio_fields: Any = ...
|
# _FieldsetSpec = Sequence[Tuple[Optional[str], _FieldOpts]]
|
||||||
prepopulated_fields: Any = ...
|
_T = TypeVar("_T")
|
||||||
formfield_overrides: Any = ...
|
_ListOrTuple = Union[Tuple[_T, ...], List[_T]]
|
||||||
readonly_fields: Any = ...
|
_FieldsetSpec = _ListOrTuple[Tuple[Optional[str], _FieldOpts]]
|
||||||
ordering: Any = ...
|
|
||||||
sortable_by: Any = ...
|
# Generic type specifically for models, for use in BaseModelAdmin and subclasses
|
||||||
|
# https://github.com/typeddjango/django-stubs/issues/482
|
||||||
|
_ModelT = TypeVar("_ModelT", bound=Model)
|
||||||
|
|
||||||
|
class BaseModelAdmin(Generic[_ModelT]):
|
||||||
|
autocomplete_fields: Sequence[str] = ...
|
||||||
|
raw_id_fields: Sequence[str] = ...
|
||||||
|
fields: Sequence[Union[str, Sequence[str]]] = ...
|
||||||
|
exclude: Sequence[str] = ...
|
||||||
|
fieldsets: _FieldsetSpec = ...
|
||||||
|
form: Type[BaseForm] = ...
|
||||||
|
filter_vertical: Sequence[str] = ...
|
||||||
|
filter_horizontal: Sequence[str] = ...
|
||||||
|
radio_fields: Mapping[str, _Direction] = ...
|
||||||
|
prepopulated_fields: Mapping[str, Sequence[str]] = ...
|
||||||
|
formfield_overrides: Mapping[Type[Field], Mapping[str, Any]] = ...
|
||||||
|
readonly_fields: Sequence[Union[str, Callable[[_ModelT], Any]]] = ...
|
||||||
|
ordering: Sequence[str] = ...
|
||||||
|
sortable_by: Sequence[str] = ...
|
||||||
view_on_site: bool = ...
|
view_on_site: bool = ...
|
||||||
show_full_result_count: bool = ...
|
show_full_result_count: bool = ...
|
||||||
checks_class: Any = ...
|
checks_class: Any = ...
|
||||||
def check(self, **kwargs: Any) -> List[Union[str, Error]]: ...
|
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def formfield_for_dbfield(
|
def formfield_for_dbfield(
|
||||||
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
|
self, db_field: Field, request: Optional[HttpRequest], **kwargs: Any
|
||||||
) -> Optional[Field]: ...
|
) -> Optional[Field]: ...
|
||||||
@@ -72,28 +111,28 @@ class BaseModelAdmin:
|
|||||||
self, db_field: ManyToManyField, request: Optional[HttpRequest], **kwargs: Any
|
self, db_field: ManyToManyField, request: Optional[HttpRequest], **kwargs: Any
|
||||||
) -> ModelMultipleChoiceField: ...
|
) -> ModelMultipleChoiceField: ...
|
||||||
def get_autocomplete_fields(self, request: HttpRequest) -> Tuple: ...
|
def get_autocomplete_fields(self, request: HttpRequest) -> Tuple: ...
|
||||||
def get_view_on_site_url(self, obj: Optional[Model] = ...) -> Optional[str]: ...
|
def get_view_on_site_url(self, obj: Optional[_ModelT] = ...) -> Optional[str]: ...
|
||||||
def get_empty_value_display(self) -> SafeText: ...
|
def get_empty_value_display(self) -> SafeText: ...
|
||||||
def get_exclude(self, request: HttpRequest, obj: Optional[Model] = ...) -> Any: ...
|
def get_exclude(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Any: ...
|
||||||
def get_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Sequence[Union[Callable, str]]: ...
|
def get_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Sequence[Union[Callable, str]]: ...
|
||||||
def get_fieldsets(
|
def get_fieldsets(
|
||||||
self, request: HttpRequest, obj: Optional[Model] = ...
|
self, request: HttpRequest, obj: Optional[_ModelT] = ...
|
||||||
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
|
) -> List[Tuple[Optional[str], Dict[str, Any]]]: ...
|
||||||
def get_ordering(self, request: HttpRequest) -> Union[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_readonly_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Union[List[str], Tuple]: ...
|
||||||
def get_prepopulated_fields(self, request: HttpRequest, obj: Optional[Model] = ...) -> Dict[str, Tuple[str]]: ...
|
def get_prepopulated_fields(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Dict[str, Tuple[str]]: ...
|
||||||
def get_queryset(self, request: HttpRequest) -> QuerySet: ...
|
def get_queryset(self, request: HttpRequest) -> QuerySet: ...
|
||||||
def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ...
|
def get_sortable_by(self, request: HttpRequest) -> Union[List[Callable], List[str], Tuple]: ...
|
||||||
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
|
def lookup_allowed(self, lookup: str, value: str) -> bool: ...
|
||||||
def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ...
|
def to_field_allowed(self, request: HttpRequest, to_field: str) -> bool: ...
|
||||||
def has_add_permission(self, request: HttpRequest) -> bool: ...
|
def has_add_permission(self, request: HttpRequest) -> bool: ...
|
||||||
def has_change_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
|
def has_change_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ...
|
||||||
def has_delete_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
|
def has_delete_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ...
|
||||||
def has_view_permission(self, request: HttpRequest, obj: Optional[Model] = ...) -> bool: ...
|
def has_view_permission(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> bool: ...
|
||||||
def has_module_permission(self, request: HttpRequest) -> bool: ...
|
def has_module_permission(self, request: HttpRequest) -> bool: ...
|
||||||
|
|
||||||
class ModelAdmin(BaseModelAdmin):
|
class ModelAdmin(BaseModelAdmin[_ModelT]):
|
||||||
list_display: Sequence[Union[str, Callable]] = ...
|
list_display: Sequence[Union[str, Callable[[_ModelT], Any]]] = ...
|
||||||
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
|
list_display_links: Optional[Sequence[Union[str, Callable]]] = ...
|
||||||
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
|
list_filter: Sequence[Union[str, Type[ListFilter], Tuple[str, Type[ListFilter]]]] = ...
|
||||||
list_select_related: Union[bool, Sequence[str]] = ...
|
list_select_related: Union[bool, Sequence[str]] = ...
|
||||||
@@ -101,43 +140,44 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
list_max_show_all: int = ...
|
list_max_show_all: int = ...
|
||||||
list_editable: Sequence[str] = ...
|
list_editable: Sequence[str] = ...
|
||||||
search_fields: Sequence[str] = ...
|
search_fields: Sequence[str] = ...
|
||||||
date_hierarchy: Optional[Any] = ...
|
date_hierarchy: Optional[str] = ...
|
||||||
save_as: bool = ...
|
save_as: bool = ...
|
||||||
save_as_continue: bool = ...
|
save_as_continue: bool = ...
|
||||||
save_on_top: bool = ...
|
save_on_top: bool = ...
|
||||||
paginator: Any = ...
|
paginator: Type = ...
|
||||||
preserve_filters: bool = ...
|
preserve_filters: bool = ...
|
||||||
inlines: Sequence[Type[InlineModelAdmin]] = ...
|
inlines: Sequence[Type[InlineModelAdmin]] = ...
|
||||||
add_form_template: Any = ...
|
add_form_template: str = ...
|
||||||
change_form_template: Any = ...
|
change_form_template: str = ...
|
||||||
change_list_template: Any = ...
|
change_list_template: str = ...
|
||||||
delete_confirmation_template: Any = ...
|
delete_confirmation_template: str = ...
|
||||||
delete_selected_confirmation_template: Any = ...
|
delete_selected_confirmation_template: str = ...
|
||||||
object_history_template: Any = ...
|
object_history_template: str = ...
|
||||||
popup_response_template: Any = ...
|
popup_response_template: str = ...
|
||||||
actions: Any = ...
|
actions: Optional[Sequence[Union[Callable[[ModelAdmin, HttpRequest, QuerySet], None], str]]] = ...
|
||||||
action_form: Any = ...
|
action_form: Any = ...
|
||||||
actions_on_top: bool = ...
|
actions_on_top: bool = ...
|
||||||
actions_on_bottom: bool = ...
|
actions_on_bottom: bool = ...
|
||||||
actions_selection_counter: bool = ...
|
actions_selection_counter: bool = ...
|
||||||
model: Type[Model] = ...
|
model: Type[_ModelT] = ...
|
||||||
opts: Options = ...
|
opts: Options = ...
|
||||||
admin_site: AdminSite = ...
|
admin_site: AdminSite = ...
|
||||||
def __init__(self, model: Type[Model], admin_site: Optional[AdminSite]) -> None: ...
|
def __init__(self, model: Type[_ModelT], admin_site: Optional[AdminSite]) -> None: ...
|
||||||
def get_inline_instances(self, request: HttpRequest, obj: Optional[Model] = ...) -> List[InlineModelAdmin]: ...
|
def get_inlines(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> List[Type[InlineModelAdmin]]: ...
|
||||||
|
def get_inline_instances(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> List[InlineModelAdmin]: ...
|
||||||
def get_urls(self) -> List[URLPattern]: ...
|
def get_urls(self) -> List[URLPattern]: ...
|
||||||
@property
|
@property
|
||||||
def urls(self) -> List[URLPattern]: ...
|
def urls(self) -> List[URLPattern]: ...
|
||||||
@property
|
@property
|
||||||
def media(self) -> Media: ...
|
def media(self) -> Media: ...
|
||||||
def get_model_perms(self, request: HttpRequest) -> 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_form(self, request: Any, obj: Optional[_ModelT] = ..., change: bool = ..., **kwargs: Any): ...
|
||||||
def get_changelist(self, request: HttpRequest, **kwargs: Any) -> Type[ChangeList]: ...
|
def get_changelist(self, request: HttpRequest, **kwargs: Any) -> Type[ChangeList]: ...
|
||||||
def get_changelist_instance(self, request: HttpRequest) -> 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_object(self, request: HttpRequest, object_id: str, from_field: None = ...) -> Optional[_ModelT]: ...
|
||||||
def get_changelist_form(self, request: Any, **kwargs: Any): ...
|
def get_changelist_form(self, request: Any, **kwargs: Any): ...
|
||||||
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
|
def get_changelist_formset(self, request: Any, **kwargs: Any): ...
|
||||||
def get_formsets_with_inlines(self, request: HttpRequest, obj: Optional[Model] = ...) -> Iterator[Any]: ...
|
def get_formsets_with_inlines(self, request: HttpRequest, obj: Optional[_ModelT] = ...) -> Iterator[Any]: ...
|
||||||
def get_paginator(
|
def get_paginator(
|
||||||
self,
|
self,
|
||||||
request: HttpRequest,
|
request: HttpRequest,
|
||||||
@@ -146,10 +186,10 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
orphans: int = ...,
|
orphans: int = ...,
|
||||||
allow_empty_first_page: bool = ...,
|
allow_empty_first_page: bool = ...,
|
||||||
) -> Paginator: ...
|
) -> Paginator: ...
|
||||||
def log_addition(self, request: HttpRequest, object: Model, message: Any) -> LogEntry: ...
|
def log_addition(self, request: HttpRequest, object: _ModelT, message: Any) -> LogEntry: ...
|
||||||
def log_change(self, request: HttpRequest, object: Model, message: Any) -> LogEntry: ...
|
def log_change(self, request: HttpRequest, object: _ModelT, message: Any) -> LogEntry: ...
|
||||||
def log_deletion(self, request: HttpRequest, object: Model, object_repr: str) -> LogEntry: ...
|
def log_deletion(self, request: HttpRequest, object: _ModelT, object_repr: str) -> LogEntry: ...
|
||||||
def action_checkbox(self, obj: Model) -> SafeText: ...
|
def action_checkbox(self, obj: _ModelT) -> SafeText: ...
|
||||||
def get_actions(self, request: HttpRequest) -> OrderedDict: ...
|
def get_actions(self, request: HttpRequest) -> OrderedDict: ...
|
||||||
def get_action_choices(
|
def get_action_choices(
|
||||||
self, request: HttpRequest, default_choices: List[Tuple[str, str]] = ...
|
self, request: HttpRequest, default_choices: List[Tuple[str, str]] = ...
|
||||||
@@ -178,8 +218,8 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
fail_silently: bool = ...,
|
fail_silently: bool = ...,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def save_form(self, request: Any, form: Any, change: Any): ...
|
def save_form(self, request: Any, form: Any, change: Any): ...
|
||||||
def save_model(self, request: Any, obj: Any, form: Any, change: Any) -> None: ...
|
def save_model(self, request: Any, obj: _ModelT, form: Any, change: Any) -> None: ...
|
||||||
def delete_model(self, request: HttpRequest, obj: Model) -> None: ...
|
def delete_model(self, request: HttpRequest, obj: _ModelT) -> None: ...
|
||||||
def delete_queryset(self, request: HttpRequest, queryset: QuerySet) -> 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_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 save_related(self, request: Any, form: Any, formsets: Any, change: Any) -> None: ...
|
||||||
@@ -190,19 +230,19 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
add: bool = ...,
|
add: bool = ...,
|
||||||
change: bool = ...,
|
change: bool = ...,
|
||||||
form_url: str = ...,
|
form_url: str = ...,
|
||||||
obj: Optional[Any] = ...,
|
obj: Optional[_ModelT] = ...,
|
||||||
): ...
|
): ...
|
||||||
def response_add(
|
def response_add(
|
||||||
self, request: HttpRequest, obj: Model, post_url_continue: Optional[str] = ...
|
self, request: HttpRequest, obj: _ModelT, post_url_continue: Optional[str] = ...
|
||||||
) -> HttpResponse: ...
|
) -> HttpResponse: ...
|
||||||
def response_change(self, request: HttpRequest, obj: Model) -> HttpResponse: ...
|
def response_change(self, request: HttpRequest, obj: _ModelT) -> HttpResponse: ...
|
||||||
def response_post_save_add(self, request: HttpRequest, obj: Model) -> HttpResponseRedirect: ...
|
def response_post_save_add(self, request: HttpRequest, obj: _ModelT) -> HttpResponseRedirect: ...
|
||||||
def response_post_save_change(self, request: HttpRequest, obj: Model) -> HttpResponseRedirect: ...
|
def response_post_save_change(self, request: HttpRequest, obj: _ModelT) -> HttpResponseRedirect: ...
|
||||||
def response_action(self, request: HttpRequest, queryset: QuerySet) -> Optional[HttpResponseBase]: ...
|
def response_action(self, request: HttpRequest, queryset: QuerySet) -> Optional[HttpResponseBase]: ...
|
||||||
def response_delete(self, request: HttpRequest, obj_display: str, obj_id: int) -> HttpResponse: ...
|
def response_delete(self, request: HttpRequest, obj_display: str, obj_id: int) -> HttpResponse: ...
|
||||||
def render_delete_form(self, request: Any, context: Any): ...
|
def render_delete_form(self, request: Any, context: Any): ...
|
||||||
def get_inline_formsets(
|
def get_inline_formsets(
|
||||||
self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[Model] = ...
|
self, request: HttpRequest, formsets: List[Any], inline_instances: List[Any], obj: Optional[_ModelT] = ...
|
||||||
) -> List[Any]: ...
|
) -> List[Any]: ...
|
||||||
def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, str]: ...
|
def get_changeform_initial_data(self, request: HttpRequest) -> Dict[str, str]: ...
|
||||||
def changeform_view(
|
def changeform_view(
|
||||||
@@ -226,10 +266,10 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
def delete_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> Any: ...
|
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: ...
|
def history_view(self, request: HttpRequest, object_id: str, extra_context: None = ...) -> HttpResponse: ...
|
||||||
|
|
||||||
class InlineModelAdmin(BaseModelAdmin):
|
class InlineModelAdmin(BaseModelAdmin[_ModelT]):
|
||||||
model: Any = ...
|
model: Type[_ModelT] = ...
|
||||||
fk_name: Any = ...
|
fk_name: str = ...
|
||||||
formset: Any = ...
|
formset: Type[BaseInlineFormSet] = ...
|
||||||
extra: int = ...
|
extra: int = ...
|
||||||
min_num: Optional[int] = ...
|
min_num: Optional[int] = ...
|
||||||
max_num: Optional[int] = ...
|
max_num: Optional[int] = ...
|
||||||
@@ -238,18 +278,18 @@ class InlineModelAdmin(BaseModelAdmin):
|
|||||||
verbose_name_plural: Optional[str] = ...
|
verbose_name_plural: Optional[str] = ...
|
||||||
can_delete: bool = ...
|
can_delete: bool = ...
|
||||||
show_change_link: bool = ...
|
show_change_link: bool = ...
|
||||||
classes: Any = ...
|
classes: Optional[Sequence[str]] = ...
|
||||||
admin_site: Any = ...
|
admin_site: AdminSite = ...
|
||||||
parent_model: Any = ...
|
parent_model: Any = ...
|
||||||
opts: Any = ...
|
opts: Any = ...
|
||||||
has_registered_model: Any = ...
|
has_registered_model: Any = ...
|
||||||
def __init__(self, parent_model: Union[Type[Model], Model], admin_site: AdminSite) -> None: ...
|
def __init__(self, parent_model: Union[Type[_ModelT], _ModelT], admin_site: AdminSite) -> None: ...
|
||||||
@property
|
@property
|
||||||
def media(self) -> Media: ...
|
def media(self) -> Media: ...
|
||||||
def get_extra(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> int: ...
|
def get_extra(self, request: HttpRequest, obj: Optional[_ModelT] = ..., **kwargs: Any) -> int: ...
|
||||||
def get_min_num(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
|
def get_min_num(self, request: HttpRequest, obj: Optional[_ModelT] = ..., **kwargs: Any) -> Optional[int]: ...
|
||||||
def get_max_num(self, request: HttpRequest, obj: Optional[Model] = ..., **kwargs: Any) -> Optional[int]: ...
|
def get_max_num(self, request: HttpRequest, obj: Optional[_ModelT] = ..., **kwargs: Any) -> Optional[int]: ...
|
||||||
def get_formset(self, request: Any, obj: Optional[Any] = ..., **kwargs: Any): ...
|
def get_formset(self, request: Any, obj: Optional[_ModelT] = ..., **kwargs: Any): ...
|
||||||
|
|
||||||
class StackedInline(InlineModelAdmin): ...
|
class StackedInline(InlineModelAdmin[_ModelT]): ...
|
||||||
class TabularInline(InlineModelAdmin): ...
|
class TabularInline(InlineModelAdmin[_ModelT]): ...
|
||||||
|
|||||||
@@ -1,36 +1,51 @@
|
|||||||
|
import sys
|
||||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
|
from django.apps.config import AppConfig
|
||||||
from django.contrib.admin.options import ModelAdmin
|
from django.contrib.admin.options import ModelAdmin
|
||||||
|
from django.contrib.auth.forms import AuthenticationForm
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
from django.db.models.query import QuerySet
|
||||||
from django.http.response import HttpResponse
|
from django.http.response import HttpResponse
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.urls.resolvers import URLResolver
|
from django.urls.resolvers import URLResolver
|
||||||
from django.utils.functional import LazyObject
|
from django.utils.functional import LazyObject
|
||||||
|
from django.core.checks import CheckMessage
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
if sys.version_info >= (3, 9):
|
||||||
|
from weakref import WeakSet
|
||||||
|
|
||||||
all_sites: Any
|
all_sites: WeakSet[AdminSite]
|
||||||
|
else:
|
||||||
|
from typing import MutableSet
|
||||||
|
|
||||||
|
all_sites: MutableSet[AdminSite]
|
||||||
|
|
||||||
|
_ActionCallback = Callable[[ModelAdmin, WSGIRequest, QuerySet], Optional[TemplateResponse]]
|
||||||
|
|
||||||
class AlreadyRegistered(Exception): ...
|
class AlreadyRegistered(Exception): ...
|
||||||
class NotRegistered(Exception): ...
|
class NotRegistered(Exception): ...
|
||||||
|
|
||||||
class AdminSite:
|
class AdminSite:
|
||||||
site_title: Any = ...
|
site_title: str = ...
|
||||||
site_header: Any = ...
|
site_header: str = ...
|
||||||
index_title: Any = ...
|
index_title: str = ...
|
||||||
site_url: str = ...
|
site_url: str = ...
|
||||||
login_form: Any = ...
|
login_form: Optional[AuthenticationForm] = ...
|
||||||
index_template: Any = ...
|
index_template: Optional[str] = ...
|
||||||
app_index_template: Any = ...
|
app_index_template: Optional[str] = ...
|
||||||
login_template: Any = ...
|
login_template: Optional[str] = ...
|
||||||
logout_template: Any = ...
|
logout_template: Optional[str] = ...
|
||||||
password_change_template: Any = ...
|
password_change_template: Optional[str] = ...
|
||||||
password_change_done_template: Any = ...
|
password_change_done_template: Optional[str] = ...
|
||||||
name: str = ...
|
name: str = ...
|
||||||
|
_empty_value_display: str = ...
|
||||||
_registry: Dict[Type[Model], ModelAdmin]
|
_registry: Dict[Type[Model], ModelAdmin]
|
||||||
|
_global_actions: Dict[str, _ActionCallback]
|
||||||
|
_actions: Dict[str, _ActionCallback]
|
||||||
def __init__(self, name: str = ...) -> None: ...
|
def __init__(self, name: str = ...) -> None: ...
|
||||||
def check(self, app_configs: Optional[Iterable[AppConfig]]) -> List[Any]: ...
|
def check(self, app_configs: Optional[Iterable[AppConfig]]) -> List[CheckMessage]: ...
|
||||||
def register(
|
def register(
|
||||||
self,
|
self,
|
||||||
model_or_iterable: Union[Type[Model], Iterable[Type[Model]]],
|
model_or_iterable: Union[Type[Model], Iterable[Type[Model]]],
|
||||||
@@ -39,30 +54,31 @@ class AdminSite:
|
|||||||
) -> None: ...
|
) -> None: ...
|
||||||
def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ...
|
def unregister(self, model_or_iterable: Union[Type[Model], Iterable[Type[Model]]]) -> None: ...
|
||||||
def is_registered(self, model: Type[Model]) -> bool: ...
|
def is_registered(self, model: Type[Model]) -> bool: ...
|
||||||
def add_action(self, action: Callable, name: Optional[str] = ...) -> None: ...
|
def add_action(self, action: _ActionCallback, name: Optional[str] = ...) -> None: ...
|
||||||
def disable_action(self, name: str) -> None: ...
|
def disable_action(self, name: str) -> None: ...
|
||||||
def get_action(self, name: str) -> Callable: ...
|
def get_action(self, name: str) -> Callable: ...
|
||||||
@property
|
@property
|
||||||
def actions(self): ...
|
def actions(self) -> Iterable[Tuple[str, _ActionCallback]]: ...
|
||||||
@property
|
@property
|
||||||
def empty_value_display(self): ...
|
def empty_value_display(self) -> str: ...
|
||||||
@empty_value_display.setter
|
@empty_value_display.setter
|
||||||
def empty_value_display(self, empty_value_display: Any) -> None: ...
|
def empty_value_display(self, empty_value_display: str) -> None: ...
|
||||||
def has_permission(self, request: WSGIRequest) -> bool: ...
|
def has_permission(self, request: WSGIRequest) -> bool: ...
|
||||||
def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ...
|
def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ...
|
||||||
def get_urls(self) -> List[URLResolver]: ...
|
def get_urls(self) -> List[URLResolver]: ...
|
||||||
@property
|
@property
|
||||||
def urls(self) -> Tuple[List[URLResolver], str, str]: ...
|
def urls(self) -> Tuple[List[URLResolver], str, str]: ...
|
||||||
def each_context(self, request: Any): ...
|
def each_context(self, request: WSGIRequest) -> Dict[str, Any]: ...
|
||||||
def password_change(
|
def password_change(
|
||||||
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
||||||
) -> TemplateResponse: ...
|
) -> TemplateResponse: ...
|
||||||
def password_change_done(
|
def password_change_done(
|
||||||
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...
|
||||||
) -> TemplateResponse: ...
|
) -> TemplateResponse: ...
|
||||||
def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[Any, Any]] = ...) -> HttpResponse: ...
|
def i18n_javascript(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
|
||||||
def logout(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
|
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 login(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> HttpResponse: ...
|
||||||
|
def _build_app_dict(self, request: WSGIRequest, label: Optional[str] = ...) -> Dict[str, Any]: ...
|
||||||
def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
|
def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
|
||||||
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
|
def index(self, request: WSGIRequest, extra_context: Optional[Dict[str, Any]] = ...) -> TemplateResponse: ...
|
||||||
def app_index(
|
def app_index(
|
||||||
@@ -71,4 +87,4 @@ class AdminSite:
|
|||||||
|
|
||||||
class DefaultAdminSite(LazyObject): ...
|
class DefaultAdminSite(LazyObject): ...
|
||||||
|
|
||||||
site: Any
|
site: AdminSite
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
from typing import Callable, TypeVar, overload
|
from typing import Callable, Optional, TypeVar, overload
|
||||||
|
|
||||||
_C = TypeVar("_C", bound=Callable)
|
_C = TypeVar("_C", bound=Callable)
|
||||||
@overload
|
@overload
|
||||||
def staff_member_required(view_func: _C = ..., redirect_field_name: str = ..., login_url: str = ...) -> _C: ...
|
def staff_member_required(
|
||||||
|
view_func: _C = ..., redirect_field_name: Optional[str] = ..., login_url: str = ...
|
||||||
|
) -> _C: ...
|
||||||
@overload
|
@overload
|
||||||
def staff_member_required(view_func: None = ..., redirect_field_name: str = ..., login_url: str = ...) -> Callable: ...
|
def staff_member_required(
|
||||||
|
view_func: None = ..., redirect_field_name: Optional[str] = ..., login_url: str = ...
|
||||||
|
) -> Callable: ...
|
||||||
|
|||||||
6
django-stubs/contrib/admindocs/apps.pyi
Normal file
6
django-stubs/contrib/admindocs/apps.pyi
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig as AppConfig
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class AdminDocsConfig(AppConfig):
|
||||||
|
name: str = ...
|
||||||
|
verbose_name: Any = ...
|
||||||
@@ -2,17 +2,16 @@ from typing import Any, List, Optional, Type, Union
|
|||||||
|
|
||||||
from django.contrib.auth.backends import ModelBackend
|
from django.contrib.auth.backends import ModelBackend
|
||||||
from django.contrib.auth.base_user import AbstractBaseUser
|
from django.contrib.auth.base_user import AbstractBaseUser
|
||||||
from django.contrib.auth.models import AbstractUser, AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.options import Options
|
from django.db.models.options import Options
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
|
from django.test.client import Client
|
||||||
|
|
||||||
from .signals import (
|
from .signals import user_logged_in as user_logged_in
|
||||||
user_logged_in as user_logged_in,
|
from .signals import user_logged_out as user_logged_out
|
||||||
user_logged_out as user_logged_out,
|
from .signals import user_login_failed as user_login_failed
|
||||||
user_login_failed as user_login_failed,
|
|
||||||
)
|
|
||||||
|
|
||||||
SESSION_KEY: str
|
SESSION_KEY: str
|
||||||
BACKEND_SESSION_KEY: str
|
BACKEND_SESSION_KEY: str
|
||||||
@@ -23,12 +22,12 @@ def load_backend(path: str) -> ModelBackend: ...
|
|||||||
def get_backends() -> List[ModelBackend]: ...
|
def get_backends() -> List[ModelBackend]: ...
|
||||||
def authenticate(request: Any = ..., **credentials: Any) -> Optional[AbstractBaseUser]: ...
|
def authenticate(request: Any = ..., **credentials: Any) -> Optional[AbstractBaseUser]: ...
|
||||||
def login(
|
def login(
|
||||||
request: HttpRequest, user: AbstractBaseUser, backend: Optional[Union[Type[ModelBackend], str]] = ...
|
request: HttpRequest, user: Optional[AbstractBaseUser], backend: Optional[Union[Type[ModelBackend], str]] = ...
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
def logout(request: HttpRequest) -> None: ...
|
def logout(request: HttpRequest) -> None: ...
|
||||||
def get_user_model() -> Type[Model]: ...
|
def get_user_model() -> Type[Model]: ...
|
||||||
def get_user(request: HttpRequest) -> Union[AbstractBaseUser, AnonymousUser]: ...
|
def get_user(request: Union[HttpRequest, Client]) -> Union[AbstractBaseUser, AnonymousUser]: ...
|
||||||
def get_permission_codename(action: str, opts: Options) -> str: ...
|
def get_permission_codename(action: str, opts: Options) -> str: ...
|
||||||
def update_session_auth_hash(request: WSGIRequest, user: AbstractUser) -> None: ...
|
def update_session_auth_hash(request: HttpRequest, user: AbstractBaseUser) -> None: ...
|
||||||
|
|
||||||
default_app_config: str
|
default_app_config: str
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from django.contrib.auth.base_user import AbstractBaseUser
|
|||||||
from django.contrib.auth.models import AnonymousUser, User, Permission
|
from django.contrib.auth.models import AnonymousUser, User, Permission
|
||||||
|
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
from django.http.request import HttpRequest
|
||||||
|
|
||||||
_AnyUser = Union[Model, AnonymousUser]
|
_AnyUser = Union[Model, AnonymousUser]
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ UserModel: Any
|
|||||||
|
|
||||||
class BaseBackend:
|
class BaseBackend:
|
||||||
def authenticate(
|
def authenticate(
|
||||||
self, request: Any, username: Optional[str] = ..., password: Optional[str] = ..., **kwargs: Any
|
self, request: HttpRequest, username: Optional[str] = ..., password: Optional[str] = ..., **kwargs: Any
|
||||||
) -> Optional[AbstractBaseUser]: ...
|
) -> Optional[AbstractBaseUser]: ...
|
||||||
def get_user(self, user_id: int) -> Optional[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_user_permissions(self, user_obj: _AnyUser, obj: Optional[Model] = ...) -> Set[str]: ...
|
||||||
@@ -35,6 +36,6 @@ class AllowAllUsersModelBackend(ModelBackend): ...
|
|||||||
class RemoteUserBackend(ModelBackend):
|
class RemoteUserBackend(ModelBackend):
|
||||||
create_unknown_user: bool = ...
|
create_unknown_user: bool = ...
|
||||||
def clean_username(self, username: str) -> str: ...
|
def clean_username(self, username: str) -> str: ...
|
||||||
def configure_user(self, user: User) -> User: ...
|
def configure_user(self, request: HttpRequest, user: User) -> User: ...
|
||||||
|
|
||||||
class AllowAllUsersRemoteUserBackend(RemoteUserBackend): ...
|
class AllowAllUsersRemoteUserBackend(RemoteUserBackend): ...
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
from typing import Any, Optional, Tuple, List, overload, TypeVar
|
import sys
|
||||||
|
from typing import Any, Optional, Tuple, List, overload, TypeVar, Union
|
||||||
|
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
|
from django.db.models.expressions import Combinable
|
||||||
|
from django.db.models.fields import BooleanField
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
if sys.version_info < (3, 8):
|
||||||
|
from typing_extensions import Literal
|
||||||
|
else:
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
_T = TypeVar("_T", bound=Model)
|
_T = TypeVar("_T", bound=Model)
|
||||||
|
|
||||||
class BaseUserManager(models.Manager[_T]):
|
class BaseUserManager(models.Manager[_T]):
|
||||||
@@ -17,13 +24,14 @@ class AbstractBaseUser(models.Model):
|
|||||||
|
|
||||||
password = models.CharField(max_length=128)
|
password = models.CharField(max_length=128)
|
||||||
last_login = models.DateTimeField(blank=True, null=True)
|
last_login = models.DateTimeField(blank=True, null=True)
|
||||||
|
is_active: Union[bool, BooleanField[Union[bool, Combinable], bool]] = ...
|
||||||
def get_username(self) -> str: ...
|
def get_username(self) -> str: ...
|
||||||
def natural_key(self) -> Tuple[str]: ...
|
def natural_key(self) -> Tuple[str]: ...
|
||||||
@property
|
@property
|
||||||
def is_anonymous(self) -> bool: ...
|
def is_anonymous(self) -> Literal[False]: ...
|
||||||
@property
|
@property
|
||||||
def is_authenticated(self) -> bool: ...
|
def is_authenticated(self) -> Literal[True]: ...
|
||||||
def set_password(self, raw_password: Optional[str]) -> None: ...
|
def set_password(self, raw_password: str) -> None: ...
|
||||||
def check_password(self, raw_password: str) -> bool: ...
|
def check_password(self, raw_password: str) -> bool: ...
|
||||||
def set_unusable_password(self) -> None: ...
|
def set_unusable_password(self) -> None: ...
|
||||||
def has_usable_password(self) -> bool: ...
|
def has_usable_password(self) -> bool: ...
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
from typing import Any, List, Iterable, Optional
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
from django.core.checks.messages import CheckMessage
|
from django.core.checks.messages import CheckMessage
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
def check_user_model(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
def check_user_model(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def check_models_permissions(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
def check_models_permissions(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
from typing import 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 # noqa: F401
|
from django.contrib.auth import REDIRECT_FIELD_NAME as REDIRECT_FIELD_NAME # noqa: F401
|
||||||
|
from django.http.response import HttpResponseBase
|
||||||
|
|
||||||
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
|
||||||
|
_VIEW = TypeVar("_VIEW", bound=Callable[..., HttpResponseBase])
|
||||||
|
|
||||||
def user_passes_test(
|
def user_passes_test(
|
||||||
test_func: Callable, login_url: Optional[str] = ..., redirect_field_name: str = ...
|
test_func: Callable[[AbstractUser], bool], login_url: Optional[str] = ..., redirect_field_name: str = ...
|
||||||
) -> Callable: ...
|
) -> Callable[[_VIEW], _VIEW]: ...
|
||||||
def login_required(
|
|
||||||
function: Optional[Callable] = ..., redirect_field_name: str = ..., login_url: Optional[str] = ...
|
# There are two ways of calling @login_required: @with(arguments) and @bare
|
||||||
) -> Callable: ...
|
@overload
|
||||||
|
def login_required(redirect_field_name: str = ..., login_url: Optional[str] = ...) -> Callable[[_VIEW], _VIEW]: ...
|
||||||
|
@overload
|
||||||
|
def login_required(function: _VIEW, redirect_field_name: str = ..., login_url: Optional[str] = ...) -> _VIEW: ...
|
||||||
def permission_required(
|
def permission_required(
|
||||||
perm: Union[List[str], Set[str], str], login_url: None = ..., raise_exception: bool = ...
|
perm: Union[List[str], Set[str], str], login_url: None = ..., raise_exception: bool = ...
|
||||||
) -> Callable: ...
|
) -> Callable[[_VIEW], _VIEW]: ...
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from typing import Any, Dict, Iterator, Optional
|
from typing import Any, Dict, Iterator, Optional
|
||||||
|
|
||||||
from django.contrib.auth.base_user import AbstractBaseUser
|
from django.contrib.auth.base_user import AbstractBaseUser
|
||||||
from django.contrib.auth.models import AbstractUser, User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
@@ -86,6 +86,6 @@ class AdminPasswordChangeForm(forms.Form):
|
|||||||
password1: Any = ...
|
password1: Any = ...
|
||||||
password2: Any = ...
|
password2: Any = ...
|
||||||
user: User = ...
|
user: User = ...
|
||||||
def __init__(self, user: AbstractUser, *args: Any, **kwargs: Any) -> None: ...
|
def __init__(self, user: AbstractBaseUser, *args: Any, **kwargs: Any) -> None: ...
|
||||||
def clean_password2(self) -> str: ...
|
def clean_password2(self) -> str: ...
|
||||||
def save(self, commit: bool = ...) -> AbstractUser: ...
|
def save(self, commit: bool = ...) -> AbstractBaseUser: ...
|
||||||
|
|||||||
0
django-stubs/contrib/auth/migrations/__init__.pyi
Normal file
0
django-stubs/contrib/auth/migrations/__init__.pyi
Normal file
@@ -1,3 +1,4 @@
|
|||||||
|
import sys
|
||||||
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar, Union
|
from typing import Any, Collection, Optional, Set, Tuple, Type, TypeVar, Union
|
||||||
|
|
||||||
from django.contrib.auth.backends import ModelBackend
|
from django.contrib.auth.backends import ModelBackend
|
||||||
@@ -9,6 +10,11 @@ from django.db.models.manager import EmptyManager
|
|||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
if sys.version_info < (3, 8):
|
||||||
|
from typing_extensions import Literal
|
||||||
|
else:
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
_AnyUser = Union[Model, "AnonymousUser"]
|
_AnyUser = Union[Model, "AnonymousUser"]
|
||||||
|
|
||||||
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
|
def update_last_login(sender: Type[AbstractBaseUser], user: AbstractBaseUser, **kwargs: Any) -> None: ...
|
||||||
@@ -105,7 +111,7 @@ class AnonymousUser:
|
|||||||
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
|
def has_perms(self, perm_list: Collection[str], obj: Optional[_AnyUser] = ...) -> bool: ...
|
||||||
def has_module_perms(self, module: str) -> bool: ...
|
def has_module_perms(self, module: str) -> bool: ...
|
||||||
@property
|
@property
|
||||||
def is_anonymous(self) -> bool: ...
|
def is_anonymous(self) -> Literal[True]: ...
|
||||||
@property
|
@property
|
||||||
def is_authenticated(self) -> bool: ...
|
def is_authenticated(self) -> Literal[False]: ...
|
||||||
def get_username(self) -> str: ...
|
def get_username(self) -> str: ...
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from datetime import date
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from django.contrib.auth.base_user import AbstractBaseUser
|
from django.contrib.auth.base_user import AbstractBaseUser
|
||||||
@@ -5,7 +6,12 @@ from django.contrib.auth.base_user import AbstractBaseUser
|
|||||||
class PasswordResetTokenGenerator:
|
class PasswordResetTokenGenerator:
|
||||||
key_salt: str = ...
|
key_salt: str = ...
|
||||||
secret: Any = ...
|
secret: Any = ...
|
||||||
|
algorithm: str = ...
|
||||||
def make_token(self, user: AbstractBaseUser) -> str: ...
|
def make_token(self, user: AbstractBaseUser) -> str: ...
|
||||||
def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ...
|
def check_token(self, user: Optional[AbstractBaseUser], token: Optional[str]) -> bool: ...
|
||||||
|
def _make_token_with_timestamp(self, user: AbstractBaseUser, timestamp: int) -> str: ...
|
||||||
|
def _make_hash_value(self, user: AbstractBaseUser, timestamp: int) -> str: ...
|
||||||
|
def _num_days(self, dt: date) -> float: ...
|
||||||
|
def _today(self) -> date: ...
|
||||||
|
|
||||||
default_token_generator: Any
|
default_token_generator: Any
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from typing import Any, Optional, Set
|
from typing import Any, Optional, Set
|
||||||
|
|
||||||
from django.contrib.auth.base_user import AbstractBaseUser
|
from django.contrib.auth.base_user import AbstractBaseUser
|
||||||
|
from django.contrib.auth.forms import AuthenticationForm
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.http.request import HttpRequest
|
from django.http.request import HttpRequest
|
||||||
from django.http.response import HttpResponseRedirect
|
from django.http.response import HttpResponseRedirect
|
||||||
@@ -14,7 +15,7 @@ class SuccessURLAllowedHostsMixin:
|
|||||||
success_url_allowed_hosts: Any = ...
|
success_url_allowed_hosts: Any = ...
|
||||||
def get_success_url_allowed_hosts(self) -> Set[str]: ...
|
def get_success_url_allowed_hosts(self) -> Set[str]: ...
|
||||||
|
|
||||||
class LoginView(SuccessURLAllowedHostsMixin, FormView):
|
class LoginView(SuccessURLAllowedHostsMixin, FormView[AuthenticationForm]):
|
||||||
authentication_form: Any = ...
|
authentication_form: Any = ...
|
||||||
redirect_field_name: Any = ...
|
redirect_field_name: Any = ...
|
||||||
redirect_authenticated_user: bool = ...
|
redirect_authenticated_user: bool = ...
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from typing import Any, List, Iterable, Optional
|
from typing import Any, List, Optional, Sequence
|
||||||
|
|
||||||
from django.apps.config import AppConfig
|
from django.apps.config import AppConfig
|
||||||
|
|
||||||
def check_generic_foreign_keys(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
def check_generic_foreign_keys(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||||
def check_model_name_lengths(app_configs: Optional[Iterable[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
def check_model_name_lengths(app_configs: Optional[Sequence[AppConfig]] = ..., **kwargs: Any) -> List[Any]: ...
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.checks.messages import Error
|
from django.core.checks.messages import CheckMessage
|
||||||
from django.db.models.base import Model
|
from django.db.models.base import Model
|
||||||
from django.db.models.expressions import Combinable
|
from django.db.models.expressions import Combinable
|
||||||
from django.db.models.fields.mixins import FieldCacheMixin
|
from django.db.models.fields.mixins import FieldCacheMixin
|
||||||
@@ -41,7 +41,7 @@ class GenericForeignKey(FieldCacheMixin):
|
|||||||
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
|
def contribute_to_class(self, cls: Type[Model], name: str, **kwargs: Any) -> None: ...
|
||||||
def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, Optional[ContentType]]: ...
|
def get_filter_kwargs_for_object(self, obj: Model) -> Dict[str, Optional[ContentType]]: ...
|
||||||
def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ...
|
def get_forward_related_filter(self, obj: Model) -> Dict[str, int]: ...
|
||||||
def check(self, **kwargs: Any) -> List[Error]: ...
|
def check(self, **kwargs: Any) -> List[CheckMessage]: ...
|
||||||
def get_cache_name(self) -> str: ...
|
def get_cache_name(self) -> str: ...
|
||||||
def get_content_type(
|
def get_content_type(
|
||||||
self, obj: Optional[Model] = ..., id: Optional[int] = ..., using: Optional[str] = ...
|
self, obj: Optional[Model] = ..., id: Optional[int] = ..., using: Optional[str] = ...
|
||||||
@@ -83,7 +83,6 @@ class GenericRelation(ForeignObject):
|
|||||||
def resolve_related_fields(self) -> List[Tuple[PositiveIntegerField, Field]]: ...
|
def resolve_related_fields(self) -> List[Tuple[PositiveIntegerField, Field]]: ...
|
||||||
def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
|
def get_path_info(self, filtered_relation: Optional[FilteredRelation] = ...) -> List[PathInfo]: ...
|
||||||
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
def get_reverse_path_info(self, filtered_relation: None = ...) -> List[PathInfo]: ...
|
||||||
def value_to_string(self, obj: Model) -> str: ...
|
|
||||||
def get_content_type(self) -> ContentType: ...
|
def get_content_type(self) -> ContentType: ...
|
||||||
def get_extra_restriction(
|
def get_extra_restriction(
|
||||||
self, where_class: Type[WhereNode], alias: Optional[str], remote_alias: str
|
self, where_class: Type[WhereNode], alias: Optional[str], remote_alias: str
|
||||||
|
|||||||
9
django-stubs/contrib/flatpages/admin.pyi
Normal file
9
django-stubs/contrib/flatpages/admin.pyi
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from django.contrib import admin as admin
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class FlatPageAdmin(admin.ModelAdmin):
|
||||||
|
form: Any = ...
|
||||||
|
fieldsets: Any = ...
|
||||||
|
list_display: Any = ...
|
||||||
|
list_filter: Any = ...
|
||||||
|
search_fields: Any = ...
|
||||||
6
django-stubs/contrib/flatpages/apps.pyi
Normal file
6
django-stubs/contrib/flatpages/apps.pyi
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig as AppConfig
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class FlatPagesConfig(AppConfig):
|
||||||
|
name: str = ...
|
||||||
|
verbose_name: Any = ...
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
default_app_config: str
|
||||||
|
|||||||
12
django-stubs/contrib/gis/admin/__init__.pyi
Normal file
12
django-stubs/contrib/gis/admin/__init__.pyi
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from django.contrib.admin import (
|
||||||
|
AdminSite as AdminSite,
|
||||||
|
HORIZONTAL as HORIZONTAL,
|
||||||
|
ModelAdmin as ModelAdmin,
|
||||||
|
StackedInline as StackedInline,
|
||||||
|
TabularInline as TabularInline,
|
||||||
|
VERTICAL as VERTICAL,
|
||||||
|
autodiscover as autodiscover,
|
||||||
|
register as register,
|
||||||
|
site as site,
|
||||||
|
)
|
||||||
|
from django.contrib.gis.admin.options import GeoModelAdmin as GeoModelAdmin, OSMGeoAdmin as OSMGeoAdmin
|
||||||
45
django-stubs/contrib/gis/admin/options.pyi
Normal file
45
django-stubs/contrib/gis/admin/options.pyi
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
from django.contrib.admin import ModelAdmin as ModelAdmin
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
spherical_mercator_srid: int
|
||||||
|
|
||||||
|
class GeoModelAdmin(ModelAdmin):
|
||||||
|
default_lon: int = ...
|
||||||
|
default_lat: int = ...
|
||||||
|
default_zoom: int = ...
|
||||||
|
display_wkt: bool = ...
|
||||||
|
display_srid: bool = ...
|
||||||
|
extra_js: Any = ...
|
||||||
|
num_zoom: int = ...
|
||||||
|
max_zoom: bool = ...
|
||||||
|
min_zoom: bool = ...
|
||||||
|
units: bool = ...
|
||||||
|
max_resolution: bool = ...
|
||||||
|
max_extent: bool = ...
|
||||||
|
modifiable: bool = ...
|
||||||
|
mouse_position: bool = ...
|
||||||
|
scale_text: bool = ...
|
||||||
|
layerswitcher: bool = ...
|
||||||
|
scrollable: bool = ...
|
||||||
|
map_width: int = ...
|
||||||
|
map_height: int = ...
|
||||||
|
map_srid: int = ...
|
||||||
|
map_template: str = ...
|
||||||
|
openlayers_url: str = ...
|
||||||
|
point_zoom: Any = ...
|
||||||
|
wms_url: str = ...
|
||||||
|
wms_layer: str = ...
|
||||||
|
wms_name: str = ...
|
||||||
|
wms_options: Any = ...
|
||||||
|
debug: bool = ...
|
||||||
|
widget: Any = ...
|
||||||
|
@property
|
||||||
|
def media(self): ...
|
||||||
|
def formfield_for_dbfield(self, db_field: Any, request: Any, **kwargs: Any): ...
|
||||||
|
def get_map_widget(self, db_field: Any): ...
|
||||||
|
|
||||||
|
class OSMGeoAdmin(GeoModelAdmin):
|
||||||
|
map_template: str = ...
|
||||||
|
num_zoom: int = ...
|
||||||
|
map_srid: Any = ...
|
||||||
|
point_zoom: Any = ...
|
||||||
9
django-stubs/contrib/gis/admin/widgets.pyi
Normal file
9
django-stubs/contrib/gis/admin/widgets.pyi
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from django.forms.widgets import Textarea as Textarea
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
geo_context: Any
|
||||||
|
logger: Any
|
||||||
|
|
||||||
|
class OpenLayersWidget(Textarea):
|
||||||
|
def get_context(self, name: Any, value: Any, attrs: Any): ...
|
||||||
|
def map_options(self): ...
|
||||||
7
django-stubs/contrib/gis/apps.pyi
Normal file
7
django-stubs/contrib/gis/apps.pyi
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from django.apps import AppConfig as AppConfig
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class GISConfig(AppConfig):
|
||||||
|
name: str = ...
|
||||||
|
verbose_name: Any = ...
|
||||||
|
def ready(self) -> None: ...
|
||||||
0
django-stubs/contrib/gis/db/backends/__init__.pyi
Normal file
0
django-stubs/contrib/gis/db/backends/__init__.pyi
Normal file
8
django-stubs/contrib/gis/db/backends/base/adapter.pyi
Normal file
8
django-stubs/contrib/gis/db/backends/base/adapter.pyi
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class WKTAdapter:
|
||||||
|
wkt: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
def __init__(self, geom: Any) -> None: ...
|
||||||
|
def __eq__(self, other: Any) -> Any: ...
|
||||||
|
def __hash__(self) -> Any: ...
|
||||||
44
django-stubs/contrib/gis/db/backends/base/features.pyi
Normal file
44
django-stubs/contrib/gis/db/backends/base/features.pyi
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class BaseSpatialFeatures:
|
||||||
|
gis_enabled: bool = ...
|
||||||
|
has_spatialrefsys_table: bool = ...
|
||||||
|
supports_add_srs_entry: bool = ...
|
||||||
|
supports_geometry_field_introspection: bool = ...
|
||||||
|
supports_3d_storage: bool = ...
|
||||||
|
supports_3d_functions: bool = ...
|
||||||
|
supports_transform: bool = ...
|
||||||
|
supports_null_geometries: bool = ...
|
||||||
|
supports_empty_geometries: bool = ...
|
||||||
|
supports_distance_geodetic: bool = ...
|
||||||
|
supports_length_geodetic: bool = ...
|
||||||
|
supports_perimeter_geodetic: bool = ...
|
||||||
|
supports_area_geodetic: bool = ...
|
||||||
|
supports_num_points_poly: bool = ...
|
||||||
|
supports_left_right_lookups: bool = ...
|
||||||
|
supports_dwithin_distance_expr: bool = ...
|
||||||
|
supports_raster: bool = ...
|
||||||
|
supports_geometry_field_unique_index: bool = ...
|
||||||
|
@property
|
||||||
|
def supports_bbcontains_lookup(self): ...
|
||||||
|
@property
|
||||||
|
def supports_contained_lookup(self): ...
|
||||||
|
@property
|
||||||
|
def supports_crosses_lookup(self): ...
|
||||||
|
@property
|
||||||
|
def supports_distances_lookups(self): ...
|
||||||
|
@property
|
||||||
|
def supports_dwithin_lookup(self): ...
|
||||||
|
@property
|
||||||
|
def supports_relate_lookup(self): ...
|
||||||
|
@property
|
||||||
|
def supports_isvalid_lookup(self): ...
|
||||||
|
@property
|
||||||
|
def supports_collect_aggr(self): ...
|
||||||
|
@property
|
||||||
|
def supports_extent_aggr(self): ...
|
||||||
|
@property
|
||||||
|
def supports_make_line_aggr(self): ...
|
||||||
|
@property
|
||||||
|
def supports_union_aggr(self): ...
|
||||||
|
def __getattr__(self, name: Any): ...
|
||||||
33
django-stubs/contrib/gis/db/backends/base/models.pyi
Normal file
33
django-stubs/contrib/gis/db/backends/base/models.pyi
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class SpatialRefSysMixin:
|
||||||
|
@property
|
||||||
|
def srs(self): ...
|
||||||
|
@property
|
||||||
|
def ellipsoid(self): ...
|
||||||
|
@property
|
||||||
|
def name(self): ...
|
||||||
|
@property
|
||||||
|
def spheroid(self): ...
|
||||||
|
@property
|
||||||
|
def datum(self): ...
|
||||||
|
@property
|
||||||
|
def projected(self): ...
|
||||||
|
@property
|
||||||
|
def local(self): ...
|
||||||
|
@property
|
||||||
|
def geographic(self): ...
|
||||||
|
@property
|
||||||
|
def linear_name(self): ...
|
||||||
|
@property
|
||||||
|
def linear_units(self): ...
|
||||||
|
@property
|
||||||
|
def angular_name(self): ...
|
||||||
|
@property
|
||||||
|
def angular_units(self): ...
|
||||||
|
@property
|
||||||
|
def units(self): ...
|
||||||
|
@classmethod
|
||||||
|
def get_units(cls, wkt: Any): ...
|
||||||
|
@classmethod
|
||||||
|
def get_spheroid(cls, wkt: Any, string: bool = ...): ...
|
||||||
33
django-stubs/contrib/gis/db/backends/base/operations.pyi
Normal file
33
django-stubs/contrib/gis/db/backends/base/operations.pyi
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class BaseSpatialOperations:
|
||||||
|
postgis: bool = ...
|
||||||
|
spatialite: bool = ...
|
||||||
|
mysql: bool = ...
|
||||||
|
oracle: bool = ...
|
||||||
|
spatial_version: Any = ...
|
||||||
|
select: str = ...
|
||||||
|
def select_extent(self): ...
|
||||||
|
geography: bool = ...
|
||||||
|
geometry: bool = ...
|
||||||
|
disallowed_aggregates: Any = ...
|
||||||
|
geom_func_prefix: str = ...
|
||||||
|
function_names: Any = ...
|
||||||
|
unsupported_functions: Any = ...
|
||||||
|
from_text: bool = ...
|
||||||
|
def convert_extent(self, box: Any, srid: Any) -> None: ...
|
||||||
|
def convert_extent3d(self, box: Any, srid: Any) -> None: ...
|
||||||
|
def geo_quote_name(self, name: Any): ...
|
||||||
|
def geo_db_type(self, f: Any) -> None: ...
|
||||||
|
def get_distance(self, f: Any, value: Any, lookup_type: Any) -> None: ...
|
||||||
|
def get_geom_placeholder(self, f: Any, value: Any, compiler: Any): ...
|
||||||
|
def check_expression_support(self, expression: Any) -> None: ...
|
||||||
|
def spatial_aggregate_name(self, agg_name: Any) -> None: ...
|
||||||
|
def spatial_function_name(self, func_name: Any): ...
|
||||||
|
def geometry_columns(self) -> None: ...
|
||||||
|
def spatial_ref_sys(self) -> None: ...
|
||||||
|
distance_expr_for_lookup: Any = ...
|
||||||
|
def get_db_converters(self, expression: Any): ...
|
||||||
|
def get_geometry_converter(self, expression: Any) -> None: ...
|
||||||
|
def get_area_att_for_field(self, field: Any): ...
|
||||||
|
def get_distance_att_for_field(self, field: Any): ...
|
||||||
8
django-stubs/contrib/gis/db/backends/mysql/base.pyi
Normal file
8
django-stubs/contrib/gis/db/backends/mysql/base.pyi
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class DatabaseWrapper(MySQLDatabaseWrapper):
|
||||||
|
SchemaEditorClass: Any = ...
|
||||||
|
features_class: Any = ...
|
||||||
|
introspection_class: Any = ...
|
||||||
|
ops_class: Any = ...
|
||||||
14
django-stubs/contrib/gis/db/backends/mysql/features.pyi
Normal file
14
django-stubs/contrib/gis/db/backends/mysql/features.pyi
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures
|
||||||
|
from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures
|
||||||
|
|
||||||
|
class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
|
||||||
|
has_spatialrefsys_table: bool = ...
|
||||||
|
supports_add_srs_entry: bool = ...
|
||||||
|
supports_distance_geodetic: bool = ...
|
||||||
|
supports_length_geodetic: bool = ...
|
||||||
|
supports_area_geodetic: bool = ...
|
||||||
|
supports_transform: bool = ...
|
||||||
|
supports_null_geometries: bool = ...
|
||||||
|
supports_num_points_poly: bool = ...
|
||||||
|
def supports_empty_geometry_collection(self): ...
|
||||||
|
def supports_geometry_field_unique_index(self): ...
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
from django.db.backends.mysql.introspection import DatabaseIntrospection as DatabaseIntrospection
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class MySQLIntrospection(DatabaseIntrospection):
|
||||||
|
data_types_reverse: Any = ...
|
||||||
|
def get_geometry_type(self, table_name: Any, description: Any): ...
|
||||||
|
def supports_spatial_index(self, cursor: Any, table_name: Any): ...
|
||||||
17
django-stubs/contrib/gis/db/backends/mysql/operations.pyi
Normal file
17
django-stubs/contrib/gis/db/backends/mysql/operations.pyi
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations as BaseSpatialOperations
|
||||||
|
from django.db.backends.mysql.operations import DatabaseOperations as DatabaseOperations
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
mysql: bool = ...
|
||||||
|
name: str = ...
|
||||||
|
geom_func_prefix: str = ...
|
||||||
|
Adapter: Any = ...
|
||||||
|
def select(self): ...
|
||||||
|
def from_text(self): ...
|
||||||
|
def gis_operators(self): ...
|
||||||
|
disallowed_aggregates: Any = ...
|
||||||
|
def unsupported_functions(self): ...
|
||||||
|
def geo_db_type(self, f: Any): ...
|
||||||
|
def get_distance(self, f: Any, value: Any, lookup_type: Any): ...
|
||||||
|
def get_geometry_converter(self, expression: Any): ...
|
||||||
16
django-stubs/contrib/gis/db/backends/mysql/schema.pyi
Normal file
16
django-stubs/contrib/gis/db/backends/mysql/schema.pyi
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from django.db.backends.mysql.schema import DatabaseSchemaEditor as DatabaseSchemaEditor
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
logger: Any
|
||||||
|
|
||||||
|
class MySQLGISSchemaEditor(DatabaseSchemaEditor):
|
||||||
|
sql_add_spatial_index: str = ...
|
||||||
|
sql_drop_spatial_index: str = ...
|
||||||
|
geometry_sql: Any = ...
|
||||||
|
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
def skip_default(self, field: Any): ...
|
||||||
|
def column_sql(self, model: Any, field: Any, include_default: bool = ...): ...
|
||||||
|
def create_model(self, model: Any) -> None: ...
|
||||||
|
def add_field(self, model: Any, field: Any) -> None: ...
|
||||||
|
def remove_field(self, model: Any, field: Any) -> None: ...
|
||||||
|
def create_spatial_indexes(self) -> None: ...
|
||||||
8
django-stubs/contrib/gis/db/backends/oracle/adapter.pyi
Normal file
8
django-stubs/contrib/gis/db/backends/oracle/adapter.pyi
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class OracleSpatialAdapter(WKTAdapter):
|
||||||
|
input_size: Any = ...
|
||||||
|
wkt: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
def __init__(self, geom: Any) -> None: ...
|
||||||
8
django-stubs/contrib/gis/db/backends/oracle/base.pyi
Normal file
8
django-stubs/contrib/gis/db/backends/oracle/base.pyi
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from django.db.backends.oracle.base import DatabaseWrapper as OracleDatabaseWrapper
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class DatabaseWrapper(OracleDatabaseWrapper):
|
||||||
|
SchemaEditorClass: Any = ...
|
||||||
|
features_class: Any = ...
|
||||||
|
introspection_class: Any = ...
|
||||||
|
ops_class: Any = ...
|
||||||
9
django-stubs/contrib/gis/db/backends/oracle/features.pyi
Normal file
9
django-stubs/contrib/gis/db/backends/oracle/features.pyi
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures
|
||||||
|
from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures
|
||||||
|
|
||||||
|
class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
|
||||||
|
supports_add_srs_entry: bool = ...
|
||||||
|
supports_geometry_field_introspection: bool = ...
|
||||||
|
supports_geometry_field_unique_index: bool = ...
|
||||||
|
supports_perimeter_geodetic: bool = ...
|
||||||
|
supports_dwithin_distance_expr: bool = ...
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from django.db.backends.oracle.introspection import DatabaseIntrospection as DatabaseIntrospection
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class OracleIntrospection(DatabaseIntrospection):
|
||||||
|
def data_types_reverse(self): ...
|
||||||
|
def get_geometry_type(self, table_name: Any, description: Any): ...
|
||||||
30
django-stubs/contrib/gis/db/backends/oracle/models.pyi
Normal file
30
django-stubs/contrib/gis/db/backends/oracle/models.pyi
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
from django.contrib.gis.db import models as models
|
||||||
|
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin as SpatialRefSysMixin
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class OracleGeometryColumns(models.Model):
|
||||||
|
table_name: Any = ...
|
||||||
|
column_name: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
class Meta:
|
||||||
|
app_label: str = ...
|
||||||
|
db_table: str = ...
|
||||||
|
managed: bool = ...
|
||||||
|
@classmethod
|
||||||
|
def table_name_col(cls): ...
|
||||||
|
@classmethod
|
||||||
|
def geom_col_name(cls): ...
|
||||||
|
|
||||||
|
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
|
cs_name: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
auth_srid: Any = ...
|
||||||
|
auth_name: Any = ...
|
||||||
|
wktext: Any = ...
|
||||||
|
cs_bounds: Any = ...
|
||||||
|
class Meta:
|
||||||
|
app_label: str = ...
|
||||||
|
db_table: str = ...
|
||||||
|
managed: bool = ...
|
||||||
|
@property
|
||||||
|
def wkt(self): ...
|
||||||
42
django-stubs/contrib/gis/db/backends/oracle/operations.pyi
Normal file
42
django-stubs/contrib/gis/db/backends/oracle/operations.pyi
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations as BaseSpatialOperations
|
||||||
|
from django.contrib.gis.db.backends.utils import SpatialOperator as SpatialOperator
|
||||||
|
from django.db.backends.oracle.operations import DatabaseOperations as DatabaseOperations
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
DEFAULT_TOLERANCE: str
|
||||||
|
|
||||||
|
class SDOOperator(SpatialOperator):
|
||||||
|
sql_template: str = ...
|
||||||
|
|
||||||
|
class SDODWithin(SpatialOperator):
|
||||||
|
sql_template: str = ...
|
||||||
|
|
||||||
|
class SDODisjoint(SpatialOperator):
|
||||||
|
sql_template: Any = ...
|
||||||
|
|
||||||
|
class SDORelate(SpatialOperator):
|
||||||
|
sql_template: str = ...
|
||||||
|
def check_relate_argument(self, arg: Any) -> None: ...
|
||||||
|
def as_sql(self, connection: Any, lookup: Any, template_params: Any, sql_params: Any): ...
|
||||||
|
|
||||||
|
class OracleOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
name: str = ...
|
||||||
|
oracle: bool = ...
|
||||||
|
disallowed_aggregates: Any = ...
|
||||||
|
Adapter: Any = ...
|
||||||
|
extent: str = ...
|
||||||
|
unionagg: str = ...
|
||||||
|
function_names: Any = ...
|
||||||
|
select: str = ...
|
||||||
|
gis_operators: Any = ...
|
||||||
|
unsupported_functions: Any = ...
|
||||||
|
def geo_quote_name(self, name: Any): ...
|
||||||
|
def geo_db_type(self, f: Any): ...
|
||||||
|
def get_distance(self, f: Any, value: Any, lookup_type: Any): ...
|
||||||
|
def get_geom_placeholder(self, f: Any, value: Any, compiler: Any): ...
|
||||||
|
def spatial_aggregate_name(self, agg_name: Any): ...
|
||||||
|
def geometry_columns(self): ...
|
||||||
|
def spatial_ref_sys(self): ...
|
||||||
|
def modify_insert_params(self, placeholder: Any, params: Any): ...
|
||||||
|
def get_geometry_converter(self, expression: Any): ...
|
||||||
|
def get_area_att_for_field(self, field: Any): ...
|
||||||
18
django-stubs/contrib/gis/db/backends/oracle/schema.pyi
Normal file
18
django-stubs/contrib/gis/db/backends/oracle/schema.pyi
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from django.db.backends.oracle.schema import DatabaseSchemaEditor
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class OracleGISSchemaEditor(DatabaseSchemaEditor):
|
||||||
|
sql_add_geometry_metadata: str = ...
|
||||||
|
sql_add_spatial_index: str = ...
|
||||||
|
sql_drop_spatial_index: str = ...
|
||||||
|
sql_clear_geometry_table_metadata: str = ...
|
||||||
|
sql_clear_geometry_field_metadata: str = ...
|
||||||
|
geometry_sql: Any = ...
|
||||||
|
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
def geo_quote_name(self, name: Any): ...
|
||||||
|
def column_sql(self, model: Any, field: Any, include_default: bool = ...): ...
|
||||||
|
def create_model(self, model: Any) -> None: ...
|
||||||
|
def delete_model(self, model: Any) -> None: ...
|
||||||
|
def add_field(self, model: Any, field: Any) -> None: ...
|
||||||
|
def remove_field(self, model: Any, field: Any) -> None: ...
|
||||||
|
def run_geometry_sql(self) -> None: ...
|
||||||
13
django-stubs/contrib/gis/db/backends/postgis/adapter.pyi
Normal file
13
django-stubs/contrib/gis/db/backends/postgis/adapter.pyi
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class PostGISAdapter:
|
||||||
|
is_geometry: Any = ...
|
||||||
|
ewkb: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
geography: Any = ...
|
||||||
|
def __init__(self, obj: Any, geography: bool = ...) -> None: ...
|
||||||
|
def __conform__(self, proto: Any): ...
|
||||||
|
def __eq__(self, other: Any) -> Any: ...
|
||||||
|
def __hash__(self) -> Any: ...
|
||||||
|
def prepare(self, conn: Any) -> None: ...
|
||||||
|
def getquoted(self): ...
|
||||||
10
django-stubs/contrib/gis/db/backends/postgis/base.pyi
Normal file
10
django-stubs/contrib/gis/db/backends/postgis/base.pyi
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django.db.backends.postgresql.base import DatabaseWrapper as Psycopg2DatabaseWrapper
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class DatabaseWrapper(Psycopg2DatabaseWrapper):
|
||||||
|
SchemaEditorClass: Any = ...
|
||||||
|
features: Any = ...
|
||||||
|
ops: Any = ...
|
||||||
|
introspection: Any = ...
|
||||||
|
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
def prepare_database(self) -> None: ...
|
||||||
9
django-stubs/contrib/gis/db/backends/postgis/const.pyi
Normal file
9
django-stubs/contrib/gis/db/backends/postgis/const.pyi
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
GDAL_TO_POSTGIS: Any
|
||||||
|
POSTGIS_TO_GDAL: Any
|
||||||
|
POSTGIS_HEADER_STRUCTURE: str
|
||||||
|
GDAL_TO_STRUCT: Any
|
||||||
|
STRUCT_SIZE: Any
|
||||||
|
BANDTYPE_PIXTYPE_MASK: int
|
||||||
|
BANDTYPE_FLAG_HASNODATA: Any
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures
|
||||||
|
from django.db.backends.postgresql.features import DatabaseFeatures as Psycopg2DatabaseFeatures
|
||||||
|
|
||||||
|
class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures):
|
||||||
|
supports_3d_storage: bool = ...
|
||||||
|
supports_3d_functions: bool = ...
|
||||||
|
supports_left_right_lookups: bool = ...
|
||||||
|
supports_raster: bool = ...
|
||||||
|
supports_empty_geometries: bool = ...
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from django.db.backends.postgresql.introspection import DatabaseIntrospection as DatabaseIntrospection
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class PostGISIntrospection(DatabaseIntrospection):
|
||||||
|
postgis_oid_lookup: Any = ...
|
||||||
|
ignored_tables: Any = ...
|
||||||
|
def get_field_type(self, data_type: Any, description: Any): ...
|
||||||
|
def get_geometry_type(self, table_name: Any, description: Any): ...
|
||||||
33
django-stubs/contrib/gis/db/backends/postgis/models.pyi
Normal file
33
django-stubs/contrib/gis/db/backends/postgis/models.pyi
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin as SpatialRefSysMixin
|
||||||
|
from django.db import models as models
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class PostGISGeometryColumns(models.Model):
|
||||||
|
f_table_catalog: Any = ...
|
||||||
|
f_table_schema: Any = ...
|
||||||
|
f_table_name: Any = ...
|
||||||
|
f_geometry_column: Any = ...
|
||||||
|
coord_dimension: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
type: Any = ...
|
||||||
|
class Meta:
|
||||||
|
app_label: str = ...
|
||||||
|
db_table: str = ...
|
||||||
|
managed: bool = ...
|
||||||
|
@classmethod
|
||||||
|
def table_name_col(cls): ...
|
||||||
|
@classmethod
|
||||||
|
def geom_col_name(cls): ...
|
||||||
|
|
||||||
|
class PostGISSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
|
srid: Any = ...
|
||||||
|
auth_name: Any = ...
|
||||||
|
auth_srid: Any = ...
|
||||||
|
srtext: Any = ...
|
||||||
|
proj4text: Any = ...
|
||||||
|
class Meta:
|
||||||
|
app_label: str = ...
|
||||||
|
db_table: str = ...
|
||||||
|
managed: bool = ...
|
||||||
|
@property
|
||||||
|
def wkt(self): ...
|
||||||
56
django-stubs/contrib/gis/db/backends/postgis/operations.pyi
Normal file
56
django-stubs/contrib/gis/db/backends/postgis/operations.pyi
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
|
||||||
|
from django.contrib.gis.db.backends.utils import SpatialOperator
|
||||||
|
from django.db.backends.postgresql.operations import DatabaseOperations
|
||||||
|
from django.db.models import Func
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
BILATERAL: str
|
||||||
|
|
||||||
|
class PostGISOperator(SpatialOperator):
|
||||||
|
geography: Any = ...
|
||||||
|
raster: Any = ...
|
||||||
|
def __init__(self, geography: bool = ..., raster: bool = ..., **kwargs: Any) -> None: ...
|
||||||
|
def as_sql(self, connection: Any, lookup: Any, template_params: Any, *args: Any): ...
|
||||||
|
def check_raster(self, lookup: Any, template_params: Any): ...
|
||||||
|
|
||||||
|
class ST_Polygon(Func):
|
||||||
|
function: str = ...
|
||||||
|
def __init__(self, expr: Any) -> None: ...
|
||||||
|
def output_field(self): ...
|
||||||
|
|
||||||
|
class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
name: str = ...
|
||||||
|
postgis: bool = ...
|
||||||
|
geography: bool = ...
|
||||||
|
geom_func_prefix: str = ...
|
||||||
|
Adapter: Any = ...
|
||||||
|
collect: Any = ...
|
||||||
|
extent: Any = ...
|
||||||
|
extent3d: Any = ...
|
||||||
|
length3d: Any = ...
|
||||||
|
makeline: Any = ...
|
||||||
|
perimeter3d: Any = ...
|
||||||
|
unionagg: Any = ...
|
||||||
|
gis_operators: Any = ...
|
||||||
|
unsupported_functions: Any = ...
|
||||||
|
select: str = ...
|
||||||
|
select_extent: Any = ...
|
||||||
|
def function_names(self): ...
|
||||||
|
def spatial_version(self): ...
|
||||||
|
def geo_db_type(self, f: Any): ...
|
||||||
|
def get_distance(self, f: Any, dist_val: Any, lookup_type: Any): ...
|
||||||
|
def get_geom_placeholder(self, f: Any, value: Any, compiler: Any): ...
|
||||||
|
def postgis_geos_version(self): ...
|
||||||
|
def postgis_lib_version(self): ...
|
||||||
|
def postgis_proj_version(self): ...
|
||||||
|
def postgis_version(self): ...
|
||||||
|
def postgis_full_version(self): ...
|
||||||
|
def postgis_version_tuple(self): ...
|
||||||
|
def proj_version_tuple(self): ...
|
||||||
|
def spatial_aggregate_name(self, agg_name: Any): ...
|
||||||
|
def geometry_columns(self): ...
|
||||||
|
def spatial_ref_sys(self): ...
|
||||||
|
def parse_raster(self, value: Any): ...
|
||||||
|
def distance_expr_for_lookup(self, lhs: Any, rhs: Any, **kwargs: Any): ...
|
||||||
|
def get_geometry_converter(self, expression: Any): ...
|
||||||
|
def get_area_att_for_field(self, field: Any): ...
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
def pack(structure: Any, data: Any): ...
|
||||||
|
def unpack(structure: Any, data: Any): ...
|
||||||
|
def chunk(data: Any, index: Any): ...
|
||||||
|
def from_pgraster(data: Any): ...
|
||||||
|
def to_pgraster(rast: Any): ...
|
||||||
10
django-stubs/contrib/gis/db/backends/postgis/schema.pyi
Normal file
10
django-stubs/contrib/gis/db/backends/postgis/schema.pyi
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class PostGISSchemaEditor(DatabaseSchemaEditor):
|
||||||
|
geom_index_type: str = ...
|
||||||
|
geom_index_ops_nd: str = ...
|
||||||
|
rast_index_wrapper: str = ...
|
||||||
|
sql_alter_column_to_3d: str = ...
|
||||||
|
sql_alter_column_to_2d: str = ...
|
||||||
|
def geo_quote_name(self, name: Any): ...
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.adapter import WKTAdapter as WKTAdapter
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class SpatiaLiteAdapter(WKTAdapter):
|
||||||
|
def __conform__(self, protocol: Any): ...
|
||||||
13
django-stubs/contrib/gis/db/backends/spatialite/base.pyi
Normal file
13
django-stubs/contrib/gis/db/backends/spatialite/base.pyi
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from django.db.backends.sqlite3.base import DatabaseWrapper as SQLiteDatabaseWrapper
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class DatabaseWrapper(SQLiteDatabaseWrapper):
|
||||||
|
SchemaEditorClass: Any = ...
|
||||||
|
client_class: Any = ...
|
||||||
|
features_class: Any = ...
|
||||||
|
introspection_class: Any = ...
|
||||||
|
ops_class: Any = ...
|
||||||
|
lib_spatialite_paths: Any = ...
|
||||||
|
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
def get_new_connection(self, conn_params: Any): ...
|
||||||
|
def prepare_database(self) -> None: ...
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from django.db.backends.sqlite3.client import DatabaseClient as DatabaseClient
|
||||||
|
|
||||||
|
class SpatiaLiteClient(DatabaseClient):
|
||||||
|
executable_name: str = ...
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures as BaseSpatialFeatures
|
||||||
|
from django.db.backends.sqlite3.features import DatabaseFeatures as SQLiteDatabaseFeatures
|
||||||
|
|
||||||
|
class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures):
|
||||||
|
supports_3d_storage: bool = ...
|
||||||
|
def supports_area_geodetic(self): ...
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
from django.db.backends.sqlite3.introspection import (
|
||||||
|
DatabaseIntrospection as DatabaseIntrospection,
|
||||||
|
FlexibleFieldLookupDict as FlexibleFieldLookupDict,
|
||||||
|
)
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class GeoFlexibleFieldLookupDict(FlexibleFieldLookupDict):
|
||||||
|
base_data_types_reverse: Any = ...
|
||||||
|
|
||||||
|
class SpatiaLiteIntrospection(DatabaseIntrospection):
|
||||||
|
data_types_reverse: Any = ...
|
||||||
|
def get_geometry_type(self, table_name: Any, description: Any): ...
|
||||||
|
def get_constraints(self, cursor: Any, table_name: Any): ...
|
||||||
33
django-stubs/contrib/gis/db/backends/spatialite/models.pyi
Normal file
33
django-stubs/contrib/gis/db/backends/spatialite/models.pyi
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin as SpatialRefSysMixin
|
||||||
|
from django.db import models as models
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class SpatialiteGeometryColumns(models.Model):
|
||||||
|
f_table_name: Any = ...
|
||||||
|
f_geometry_column: Any = ...
|
||||||
|
coord_dimension: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
spatial_index_enabled: Any = ...
|
||||||
|
type: Any = ...
|
||||||
|
class Meta:
|
||||||
|
app_label: str = ...
|
||||||
|
db_table: str = ...
|
||||||
|
managed: bool = ...
|
||||||
|
@classmethod
|
||||||
|
def table_name_col(cls): ...
|
||||||
|
@classmethod
|
||||||
|
def geom_col_name(cls): ...
|
||||||
|
|
||||||
|
class SpatialiteSpatialRefSys(models.Model, SpatialRefSysMixin):
|
||||||
|
srid: Any = ...
|
||||||
|
auth_name: Any = ...
|
||||||
|
auth_srid: Any = ...
|
||||||
|
ref_sys_name: Any = ...
|
||||||
|
proj4text: Any = ...
|
||||||
|
srtext: Any = ...
|
||||||
|
class Meta:
|
||||||
|
app_label: str = ...
|
||||||
|
db_table: str = ...
|
||||||
|
managed: bool = ...
|
||||||
|
@property
|
||||||
|
def wkt(self): ...
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
|
||||||
|
from django.contrib.gis.db.backends.utils import SpatialOperator as SpatialOperator
|
||||||
|
from django.db.backends.sqlite3.operations import DatabaseOperations
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class SpatialiteNullCheckOperator(SpatialOperator):
|
||||||
|
def as_sql(self, connection: Any, lookup: Any, template_params: Any, sql_params: Any): ...
|
||||||
|
|
||||||
|
class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations):
|
||||||
|
name: str = ...
|
||||||
|
spatialite: bool = ...
|
||||||
|
Adapter: Any = ...
|
||||||
|
collect: str = ...
|
||||||
|
extent: str = ...
|
||||||
|
makeline: str = ...
|
||||||
|
unionagg: str = ...
|
||||||
|
gis_operators: Any = ...
|
||||||
|
disallowed_aggregates: Any = ...
|
||||||
|
select: str = ...
|
||||||
|
function_names: Any = ...
|
||||||
|
def unsupported_functions(self): ...
|
||||||
|
def spatial_version(self): ...
|
||||||
|
def geo_db_type(self, f: Any) -> None: ...
|
||||||
|
def get_distance(self, f: Any, value: Any, lookup_type: Any): ...
|
||||||
|
def geos_version(self): ...
|
||||||
|
def proj4_version(self): ...
|
||||||
|
def lwgeom_version(self): ...
|
||||||
|
def spatialite_version(self): ...
|
||||||
|
def spatialite_version_tuple(self): ...
|
||||||
|
def spatial_aggregate_name(self, agg_name: Any): ...
|
||||||
|
def geometry_columns(self): ...
|
||||||
|
def spatial_ref_sys(self): ...
|
||||||
|
def get_geometry_converter(self, expression: Any): ...
|
||||||
24
django-stubs/contrib/gis/db/backends/spatialite/schema.pyi
Normal file
24
django-stubs/contrib/gis/db/backends/spatialite/schema.pyi
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor as DatabaseSchemaEditor
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class SpatialiteSchemaEditor(DatabaseSchemaEditor):
|
||||||
|
sql_add_geometry_column: str = ...
|
||||||
|
sql_add_spatial_index: str = ...
|
||||||
|
sql_drop_spatial_index: str = ...
|
||||||
|
sql_recover_geometry_metadata: str = ...
|
||||||
|
sql_remove_geometry_metadata: str = ...
|
||||||
|
sql_discard_geometry_columns: str = ...
|
||||||
|
sql_update_geometry_columns: str = ...
|
||||||
|
geometry_tables: Any = ...
|
||||||
|
geometry_sql: Any = ...
|
||||||
|
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
||||||
|
def geo_quote_name(self, name: Any): ...
|
||||||
|
def column_sql(self, model: Any, field: Any, include_default: bool = ...): ...
|
||||||
|
def remove_geometry_metadata(self, model: Any, field: Any) -> None: ...
|
||||||
|
def create_model(self, model: Any) -> None: ...
|
||||||
|
def delete_model(self, model: Any, **kwargs: Any) -> None: ...
|
||||||
|
def add_field(self, model: Any, field: Any) -> None: ...
|
||||||
|
def remove_field(self, model: Any, field: Any) -> None: ...
|
||||||
|
def alter_db_table(
|
||||||
|
self, model: Any, old_db_table: Any, new_db_table: Any, disable_constraints: bool = ...
|
||||||
|
) -> None: ...
|
||||||
10
django-stubs/contrib/gis/db/backends/utils.pyi
Normal file
10
django-stubs/contrib/gis/db/backends/utils.pyi
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
class SpatialOperator:
|
||||||
|
sql_template: Any = ...
|
||||||
|
op: Any = ...
|
||||||
|
func: Any = ...
|
||||||
|
def __init__(self, op: Optional[Any] = ..., func: Optional[Any] = ...) -> None: ...
|
||||||
|
@property
|
||||||
|
def default_template(self): ...
|
||||||
|
def as_sql(self, connection: Any, lookup: Any, template_params: Any, sql_params: Any): ...
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
# noqa: F401
|
||||||
from django.db.models import *
|
from django.db.models import *
|
||||||
|
from django.contrib.gis.db.models.aggregates import *
|
||||||
from .fields import (
|
from django.contrib.gis.db.models.fields import (
|
||||||
|
GeometryCollectionField as GeometryCollectionField,
|
||||||
GeometryField as GeometryField,
|
GeometryField as GeometryField,
|
||||||
LineStringField as LineStringField,
|
LineStringField as LineStringField,
|
||||||
MultiLineStringField as MultiLineStringField,
|
MultiLineStringField as MultiLineStringField,
|
||||||
@@ -8,6 +10,5 @@ from .fields import (
|
|||||||
MultiPolygonField as MultiPolygonField,
|
MultiPolygonField as MultiPolygonField,
|
||||||
PointField as PointField,
|
PointField as PointField,
|
||||||
PolygonField as PolygonField,
|
PolygonField as PolygonField,
|
||||||
GeometryCollectionField as GeometryCollectionField,
|
|
||||||
RasterField as RasterField,
|
RasterField as RasterField,
|
||||||
)
|
)
|
||||||
|
|||||||
37
django-stubs/contrib/gis/db/models/aggregates.pyi
Normal file
37
django-stubs/contrib/gis/db/models/aggregates.pyi
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
from django.db.models import Aggregate
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
class GeoAggregate(Aggregate):
|
||||||
|
function: Any = ...
|
||||||
|
is_extent: bool = ...
|
||||||
|
def output_field(self): ...
|
||||||
|
def as_sql(self, compiler: Any, connection: Any, function: Optional[Any] = ..., **extra_context: Any): ...
|
||||||
|
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
def resolve_expression(
|
||||||
|
self,
|
||||||
|
query: Optional[Any] = ...,
|
||||||
|
allow_joins: bool = ...,
|
||||||
|
reuse: Optional[Any] = ...,
|
||||||
|
summarize: bool = ...,
|
||||||
|
for_save: bool = ...,
|
||||||
|
): ...
|
||||||
|
|
||||||
|
class Collect(GeoAggregate):
|
||||||
|
name: str = ...
|
||||||
|
output_field_class: Any = ...
|
||||||
|
|
||||||
|
class Extent(GeoAggregate):
|
||||||
|
name: str = ...
|
||||||
|
def __init__(self, expression: Any, **extra: Any) -> None: ...
|
||||||
|
|
||||||
|
class Extent3D(GeoAggregate):
|
||||||
|
name: str = ...
|
||||||
|
def __init__(self, expression: Any, **extra: Any) -> None: ...
|
||||||
|
|
||||||
|
class MakeLine(GeoAggregate):
|
||||||
|
name: str = ...
|
||||||
|
output_field_class: Any = ...
|
||||||
|
|
||||||
|
class Union(GeoAggregate):
|
||||||
|
name: str = ...
|
||||||
|
output_field_class: Any = ...
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
from typing import Any, Iterable, NamedTuple, Optional, TypeVar, Union, Tuple
|
from typing import Any, Iterable, NamedTuple, Optional, TypeVar, Union, Tuple
|
||||||
|
|
||||||
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
|
from django.db.models.fields import Field, _ErrorMessagesToOverride, _FieldChoices, _ValidatorCallable
|
||||||
|
|
||||||
_Connection = Any
|
|
||||||
|
|
||||||
# __set__ value type
|
# __set__ value type
|
||||||
_ST = TypeVar("_ST")
|
_ST = TypeVar("_ST")
|
||||||
# __get__ return type
|
# __get__ return type
|
||||||
@@ -15,7 +12,7 @@ class SRIDCacheEntry(NamedTuple):
|
|||||||
geodetic: bool
|
geodetic: bool
|
||||||
spheroid: str
|
spheroid: str
|
||||||
|
|
||||||
def get_srid_info(srid: int, connection: _Connection) -> SRIDCacheEntry: ...
|
def get_srid_info(srid: int, connection: Any) -> SRIDCacheEntry: ...
|
||||||
|
|
||||||
class BaseSpatialField(Field[_ST, _GT]):
|
class BaseSpatialField(Field[_ST, _GT]):
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -44,12 +41,25 @@ class BaseSpatialField(Field[_ST, _GT]):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
): ...
|
): ...
|
||||||
def spheroid(self, connection: _Connection) -> str: ...
|
def deconstruct(self): ...
|
||||||
def units(self, connection: _Connection) -> Any: ...
|
def db_type(self, connection: Any): ...
|
||||||
def units_name(self, connection: _Connection) -> str: ...
|
def spheroid(self, connection: Any): ...
|
||||||
def geodetic(self, connection: _Connection) -> bool: ...
|
def units(self, connection: Any): ...
|
||||||
|
def units_name(self, connection: Any): ...
|
||||||
|
def geodetic(self, connection: Any): ...
|
||||||
|
def get_placeholder(self, value: Any, compiler: Any, connection: Any): ...
|
||||||
|
def get_srid(self, obj: Any): ...
|
||||||
|
def get_db_prep_value(self, value: Any, connection: Any, *args: Any, **kwargs: Any): ...
|
||||||
|
def get_raster_prep_value(self, value: Any, is_candidate: Any): ...
|
||||||
|
def get_prep_value(self, value: Any): ...
|
||||||
|
|
||||||
class GeometryField(BaseSpatialField):
|
class GeometryField(BaseSpatialField):
|
||||||
|
description: Any = ...
|
||||||
|
form_class: Any = ...
|
||||||
|
geom_type: str = ...
|
||||||
|
geom_class: Any = ...
|
||||||
|
dim: Any = ...
|
||||||
|
geography: Any = ...
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
verbose_name: Optional[Union[str, bytes]] = ...,
|
verbose_name: Optional[Union[str, bytes]] = ...,
|
||||||
@@ -80,12 +90,61 @@ class GeometryField(BaseSpatialField):
|
|||||||
validators: Iterable[_ValidatorCallable] = ...,
|
validators: Iterable[_ValidatorCallable] = ...,
|
||||||
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
error_messages: Optional[_ErrorMessagesToOverride] = ...,
|
||||||
): ...
|
): ...
|
||||||
|
def deconstruct(self): ...
|
||||||
|
def formfield(self, **kwargs: Any): ...
|
||||||
|
def select_format(self, compiler: Any, sql: Any, params: Any): ...
|
||||||
|
|
||||||
class PointField(GeometryField): ...
|
class PointField(GeometryField):
|
||||||
class LineStringField(GeometryField): ...
|
geom_type: str = ...
|
||||||
class PolygonField(GeometryField): ...
|
geom_class: Any = ...
|
||||||
class MultiPointField(GeometryField): ...
|
form_class: Any = ...
|
||||||
class MultiLineStringField(GeometryField): ...
|
description: Any = ...
|
||||||
class MultiPolygonField(GeometryField): ...
|
|
||||||
class GeometryCollectionField(GeometryField): ...
|
class LineStringField(GeometryField):
|
||||||
class RasterField(BaseSpatialField): ...
|
geom_type: str = ...
|
||||||
|
geom_class: Any = ...
|
||||||
|
form_class: Any = ...
|
||||||
|
description: Any = ...
|
||||||
|
|
||||||
|
class PolygonField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
geom_class: Any = ...
|
||||||
|
form_class: Any = ...
|
||||||
|
description: Any = ...
|
||||||
|
|
||||||
|
class MultiPointField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
geom_class: Any = ...
|
||||||
|
form_class: Any = ...
|
||||||
|
description: Any = ...
|
||||||
|
|
||||||
|
class MultiLineStringField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
geom_class: Any = ...
|
||||||
|
form_class: Any = ...
|
||||||
|
description: Any = ...
|
||||||
|
|
||||||
|
class MultiPolygonField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
geom_class: Any = ...
|
||||||
|
form_class: Any = ...
|
||||||
|
description: Any = ...
|
||||||
|
|
||||||
|
class GeometryCollectionField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
geom_class: Any = ...
|
||||||
|
form_class: Any = ...
|
||||||
|
description: Any = ...
|
||||||
|
|
||||||
|
class ExtentField(Field):
|
||||||
|
description: Any = ...
|
||||||
|
def get_internal_type(self): ...
|
||||||
|
def select_format(self, compiler: Any, sql: Any, params: Any): ...
|
||||||
|
|
||||||
|
class RasterField(BaseSpatialField):
|
||||||
|
description: Any = ...
|
||||||
|
geom_type: str = ...
|
||||||
|
geography: bool = ...
|
||||||
|
def db_type(self, connection: Any): ...
|
||||||
|
def from_db_value(self, value: Any, expression: Any, connection: Any): ...
|
||||||
|
def get_transform(self, name: Any): ...
|
||||||
|
|||||||
168
django-stubs/contrib/gis/db/models/functions.pyi
Normal file
168
django-stubs/contrib/gis/db/models/functions.pyi
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
from django.db.models import Func, Transform as StandardTransform
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
NUMERIC_TYPES: Any
|
||||||
|
|
||||||
|
class GeoFuncMixin:
|
||||||
|
function: Any = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
def __init__(self, *expressions: Any, **extra: Any) -> None: ...
|
||||||
|
def geo_field(self): ...
|
||||||
|
def as_sql(self, compiler: Any, connection: Any, function: Optional[Any] = ..., **extra_context: Any): ...
|
||||||
|
def resolve_expression(self, *args: Any, **kwargs: Any): ...
|
||||||
|
|
||||||
|
class GeoFunc(GeoFuncMixin, Func): ...
|
||||||
|
|
||||||
|
class GeomOutputGeoFunc(GeoFunc):
|
||||||
|
def output_field(self): ...
|
||||||
|
|
||||||
|
class SQLiteDecimalToFloatMixin:
|
||||||
|
def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class OracleToleranceMixin:
|
||||||
|
tolerance: float = ...
|
||||||
|
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class Area(OracleToleranceMixin, GeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
def output_field(self): ...
|
||||||
|
def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class Azimuth(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
|
||||||
|
class AsGeoJSON(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
def __init__(
|
||||||
|
self, expression: Any, bbox: bool = ..., crs: bool = ..., precision: int = ..., **extra: Any
|
||||||
|
) -> None: ...
|
||||||
|
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class AsGML(GeoFunc):
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
output_field: Any = ...
|
||||||
|
def __init__(self, expression: Any, version: int = ..., precision: int = ..., **extra: Any) -> None: ...
|
||||||
|
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class AsKML(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
def __init__(self, expression: Any, precision: int = ..., **extra: Any) -> None: ...
|
||||||
|
|
||||||
|
class AsSVG(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
def __init__(self, expression: Any, relative: bool = ..., precision: int = ..., **extra: Any) -> None: ...
|
||||||
|
|
||||||
|
class AsWKB(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class AsWKT(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class BoundingCircle(OracleToleranceMixin, GeoFunc):
|
||||||
|
def __init__(self, expression: Any, num_seg: int = ..., **extra: Any) -> None: ...
|
||||||
|
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class Centroid(OracleToleranceMixin, GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class Difference(OracleToleranceMixin, GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
|
||||||
|
class DistanceResultMixin:
|
||||||
|
def output_field(self): ...
|
||||||
|
def source_is_geography(self): ...
|
||||||
|
|
||||||
|
class Distance(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
spheroid: Any = ...
|
||||||
|
def __init__(self, expr1: Any, expr2: Any, spheroid: Optional[Any] = ..., **extra: Any) -> None: ...
|
||||||
|
def as_postgresql(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class Envelope(GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class ForcePolygonCW(GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class GeoHash(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
def __init__(self, expression: Any, precision: Optional[Any] = ..., **extra: Any) -> None: ...
|
||||||
|
def as_mysql(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class GeometryDistance(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
function: str = ...
|
||||||
|
arg_joiner: str = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
|
||||||
|
class Intersection(OracleToleranceMixin, GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
|
||||||
|
class IsValid(OracleToleranceMixin, GeoFuncMixin, StandardTransform):
|
||||||
|
lookup_name: str = ...
|
||||||
|
output_field: Any = ...
|
||||||
|
def as_oracle(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class Length(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
|
||||||
|
spheroid: Any = ...
|
||||||
|
def __init__(self, expr1: Any, spheroid: bool = ..., **extra: Any) -> None: ...
|
||||||
|
def as_postgresql(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class LineLocatePoint(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
|
||||||
|
class MakeValid(GeomOutputGeoFunc): ...
|
||||||
|
|
||||||
|
class MemSize(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class NumGeometries(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class NumPoints(GeoFunc):
|
||||||
|
output_field: Any = ...
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class Perimeter(DistanceResultMixin, OracleToleranceMixin, GeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
def as_postgresql(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class PointOnSurface(OracleToleranceMixin, GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class Reverse(GeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
|
||||||
|
class Scale(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc):
|
||||||
|
def __init__(self, expression: Any, x: Any, y: Any, z: float = ..., **extra: Any) -> None: ...
|
||||||
|
|
||||||
|
class SnapToGrid(SQLiteDecimalToFloatMixin, GeomOutputGeoFunc):
|
||||||
|
def __init__(self, expression: Any, *args: Any, **extra: Any) -> None: ...
|
||||||
|
|
||||||
|
class SymDifference(OracleToleranceMixin, GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
|
|
||||||
|
class Transform(GeomOutputGeoFunc):
|
||||||
|
def __init__(self, expression: Any, srid: Any, **extra: Any) -> None: ...
|
||||||
|
|
||||||
|
class Translate(Scale):
|
||||||
|
def as_sqlite(self, compiler: Any, connection: Any, **extra_context: Any): ...
|
||||||
|
|
||||||
|
class Union(OracleToleranceMixin, GeomOutputGeoFunc):
|
||||||
|
arity: int = ...
|
||||||
|
geom_param_pos: Any = ...
|
||||||
126
django-stubs/contrib/gis/db/models/lookups.pyi
Normal file
126
django-stubs/contrib/gis/db/models/lookups.pyi
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
from django.db.models import Lookup, Transform
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class RasterBandTransform(Transform): ...
|
||||||
|
|
||||||
|
class GISLookup(Lookup):
|
||||||
|
sql_template: Any = ...
|
||||||
|
transform_func: Any = ...
|
||||||
|
distance: bool = ...
|
||||||
|
band_rhs: Any = ...
|
||||||
|
band_lhs: Any = ...
|
||||||
|
template_params: Any = ...
|
||||||
|
def __init__(self, lhs: Any, rhs: Any) -> None: ...
|
||||||
|
def process_rhs_params(self) -> None: ...
|
||||||
|
def process_band_indices(self, only_lhs: bool = ...) -> None: ...
|
||||||
|
def get_db_prep_lookup(self, value: Any, connection: Any): ...
|
||||||
|
rhs: Any = ...
|
||||||
|
def process_rhs(self, compiler: Any, connection: Any): ...
|
||||||
|
def get_rhs_op(self, connection: Any, rhs: Any): ...
|
||||||
|
def as_sql(self, compiler: Any, connection: Any): ...
|
||||||
|
|
||||||
|
class OverlapsLeftLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class OverlapsRightLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class OverlapsBelowLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class OverlapsAboveLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class LeftLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class RightLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class StrictlyBelowLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class StrictlyAboveLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class SameAsLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class BBContainsLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class BBOverlapsLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class ContainedLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class ContainsLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class ContainsProperlyLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class CoveredByLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class CoversLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class CrossesLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class DisjointLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class EqualsLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class IntersectsLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class OverlapsLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class RelateLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
sql_template: str = ...
|
||||||
|
pattern_regex: Any = ...
|
||||||
|
def process_rhs(self, compiler: Any, connection: Any): ...
|
||||||
|
|
||||||
|
class TouchesLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class WithinLookup(GISLookup):
|
||||||
|
lookup_name: str = ...
|
||||||
|
|
||||||
|
class DistanceLookupBase(GISLookup):
|
||||||
|
distance: bool = ...
|
||||||
|
sql_template: str = ...
|
||||||
|
def process_rhs_params(self) -> None: ...
|
||||||
|
def process_distance(self, compiler: Any, connection: Any): ...
|
||||||
|
|
||||||
|
class DWithinLookup(DistanceLookupBase):
|
||||||
|
lookup_name: str = ...
|
||||||
|
sql_template: str = ...
|
||||||
|
def process_distance(self, compiler: Any, connection: Any): ...
|
||||||
|
def process_rhs(self, compiler: Any, connection: Any): ...
|
||||||
|
|
||||||
|
class DistanceLookupFromFunction(DistanceLookupBase):
|
||||||
|
def as_sql(self, compiler: Any, connection: Any): ...
|
||||||
|
|
||||||
|
class DistanceGTLookup(DistanceLookupFromFunction):
|
||||||
|
lookup_name: str = ...
|
||||||
|
op: str = ...
|
||||||
|
|
||||||
|
class DistanceGTELookup(DistanceLookupFromFunction):
|
||||||
|
lookup_name: str = ...
|
||||||
|
op: str = ...
|
||||||
|
|
||||||
|
class DistanceLTLookup(DistanceLookupFromFunction):
|
||||||
|
lookup_name: str = ...
|
||||||
|
op: str = ...
|
||||||
|
|
||||||
|
class DistanceLTELookup(DistanceLookupFromFunction):
|
||||||
|
lookup_name: str = ...
|
||||||
|
op: str = ...
|
||||||
7
django-stubs/contrib/gis/db/models/proxy.pyi
Normal file
7
django-stubs/contrib/gis/db/models/proxy.pyi
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from django.db.models.query_utils import DeferredAttribute
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
class SpatialProxy(DeferredAttribute):
|
||||||
|
def __init__(self, klass: Any, field: Any, load_func: Optional[Any] = ...) -> None: ...
|
||||||
|
def __get__(self, instance: Any, cls: Optional[Any] = ...): ...
|
||||||
|
def __set__(self, instance: Any, value: Any): ...
|
||||||
0
django-stubs/contrib/gis/db/models/sql/__init__.pyi
Normal file
0
django-stubs/contrib/gis/db/models/sql/__init__.pyi
Normal file
18
django-stubs/contrib/gis/db/models/sql/conversion.pyi
Normal file
18
django-stubs/contrib/gis/db/models/sql/conversion.pyi
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from django.db import models as models
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class AreaField(models.FloatField):
|
||||||
|
geo_field: Any = ...
|
||||||
|
def __init__(self, geo_field: Any) -> None: ...
|
||||||
|
def get_prep_value(self, value: Any): ...
|
||||||
|
def get_db_prep_value(self, value: Any, connection: Any, prepared: bool = ...): ...
|
||||||
|
def from_db_value(self, value: Any, expression: Any, connection: Any): ...
|
||||||
|
def get_internal_type(self): ...
|
||||||
|
|
||||||
|
class DistanceField(models.FloatField):
|
||||||
|
geo_field: Any = ...
|
||||||
|
def __init__(self, geo_field: Any) -> None: ...
|
||||||
|
def get_prep_value(self, value: Any): ...
|
||||||
|
def get_db_prep_value(self, value: Any, connection: Any, prepared: bool = ...): ...
|
||||||
|
def from_db_value(self, value: Any, expression: Any, connection: Any): ...
|
||||||
|
def get_internal_type(self): ...
|
||||||
28
django-stubs/contrib/gis/feeds.pyi
Normal file
28
django-stubs/contrib/gis/feeds.pyi
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from django.contrib.syndication.views import Feed as BaseFeed
|
||||||
|
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class GeoFeedMixin:
|
||||||
|
def georss_coords(self, coords: Any): ...
|
||||||
|
def add_georss_point(self, handler: Any, coords: Any, w3c_geo: bool = ...) -> None: ...
|
||||||
|
def add_georss_element(self, handler: Any, item: Any, w3c_geo: bool = ...) -> None: ...
|
||||||
|
|
||||||
|
class GeoRSSFeed(Rss201rev2Feed, GeoFeedMixin):
|
||||||
|
def rss_attributes(self): ...
|
||||||
|
def add_item_elements(self, handler: Any, item: Any) -> None: ...
|
||||||
|
def add_root_elements(self, handler: Any) -> None: ...
|
||||||
|
|
||||||
|
class GeoAtom1Feed(Atom1Feed, GeoFeedMixin):
|
||||||
|
def root_attributes(self): ...
|
||||||
|
def add_item_elements(self, handler: Any, item: Any) -> None: ...
|
||||||
|
def add_root_elements(self, handler: Any) -> None: ...
|
||||||
|
|
||||||
|
class W3CGeoFeed(Rss201rev2Feed, GeoFeedMixin):
|
||||||
|
def rss_attributes(self): ...
|
||||||
|
def add_item_elements(self, handler: Any, item: Any) -> None: ...
|
||||||
|
def add_root_elements(self, handler: Any) -> None: ...
|
||||||
|
|
||||||
|
class Feed(BaseFeed):
|
||||||
|
feed_type: Any = ...
|
||||||
|
def feed_extra_kwargs(self, obj: Any): ...
|
||||||
|
def item_extra_kwargs(self, item: Any): ...
|
||||||
0
django-stubs/contrib/gis/forms/__init__.pyi
Normal file
0
django-stubs/contrib/gis/forms/__init__.pyi
Normal file
33
django-stubs/contrib/gis/forms/fields.pyi
Normal file
33
django-stubs/contrib/gis/forms/fields.pyi
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from django import forms as forms
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
class GeometryField(forms.Field):
|
||||||
|
widget: Any = ...
|
||||||
|
geom_type: str = ...
|
||||||
|
default_error_messages: Any = ...
|
||||||
|
srid: Any = ...
|
||||||
|
def __init__(self, *, srid: Optional[Any] = ..., geom_type: Optional[Any] = ..., **kwargs: Any) -> None: ...
|
||||||
|
def to_python(self, value: Any): ...
|
||||||
|
def clean(self, value: Any): ...
|
||||||
|
def has_changed(self, initial: Any, data: Any): ...
|
||||||
|
|
||||||
|
class GeometryCollectionField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
|
||||||
|
class PointField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
|
||||||
|
class MultiPointField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
|
||||||
|
class LineStringField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
|
||||||
|
class MultiLineStringField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
|
||||||
|
class PolygonField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
|
|
||||||
|
class MultiPolygonField(GeometryField):
|
||||||
|
geom_type: str = ...
|
||||||
34
django-stubs/contrib/gis/forms/widgets.pyi
Normal file
34
django-stubs/contrib/gis/forms/widgets.pyi
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
from django.forms.widgets import Widget as Widget
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
logger: Any
|
||||||
|
|
||||||
|
class BaseGeometryWidget(Widget):
|
||||||
|
geom_type: str = ...
|
||||||
|
map_srid: int = ...
|
||||||
|
map_width: int = ...
|
||||||
|
map_height: int = ...
|
||||||
|
display_raw: bool = ...
|
||||||
|
supports_3d: bool = ...
|
||||||
|
template_name: str = ...
|
||||||
|
attrs: Any = ...
|
||||||
|
def __init__(self, attrs: Optional[Any] = ...) -> None: ...
|
||||||
|
def serialize(self, value: Any): ...
|
||||||
|
def deserialize(self, value: Any): ...
|
||||||
|
def get_context(self, name: Any, value: Any, attrs: Any): ...
|
||||||
|
|
||||||
|
class OpenLayersWidget(BaseGeometryWidget):
|
||||||
|
template_name: str = ...
|
||||||
|
map_srid: int = ...
|
||||||
|
class Media:
|
||||||
|
css: Any = ...
|
||||||
|
js: Any = ...
|
||||||
|
def serialize(self, value: Any): ...
|
||||||
|
def deserialize(self, value: Any): ...
|
||||||
|
|
||||||
|
class OSMWidget(OpenLayersWidget):
|
||||||
|
template_name: str = ...
|
||||||
|
default_lon: int = ...
|
||||||
|
default_lat: int = ...
|
||||||
|
default_zoom: int = ...
|
||||||
|
def __init__(self, attrs: Optional[Any] = ...) -> None: ...
|
||||||
15
django-stubs/contrib/gis/gdal/__init__.pyi
Normal file
15
django-stubs/contrib/gis/gdal/__init__.pyi
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from django.contrib.gis.gdal.error import (
|
||||||
|
GDALException as GDALException,
|
||||||
|
SRSException as SRSException,
|
||||||
|
check_err as check_err,
|
||||||
|
)
|
||||||
|
from django.contrib.gis.gdal.libgdal import (
|
||||||
|
GDAL_VERSION as GDAL_VERSION,
|
||||||
|
gdal_full_version as gdal_full_version,
|
||||||
|
gdal_version as gdal_version,
|
||||||
|
)
|
||||||
|
from django.contrib.gis.gdal.srs import (
|
||||||
|
AxisOrder as AxisOrder,
|
||||||
|
CoordTransform as CoordTransform,
|
||||||
|
SpatialReference as SpatialReference,
|
||||||
|
)
|
||||||
5
django-stubs/contrib/gis/gdal/base.pyi
Normal file
5
django-stubs/contrib/gis/gdal/base.pyi
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from django.contrib.gis.ptr import CPointerBase as CPointerBase
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class GDALBase(CPointerBase):
|
||||||
|
null_ptr_exception_class: Any = ...
|
||||||
15
django-stubs/contrib/gis/gdal/datasource.pyi
Normal file
15
django-stubs/contrib/gis/gdal/datasource.pyi
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from django.contrib.gis.gdal.base import GDALBase as GDALBase
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class DataSource(GDALBase):
|
||||||
|
destructor: Any = ...
|
||||||
|
encoding: Any = ...
|
||||||
|
ptr: Any = ...
|
||||||
|
driver: Any = ...
|
||||||
|
def __init__(self, ds_input: Any, ds_driver: bool = ..., write: bool = ..., encoding: str = ...) -> None: ...
|
||||||
|
def __getitem__(self, index: Any): ...
|
||||||
|
def __len__(self): ...
|
||||||
|
@property
|
||||||
|
def layer_count(self): ...
|
||||||
|
@property
|
||||||
|
def name(self): ...
|
||||||
12
django-stubs/contrib/gis/gdal/driver.pyi
Normal file
12
django-stubs/contrib/gis/gdal/driver.pyi
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from django.contrib.gis.gdal.base import GDALBase as GDALBase
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class Driver(GDALBase):
|
||||||
|
ptr: Any = ...
|
||||||
|
def __init__(self, dr_input: Any) -> None: ...
|
||||||
|
@classmethod
|
||||||
|
def ensure_registered(cls) -> None: ...
|
||||||
|
@classmethod
|
||||||
|
def driver_count(cls): ...
|
||||||
|
@property
|
||||||
|
def name(self): ...
|
||||||
25
django-stubs/contrib/gis/gdal/envelope.pyi
Normal file
25
django-stubs/contrib/gis/gdal/envelope.pyi
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
from ctypes import Structure
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class OGREnvelope(Structure): ...
|
||||||
|
|
||||||
|
class Envelope:
|
||||||
|
def __init__(self, *args: Any) -> None: ...
|
||||||
|
def __eq__(self, other: Any) -> Any: ...
|
||||||
|
def expand_to_include(self, *args: Any): ...
|
||||||
|
@property
|
||||||
|
def min_x(self): ...
|
||||||
|
@property
|
||||||
|
def min_y(self): ...
|
||||||
|
@property
|
||||||
|
def max_x(self): ...
|
||||||
|
@property
|
||||||
|
def max_y(self): ...
|
||||||
|
@property
|
||||||
|
def ur(self): ...
|
||||||
|
@property
|
||||||
|
def ll(self): ...
|
||||||
|
@property
|
||||||
|
def tuple(self): ...
|
||||||
|
@property
|
||||||
|
def wkt(self): ...
|
||||||
10
django-stubs/contrib/gis/gdal/error.pyi
Normal file
10
django-stubs/contrib/gis/gdal/error.pyi
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class GDALException(Exception): ...
|
||||||
|
class SRSException(Exception): ...
|
||||||
|
|
||||||
|
OGRERR_DICT: Any
|
||||||
|
CPLERR_DICT: Any
|
||||||
|
ERR_NONE: int
|
||||||
|
|
||||||
|
def check_err(code: Any, cpl: bool = ...) -> None: ...
|
||||||
26
django-stubs/contrib/gis/gdal/feature.pyi
Normal file
26
django-stubs/contrib/gis/gdal/feature.pyi
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from django.contrib.gis.gdal.base import GDALBase as GDALBase
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class Feature(GDALBase):
|
||||||
|
destructor: Any = ...
|
||||||
|
ptr: Any = ...
|
||||||
|
def __init__(self, feat: Any, layer: Any) -> None: ...
|
||||||
|
def __getitem__(self, index: Any): ...
|
||||||
|
def __len__(self): ...
|
||||||
|
def __eq__(self, other: Any) -> Any: ...
|
||||||
|
@property
|
||||||
|
def encoding(self): ...
|
||||||
|
@property
|
||||||
|
def fid(self): ...
|
||||||
|
@property
|
||||||
|
def layer_name(self): ...
|
||||||
|
@property
|
||||||
|
def num_fields(self): ...
|
||||||
|
@property
|
||||||
|
def fields(self): ...
|
||||||
|
@property
|
||||||
|
def geom(self): ...
|
||||||
|
@property
|
||||||
|
def geom_type(self): ...
|
||||||
|
def get(self, field: Any): ...
|
||||||
|
def index(self, field_name: Any): ...
|
||||||
61
django-stubs/contrib/gis/gdal/field.pyi
Normal file
61
django-stubs/contrib/gis/gdal/field.pyi
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
from django.contrib.gis.gdal.base import GDALBase as GDALBase
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
class Field(GDALBase):
|
||||||
|
ptr: Any = ...
|
||||||
|
__class__: Any = ...
|
||||||
|
def __init__(self, feat: Any, index: Any) -> None: ...
|
||||||
|
def as_double(self): ...
|
||||||
|
def as_int(self, is_64: bool = ...): ...
|
||||||
|
def as_string(self): ...
|
||||||
|
def as_datetime(self): ...
|
||||||
|
@property
|
||||||
|
def is_set(self): ...
|
||||||
|
@property
|
||||||
|
def name(self): ...
|
||||||
|
@property
|
||||||
|
def precision(self): ...
|
||||||
|
@property
|
||||||
|
def type(self): ...
|
||||||
|
@property
|
||||||
|
def type_name(self): ...
|
||||||
|
@property
|
||||||
|
def value(self): ...
|
||||||
|
@property
|
||||||
|
def width(self): ...
|
||||||
|
|
||||||
|
class OFTInteger(Field):
|
||||||
|
@property
|
||||||
|
def value(self): ...
|
||||||
|
@property
|
||||||
|
def type(self): ...
|
||||||
|
|
||||||
|
class OFTReal(Field):
|
||||||
|
@property
|
||||||
|
def value(self): ...
|
||||||
|
|
||||||
|
class OFTString(Field): ...
|
||||||
|
class OFTWideString(Field): ...
|
||||||
|
class OFTBinary(Field): ...
|
||||||
|
|
||||||
|
class OFTDate(Field):
|
||||||
|
@property
|
||||||
|
def value(self): ...
|
||||||
|
|
||||||
|
class OFTDateTime(Field):
|
||||||
|
@property
|
||||||
|
def value(self): ...
|
||||||
|
|
||||||
|
class OFTTime(Field):
|
||||||
|
@property
|
||||||
|
def value(self): ...
|
||||||
|
|
||||||
|
class OFTInteger64(OFTInteger): ...
|
||||||
|
class OFTIntegerList(Field): ...
|
||||||
|
class OFTRealList(Field): ...
|
||||||
|
class OFTStringList(Field): ...
|
||||||
|
class OFTWideStringList(Field): ...
|
||||||
|
class OFTInteger64List(Field): ...
|
||||||
|
|
||||||
|
OGRFieldTypes: Any
|
||||||
|
ROGRFieldTypes: Any
|
||||||
138
django-stubs/contrib/gis/gdal/geometries.pyi
Normal file
138
django-stubs/contrib/gis/gdal/geometries.pyi
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
from django.contrib.gis.gdal.base import GDALBase as GDALBase
|
||||||
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
class OGRGeometry(GDALBase):
|
||||||
|
destructor: Any = ...
|
||||||
|
ptr: Any = ...
|
||||||
|
srs: Any = ...
|
||||||
|
__class__: Any = ...
|
||||||
|
def __init__(self, geom_input: Any, srs: Optional[Any] = ...) -> None: ...
|
||||||
|
@classmethod
|
||||||
|
def from_bbox(cls, bbox: Any): ...
|
||||||
|
@staticmethod
|
||||||
|
def from_json(geom_input: Any): ...
|
||||||
|
@classmethod
|
||||||
|
def from_gml(cls, gml_string: Any): ...
|
||||||
|
def __or__(self, other: Any): ...
|
||||||
|
def __and__(self, other: Any): ...
|
||||||
|
def __sub__(self, other: Any): ...
|
||||||
|
def __xor__(self, other: Any): ...
|
||||||
|
def __eq__(self, other: Any) -> Any: ...
|
||||||
|
@property
|
||||||
|
def dimension(self): ...
|
||||||
|
coord_dim: Any = ...
|
||||||
|
@property
|
||||||
|
def geom_count(self): ...
|
||||||
|
@property
|
||||||
|
def point_count(self): ...
|
||||||
|
@property
|
||||||
|
def num_points(self): ...
|
||||||
|
@property
|
||||||
|
def num_coords(self): ...
|
||||||
|
@property
|
||||||
|
def geom_type(self): ...
|
||||||
|
@property
|
||||||
|
def geom_name(self): ...
|
||||||
|
@property
|
||||||
|
def area(self): ...
|
||||||
|
@property
|
||||||
|
def envelope(self): ...
|
||||||
|
@property
|
||||||
|
def empty(self): ...
|
||||||
|
@property
|
||||||
|
def extent(self): ...
|
||||||
|
srid: Any = ...
|
||||||
|
@property
|
||||||
|
def geos(self): ...
|
||||||
|
@property
|
||||||
|
def gml(self): ...
|
||||||
|
@property
|
||||||
|
def hex(self): ...
|
||||||
|
@property
|
||||||
|
def json(self): ...
|
||||||
|
geojson: Any = ...
|
||||||
|
@property
|
||||||
|
def kml(self): ...
|
||||||
|
@property
|
||||||
|
def wkb_size(self): ...
|
||||||
|
@property
|
||||||
|
def wkb(self): ...
|
||||||
|
@property
|
||||||
|
def wkt(self): ...
|
||||||
|
@property
|
||||||
|
def ewkt(self): ...
|
||||||
|
def clone(self): ...
|
||||||
|
def close_rings(self) -> None: ...
|
||||||
|
def transform(self, coord_trans: Any, clone: bool = ...): ...
|
||||||
|
def intersects(self, other: Any): ...
|
||||||
|
def equals(self, other: Any): ...
|
||||||
|
def disjoint(self, other: Any): ...
|
||||||
|
def touches(self, other: Any): ...
|
||||||
|
def crosses(self, other: Any): ...
|
||||||
|
def within(self, other: Any): ...
|
||||||
|
def contains(self, other: Any): ...
|
||||||
|
def overlaps(self, other: Any): ...
|
||||||
|
@property
|
||||||
|
def boundary(self): ...
|
||||||
|
@property
|
||||||
|
def convex_hull(self): ...
|
||||||
|
def difference(self, other: Any): ...
|
||||||
|
def intersection(self, other: Any): ...
|
||||||
|
def sym_difference(self, other: Any): ...
|
||||||
|
def union(self, other: Any): ...
|
||||||
|
|
||||||
|
class Point(OGRGeometry):
|
||||||
|
@property
|
||||||
|
def x(self): ...
|
||||||
|
@property
|
||||||
|
def y(self): ...
|
||||||
|
@property
|
||||||
|
def z(self): ...
|
||||||
|
@property
|
||||||
|
def tuple(self): ...
|
||||||
|
coords: Any = ...
|
||||||
|
|
||||||
|
class LineString(OGRGeometry):
|
||||||
|
def __getitem__(self, index: Any): ...
|
||||||
|
def __len__(self): ...
|
||||||
|
@property
|
||||||
|
def tuple(self): ...
|
||||||
|
coords: Any = ...
|
||||||
|
@property
|
||||||
|
def x(self): ...
|
||||||
|
@property
|
||||||
|
def y(self): ...
|
||||||
|
@property
|
||||||
|
def z(self): ...
|
||||||
|
|
||||||
|
class LinearRing(LineString): ...
|
||||||
|
|
||||||
|
class Polygon(OGRGeometry):
|
||||||
|
def __len__(self): ...
|
||||||
|
def __getitem__(self, index: Any): ...
|
||||||
|
@property
|
||||||
|
def shell(self): ...
|
||||||
|
exterior_ring: Any = ...
|
||||||
|
@property
|
||||||
|
def tuple(self): ...
|
||||||
|
coords: Any = ...
|
||||||
|
@property
|
||||||
|
def point_count(self): ...
|
||||||
|
@property
|
||||||
|
def centroid(self): ...
|
||||||
|
|
||||||
|
class GeometryCollection(OGRGeometry):
|
||||||
|
def __getitem__(self, index: Any): ...
|
||||||
|
def __len__(self): ...
|
||||||
|
def add(self, geom: Any) -> None: ...
|
||||||
|
@property
|
||||||
|
def point_count(self): ...
|
||||||
|
@property
|
||||||
|
def tuple(self): ...
|
||||||
|
coords: Any = ...
|
||||||
|
|
||||||
|
class MultiPoint(GeometryCollection): ...
|
||||||
|
class MultiLineString(GeometryCollection): ...
|
||||||
|
class MultiPolygon(GeometryCollection): ...
|
||||||
|
|
||||||
|
GEO_CLASSES: Any
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user