extended-mypy-django-plugin 0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- extended_mypy_django_plugin-0.5/.github/workflows/ci.yml +41 -0
- extended_mypy_django_plugin-0.5/.github/workflows/ciold.yml +47 -0
- extended_mypy_django_plugin-0.5/.github/workflows/lint.yml +78 -0
- extended_mypy_django_plugin-0.5/.github/workflows/lintold.yml +56 -0
- extended_mypy_django_plugin-0.5/.github/workflows/release.yml +47 -0
- extended_mypy_django_plugin-0.5/.gitignore +8 -0
- extended_mypy_django_plugin-0.5/.readthedocs.yaml +15 -0
- extended_mypy_django_plugin-0.5/DEVELOPMENT.rst +36 -0
- extended_mypy_django_plugin-0.5/LICENSE +22 -0
- extended_mypy_django_plugin-0.5/PKG-INFO +59 -0
- extended_mypy_django_plugin-0.5/README.rst +42 -0
- extended_mypy_django_plugin-0.5/docs/.gitignore +2 -0
- extended_mypy_django_plugin-0.5/docs/README.rst +14 -0
- extended_mypy_django_plugin-0.5/docs/_static/css/extra.css +5 -0
- extended_mypy_django_plugin-0.5/docs/api/changelog.rst +8 -0
- extended_mypy_django_plugin-0.5/docs/api/installation.rst +29 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/actions.rst +43 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/config.rst +4 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/dependencies.rst +4 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/hook.rst +4 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/index.rst +15 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/plugin.rst +4 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/reports.rst +4 -0
- extended_mypy_django_plugin-0.5/docs/api/internals/store.rst +14 -0
- extended_mypy_django_plugin-0.5/docs/api/primer.rst +201 -0
- extended_mypy_django_plugin-0.5/docs/api/tracking-changes.rst +20 -0
- extended_mypy_django_plugin-0.5/docs/api/usage.rst +154 -0
- extended_mypy_django_plugin-0.5/docs/conf.py +29 -0
- extended_mypy_django_plugin-0.5/docs/index.rst +12 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/asgi.py +16 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp/apps.py +6 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp/migrations/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp/models.py +56 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp2/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp2/apps.py +6 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp2/migrations/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/exampleapp2/models.py +11 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/settings.py +123 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/urls.py +23 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/version.py +1 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/views.py +67 -0
- extended_mypy_django_plugin-0.5/example/djangoexample/wsgi.py +16 -0
- extended_mypy_django_plugin-0.5/example/manage.py +23 -0
- extended_mypy_django_plugin-0.5/example/mypy.ini +13 -0
- extended_mypy_django_plugin-0.5/example/pyproject.toml +25 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/__init__.py +3 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/annotations.py +75 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/entry.py +48 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/main.py +4 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/__init__.py +3 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/_config.py +124 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/_debug.py +9 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/_dependencies.py +61 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/_hook.py +169 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/_plugin.py +246 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/_reports.py +411 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/_store.py +251 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/actions/__init__.py +5 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/actions/_sem_analyze.py +88 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/actions/_type_analyze.py +110 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/plugin/actions/_type_checker.py +183 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/py.typed +0 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/scripts/__init__.py +3 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/scripts/find_models.py +30 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/scripts/get_installed_apps.py +53 -0
- extended_mypy_django_plugin-0.5/extended_mypy_django_plugin/version.py +1 -0
- extended_mypy_django_plugin-0.5/find +15 -0
- extended_mypy_django_plugin-0.5/format +7 -0
- extended_mypy_django_plugin-0.5/lint +7 -0
- extended_mypy_django_plugin-0.5/mypy.ini +21 -0
- extended_mypy_django_plugin-0.5/pyproject.toml +63 -0
- extended_mypy_django_plugin-0.5/pytest.ini +8 -0
- extended_mypy_django_plugin-0.5/run.sh +41 -0
- extended_mypy_django_plugin-0.5/scripts/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/scripts/make_old.patch +40 -0
- extended_mypy_django_plugin-0.5/scripts/myapp/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/scripts/myapp/apps.py +6 -0
- extended_mypy_django_plugin-0.5/scripts/myapp/models.py +44 -0
- extended_mypy_django_plugin-0.5/scripts/myapp2/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/scripts/myapp2/apps.py +6 -0
- extended_mypy_django_plugin-0.5/scripts/myapp2/models.py +7 -0
- extended_mypy_django_plugin-0.5/scripts/mypy.ini +9 -0
- extended_mypy_django_plugin-0.5/scripts/py.typed +0 -0
- extended_mypy_django_plugin-0.5/scripts/test_settings.py +10 -0
- extended_mypy_django_plugin-0.5/scripts/tests_extension_hook.py +162 -0
- extended_mypy_django_plugin-0.5/test.sh +10 -0
- extended_mypy_django_plugin-0.5/tests/__init__.py +0 -0
- extended_mypy_django_plugin-0.5/tests/test_concrete_annotation.yml +100 -0
- extended_mypy_django_plugin-0.5/tests/test_works.yml +74 -0
- extended_mypy_django_plugin-0.5/tools/.gitignore +2 -0
- extended_mypy_django_plugin-0.5/tools/bootstrap_venvstarter.py +33 -0
- extended_mypy_django_plugin-0.5/tools/devtools.py +133 -0
- extended_mypy_django_plugin-0.5/tools/requirements.dev.txt +16 -0
- extended_mypy_django_plugin-0.5/tools/requirements.docs.txt +4 -0
- extended_mypy_django_plugin-0.5/tools/venv +42 -0
- extended_mypy_django_plugin-0.5/tox.ini +9 -0
- extended_mypy_django_plugin-0.5/types +12 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
name: CI tasks
|
|
4
|
+
|
|
5
|
+
on: [push, pull_request]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
tests:
|
|
9
|
+
runs-on: ${{ matrix.os }}
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: actions/setup-python@v4
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
|
|
22
|
+
- name: Display Python version
|
|
23
|
+
run: python -c "import sys; print(sys.version)"
|
|
24
|
+
|
|
25
|
+
- name: Install deps
|
|
26
|
+
shell: bash
|
|
27
|
+
env:
|
|
28
|
+
VENVSTARTER_ONLY_MAKE_VENV: "1"
|
|
29
|
+
run: python ./tools/venv
|
|
30
|
+
|
|
31
|
+
- name: Run tests
|
|
32
|
+
shell: bash
|
|
33
|
+
run: ./test.sh -v --mypy-cache-strategy NO_INCREMENTAL
|
|
34
|
+
|
|
35
|
+
- name: Run tests incremental
|
|
36
|
+
shell: bash
|
|
37
|
+
run: ./test.sh -v --mypy-cache-strategy NON_SHARED_INCREMENTAL
|
|
38
|
+
|
|
39
|
+
- name: Run tests daemon
|
|
40
|
+
shell: bash
|
|
41
|
+
run: ./test.sh -v --mypy-cache-strategy DAEMON
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
name: CI tasks for old versions
|
|
4
|
+
|
|
5
|
+
on: [push, pull_request]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
tests:
|
|
9
|
+
runs-on: ${{ matrix.os }}
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
|
14
|
+
python-version: ["3.10"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: actions/setup-python@v4
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
|
|
22
|
+
- name: Display Python version
|
|
23
|
+
run: python -c "import sys; print(sys.version)"
|
|
24
|
+
|
|
25
|
+
- name: Install patch to make this use old versions of things
|
|
26
|
+
run: |
|
|
27
|
+
git config user.name github-actions
|
|
28
|
+
git config user.email github-actions@github.com
|
|
29
|
+
git am ./scripts/make_old.patch
|
|
30
|
+
|
|
31
|
+
- name: Install deps
|
|
32
|
+
shell: bash
|
|
33
|
+
env:
|
|
34
|
+
VENVSTARTER_ONLY_MAKE_VENV: "1"
|
|
35
|
+
run: python ./tools/venv
|
|
36
|
+
|
|
37
|
+
- name: Run tests
|
|
38
|
+
shell: bash
|
|
39
|
+
run: ./test.sh -v --mypy-cache-strategy NO_INCREMENTAL
|
|
40
|
+
|
|
41
|
+
- name: Run tests incremental
|
|
42
|
+
shell: bash
|
|
43
|
+
run: ./test.sh -v --mypy-cache-strategy NON_SHARED_INCREMENTAL
|
|
44
|
+
|
|
45
|
+
- name: Run tests daemon
|
|
46
|
+
shell: bash
|
|
47
|
+
run: ./test.sh -v --mypy-cache-strategy DAEMON
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
name: Lint
|
|
4
|
+
|
|
5
|
+
on: [push, pull_request]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
lint:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v3
|
|
12
|
+
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: actions/setup-python@v4
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.10"
|
|
17
|
+
|
|
18
|
+
- name: Install deps
|
|
19
|
+
shell: bash
|
|
20
|
+
env:
|
|
21
|
+
VENVSTARTER_ONLY_MAKE_VENV: "1"
|
|
22
|
+
run: python ./tools/venv
|
|
23
|
+
|
|
24
|
+
- name: Ensure linter is happy
|
|
25
|
+
run: ./lint
|
|
26
|
+
|
|
27
|
+
types:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
strategy:
|
|
30
|
+
fail-fast: false
|
|
31
|
+
matrix:
|
|
32
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v3
|
|
35
|
+
|
|
36
|
+
- name: Set up Python
|
|
37
|
+
uses: actions/setup-python@v4
|
|
38
|
+
with:
|
|
39
|
+
python-version: ${{ matrix.python-version }}
|
|
40
|
+
|
|
41
|
+
- name: Install deps
|
|
42
|
+
shell: bash
|
|
43
|
+
env:
|
|
44
|
+
VENVSTARTER_ONLY_MAKE_VENV: "1"
|
|
45
|
+
run: python ./tools/venv
|
|
46
|
+
|
|
47
|
+
- name: Ensure mypy is happy
|
|
48
|
+
run: ./types
|
|
49
|
+
|
|
50
|
+
format:
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
steps:
|
|
53
|
+
- uses: actions/checkout@v3
|
|
54
|
+
|
|
55
|
+
- name: Set up Python
|
|
56
|
+
uses: actions/setup-python@v4
|
|
57
|
+
with:
|
|
58
|
+
python-version: "3.10"
|
|
59
|
+
|
|
60
|
+
- name: Install deps
|
|
61
|
+
shell: bash
|
|
62
|
+
env:
|
|
63
|
+
VENVSTARTER_ONLY_MAKE_VENV: "1"
|
|
64
|
+
run: python ./tools/venv
|
|
65
|
+
|
|
66
|
+
- name: Ensure code is formatted
|
|
67
|
+
run: |
|
|
68
|
+
./format
|
|
69
|
+
|
|
70
|
+
# Complain if there were changes
|
|
71
|
+
if [[ ! -z "$(git status --porcelain)" ]]; then
|
|
72
|
+
echo "=========================================="
|
|
73
|
+
echo "Found changes!"
|
|
74
|
+
echo "Please run ./format before committing code"
|
|
75
|
+
echo "=========================================="
|
|
76
|
+
git diff
|
|
77
|
+
exit 1
|
|
78
|
+
fi
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
|
|
3
|
+
name: Lint for old versions
|
|
4
|
+
|
|
5
|
+
on: [push, pull_request]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
lint:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v3
|
|
12
|
+
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: actions/setup-python@v4
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.10"
|
|
17
|
+
|
|
18
|
+
- name: Install patch to make this use old versions of things
|
|
19
|
+
run: |
|
|
20
|
+
git config user.name github-actions
|
|
21
|
+
git config user.email github-actions@github.com
|
|
22
|
+
git am ./scripts/make_old.patch
|
|
23
|
+
|
|
24
|
+
- name: Install deps
|
|
25
|
+
shell: bash
|
|
26
|
+
env:
|
|
27
|
+
VENVSTARTER_ONLY_MAKE_VENV: "1"
|
|
28
|
+
run: python ./tools/venv
|
|
29
|
+
|
|
30
|
+
- name: Ensure linter is happy
|
|
31
|
+
run: ./lint
|
|
32
|
+
|
|
33
|
+
types:
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v3
|
|
37
|
+
|
|
38
|
+
- name: Set up Python
|
|
39
|
+
uses: actions/setup-python@v4
|
|
40
|
+
with:
|
|
41
|
+
python-version: "3.10"
|
|
42
|
+
|
|
43
|
+
- name: Install patch to make this use old versions of things
|
|
44
|
+
run: |
|
|
45
|
+
git config user.name github-actions
|
|
46
|
+
git config user.email github-actions@github.com
|
|
47
|
+
git am ./scripts/make_old.patch
|
|
48
|
+
|
|
49
|
+
- name: Install deps
|
|
50
|
+
shell: bash
|
|
51
|
+
env:
|
|
52
|
+
VENVSTARTER_ONLY_MAKE_VENV: "1"
|
|
53
|
+
run: python ./tools/venv
|
|
54
|
+
|
|
55
|
+
- name: Ensure mypy is happy
|
|
56
|
+
run: ./types
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
on:
|
|
2
|
+
- workflow_dispatch
|
|
3
|
+
|
|
4
|
+
name: Release Packages
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: write
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
name: Create the package
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: github_release
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: actions/setup-python@v4
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.10"
|
|
20
|
+
|
|
21
|
+
- id: build
|
|
22
|
+
run: pip install hatch==1.7.0 && hatch build
|
|
23
|
+
|
|
24
|
+
- id: version
|
|
25
|
+
run: |
|
|
26
|
+
version=$(python -c "import runpy; print(runpy.run_path('extended_mypy_django_plugin/version.py')['VERSION'])")
|
|
27
|
+
versiondash=$(python -c "import runpy; print(runpy.run_path('extended_mypy_django_plugin/version.py')['VERSION'].replace('.', '-'))")
|
|
28
|
+
|
|
29
|
+
echo "version=$version" >> $GITHUB_OUTPUT
|
|
30
|
+
echo "versiondash=$versiondash" >> $GITHUB_OUTPUT
|
|
31
|
+
|
|
32
|
+
- id: create-release
|
|
33
|
+
uses: softprops/action-gh-release@v2
|
|
34
|
+
with:
|
|
35
|
+
name: extended_mypy_django_plugin ${{ steps.version.outputs.version }}
|
|
36
|
+
body: "https://extended-mypy-django-plugin.readthedocs.io/en/latest/api/changelog.html#release-${{ steps.version.outputs.versiondash }}"
|
|
37
|
+
tag_name: "release-${{ steps.version.outputs.version }}"
|
|
38
|
+
fail_on_unmatched_files: true
|
|
39
|
+
draft: false
|
|
40
|
+
prerelease: false
|
|
41
|
+
files: "dist/*"
|
|
42
|
+
|
|
43
|
+
- uses: pypa/gh-action-pypi-publish@v1.4.1
|
|
44
|
+
with:
|
|
45
|
+
user: __token__
|
|
46
|
+
password: ${{ secrets.PYPI_API_TOKEN_CORE }}
|
|
47
|
+
packages_dir: dist
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Development
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
This project uses `venvstarter`_ to manage a ``virtualenv``.
|
|
5
|
+
|
|
6
|
+
All the commands will only install things locally to this repository.
|
|
7
|
+
|
|
8
|
+
To run mypy against this plugin::
|
|
9
|
+
|
|
10
|
+
> ./types
|
|
11
|
+
|
|
12
|
+
To run mypy only against the example Django app::
|
|
13
|
+
|
|
14
|
+
> ./types example
|
|
15
|
+
|
|
16
|
+
To clear the cache first::
|
|
17
|
+
|
|
18
|
+
> CLEAR_MYPY_CACHE=1 ./types
|
|
19
|
+
|
|
20
|
+
To run tests::
|
|
21
|
+
|
|
22
|
+
> ./test.sh
|
|
23
|
+
|
|
24
|
+
To run tests such that breakpoints work::
|
|
25
|
+
|
|
26
|
+
> ./test.sh --mypy-same-process -s
|
|
27
|
+
|
|
28
|
+
To activate the ``virtualenv`` in your current shell::
|
|
29
|
+
|
|
30
|
+
> source run.sh activate
|
|
31
|
+
|
|
32
|
+
To build the docs locally::
|
|
33
|
+
|
|
34
|
+
> ./run.sh docs view
|
|
35
|
+
|
|
36
|
+
.. _venvstarter: https://venvstarter.readthedocs.io
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Stephen Moore
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: extended_mypy_django_plugin
|
|
3
|
+
Version: 0.5
|
|
4
|
+
Summary: Trying to make mypy understand .objects on abstract django models
|
|
5
|
+
Author-email: Stephen Moore <stephen@delfick.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Provides-Extra: stubs-latest
|
|
9
|
+
Requires-Dist: django-stubs==5.0.0; extra == 'stubs-latest'
|
|
10
|
+
Requires-Dist: mypy==1.10.0; extra == 'stubs-latest'
|
|
11
|
+
Provides-Extra: stubs-older
|
|
12
|
+
Requires-Dist: django-stubs==4.2.3; extra == 'stubs-older'
|
|
13
|
+
Requires-Dist: mypy==1.4.0; extra == 'stubs-older'
|
|
14
|
+
Provides-Extra: tests
|
|
15
|
+
Requires-Dist: pytest==8.1.1; extra == 'tests'
|
|
16
|
+
Description-Content-Type: text/x-rst
|
|
17
|
+
|
|
18
|
+
Extended ``django-stubs``
|
|
19
|
+
=========================
|
|
20
|
+
|
|
21
|
+
This is an extension on the `django-stubs`_ project that attempts to make it
|
|
22
|
+
possible to work with abstract Django ORM models as if they represent all the
|
|
23
|
+
concrete models that extend from them.
|
|
24
|
+
|
|
25
|
+
There are also some extra changes to improve the experience of using this
|
|
26
|
+
``mypy`` plugin.
|
|
27
|
+
|
|
28
|
+
The intention is to get this code working and tested and documented before
|
|
29
|
+
getting those changes into the `django-stubs` project itself.
|
|
30
|
+
|
|
31
|
+
.. _django-stubs: https://github.com/typeddjango/django-stubs
|
|
32
|
+
|
|
33
|
+
Built Docs
|
|
34
|
+
----------
|
|
35
|
+
|
|
36
|
+
https://extended-mypy-django-plugin.readthedocs.io
|
|
37
|
+
|
|
38
|
+
History
|
|
39
|
+
-------
|
|
40
|
+
|
|
41
|
+
This project comes from working on a large Django project (millions of lines of
|
|
42
|
+
code) that has varying levels of typing maturity within it. There is work to
|
|
43
|
+
get this project onto the latest version of ``mypy`` and ``django-stubs``, but
|
|
44
|
+
it is difficult due to 100s of errors introduced by a change from ``mypy`` 1.5.0.
|
|
45
|
+
|
|
46
|
+
Most of these errors are due to using variables that are typed as Abstract Django
|
|
47
|
+
ORM models when they should be typed as the concrete models that inherit those
|
|
48
|
+
abstract models. Unfortunately this is not straight forward due to a few factors
|
|
49
|
+
that mean what concrete models are available can't be explicitly specified.
|
|
50
|
+
|
|
51
|
+
This project exists so that it can work with either the old version of
|
|
52
|
+
``django-stubs`` that is in use or the latest ``django-stubs``. Support for the
|
|
53
|
+
old version is purely a transitional clutch.
|
|
54
|
+
|
|
55
|
+
Status
|
|
56
|
+
------
|
|
57
|
+
|
|
58
|
+
This mostly works and is in a reasonable tidy state, but some more work needs
|
|
59
|
+
to be done improve the test coverage and general tidiness oft he code.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Extended ``django-stubs``
|
|
2
|
+
=========================
|
|
3
|
+
|
|
4
|
+
This is an extension on the `django-stubs`_ project that attempts to make it
|
|
5
|
+
possible to work with abstract Django ORM models as if they represent all the
|
|
6
|
+
concrete models that extend from them.
|
|
7
|
+
|
|
8
|
+
There are also some extra changes to improve the experience of using this
|
|
9
|
+
``mypy`` plugin.
|
|
10
|
+
|
|
11
|
+
The intention is to get this code working and tested and documented before
|
|
12
|
+
getting those changes into the `django-stubs` project itself.
|
|
13
|
+
|
|
14
|
+
.. _django-stubs: https://github.com/typeddjango/django-stubs
|
|
15
|
+
|
|
16
|
+
Built Docs
|
|
17
|
+
----------
|
|
18
|
+
|
|
19
|
+
https://extended-mypy-django-plugin.readthedocs.io
|
|
20
|
+
|
|
21
|
+
History
|
|
22
|
+
-------
|
|
23
|
+
|
|
24
|
+
This project comes from working on a large Django project (millions of lines of
|
|
25
|
+
code) that has varying levels of typing maturity within it. There is work to
|
|
26
|
+
get this project onto the latest version of ``mypy`` and ``django-stubs``, but
|
|
27
|
+
it is difficult due to 100s of errors introduced by a change from ``mypy`` 1.5.0.
|
|
28
|
+
|
|
29
|
+
Most of these errors are due to using variables that are typed as Abstract Django
|
|
30
|
+
ORM models when they should be typed as the concrete models that inherit those
|
|
31
|
+
abstract models. Unfortunately this is not straight forward due to a few factors
|
|
32
|
+
that mean what concrete models are available can't be explicitly specified.
|
|
33
|
+
|
|
34
|
+
This project exists so that it can work with either the old version of
|
|
35
|
+
``django-stubs`` that is in use or the latest ``django-stubs``. Support for the
|
|
36
|
+
old version is purely a transitional clutch.
|
|
37
|
+
|
|
38
|
+
Status
|
|
39
|
+
------
|
|
40
|
+
|
|
41
|
+
This mostly works and is in a reasonable tidy state, but some more work needs
|
|
42
|
+
to be done improve the test coverage and general tidiness oft he code.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Documentation
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
From the root of the repo, to build the documentation run::
|
|
5
|
+
|
|
6
|
+
> ./run.sh docs
|
|
7
|
+
|
|
8
|
+
If you want to build from fresh then say::
|
|
9
|
+
|
|
10
|
+
> ./run.sh docs fresh
|
|
11
|
+
|
|
12
|
+
Once your documentation is built do something like::
|
|
13
|
+
|
|
14
|
+
> ./run.sh docs view
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Installation
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
.. note:: This plugin hasn't been published on pypi at this point
|
|
5
|
+
|
|
6
|
+
Enabling this plugin in a project is adding either to ``mypy.ini``::
|
|
7
|
+
|
|
8
|
+
[mypy]
|
|
9
|
+
plugins =
|
|
10
|
+
extended_mypy_django_plugin.main
|
|
11
|
+
mypy_path = $MYPY_CONFIG_FILE_DIR/./path/relative/to/config/where/information/is/cached
|
|
12
|
+
|
|
13
|
+
[mypy.plugins.django-stubs]
|
|
14
|
+
scratch_path = ./path/relative/to/config/where/information/is/cached
|
|
15
|
+
django_settings_module = some_valid_import_path_to_django_settings
|
|
16
|
+
|
|
17
|
+
Or to ``pyproject.toml``::
|
|
18
|
+
|
|
19
|
+
[tool.mypy]
|
|
20
|
+
plugins = ["extended_mypy_django_plugin.main"]
|
|
21
|
+
mypy_path = "$MYPY_CONFIG_FILE_DIR/./path/relative/to/config/where/information/is/cached"
|
|
22
|
+
|
|
23
|
+
[tool.django-stubs]
|
|
24
|
+
scratch_path = "./path/relative/to/config/where/information/is/cached"
|
|
25
|
+
django_settings_module = "some_valid_import_path_to_django_settings"
|
|
26
|
+
|
|
27
|
+
.. note:: This project adds a mandatory setting ``scratch_path`` that
|
|
28
|
+
will be a path relative to the config file where the mypy plugin will write
|
|
29
|
+
files to for the purpose of understanding when files need to be re-analyzed.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Actions
|
|
2
|
+
-------
|
|
3
|
+
|
|
4
|
+
The logic that glues together the annotations to be resolved with the resolved
|
|
5
|
+
types lives within the ``actions`` subpackage of the plugin.
|
|
6
|
+
|
|
7
|
+
All the hooks for a mypy plugin will have an ``api`` on the context that is provided
|
|
8
|
+
(except ``report_config_data`` and ``get_additional_deps`` and these ``api``
|
|
9
|
+
objects are either a ``SemanticAnalyzerPluginInterface``, ``TypeAnalyzerPluginInterface``
|
|
10
|
+
or a ``CheckerPluginInterface``.
|
|
11
|
+
|
|
12
|
+
Curently, in practice though these are going to the specific concrete variants
|
|
13
|
+
of these:
|
|
14
|
+
|
|
15
|
+
* ``SemanticAnalyzerPluginInterface`` is a ``mypy.semanal.SemanticAnalyzer``
|
|
16
|
+
* ``TypeAnalyzerPluginInterface`` is a ``mypy.typeanal.TypeAnalyser``
|
|
17
|
+
* ``CheckerPluginInterface`` is a ``mypy.checker.TypeChecker``
|
|
18
|
+
|
|
19
|
+
The plugin will assert that this is the case before passing them into an
|
|
20
|
+
instance of the one of the classes in the actions folder to do the work.
|
|
21
|
+
|
|
22
|
+
There is a class for each of these Interfaces:
|
|
23
|
+
|
|
24
|
+
.. autoclass:: extended_mypy_django_plugin.plugin.actions._sem_analyze.SemAnalyzing
|
|
25
|
+
|
|
26
|
+
.. autoclass:: extended_mypy_django_plugin.plugin.actions._type_analyze.TypeAnalyzing
|
|
27
|
+
|
|
28
|
+
.. autoclass:: extended_mypy_django_plugin.plugin.actions._type_checker.TypeChecking
|
|
29
|
+
|
|
30
|
+
The specifics of what they do in this plugin has yet to be documented. More
|
|
31
|
+
information of the structure of a mypy plugin is best done by reading the mypy
|
|
32
|
+
source code.
|
|
33
|
+
|
|
34
|
+
Specifically the module level do comment of:
|
|
35
|
+
|
|
36
|
+
* https://github.com/python/mypy/blob/1.9.0/mypy/plugin.py
|
|
37
|
+
* https://github.com/python/mypy/blob/1.9.0/mypy/semanal.py
|
|
38
|
+
|
|
39
|
+
And plugins that can be found:
|
|
40
|
+
|
|
41
|
+
* https://github.com/python/mypy/tree/1.9.0/mypy/plugins
|
|
42
|
+
* https://github.com/typeddjango/django-stubs
|
|
43
|
+
* https://github.com/dry-python/returns/blob/master/returns/contrib/mypy/returns_plugin.py
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
The Store
|
|
2
|
+
---------
|
|
3
|
+
|
|
4
|
+
.. autoclass:: extended_mypy_django_plugin.plugin._store.Store
|
|
5
|
+
|
|
6
|
+
.. autoprotocol:: extended_mypy_django_plugin.plugin._store.LookupFunction
|
|
7
|
+
|
|
8
|
+
.. autoprotocol:: extended_mypy_django_plugin.plugin._store.LookupInstanceFunction
|
|
9
|
+
|
|
10
|
+
.. autoprotocol:: extended_mypy_django_plugin.plugin._store.GetModelClassByFullname
|
|
11
|
+
|
|
12
|
+
.. autoprotocol:: extended_mypy_django_plugin.plugin._store.IsInstalledModel
|
|
13
|
+
|
|
14
|
+
.. autoprotocol:: extended_mypy_django_plugin.plugin._store.KnownConcreteModelsGetter
|