mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-18 01:45:59 +08:00
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
@@ -19,12 +19,6 @@ jobs:
|
|||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
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
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install -U pip setuptools wheel
|
pip install -U pip setuptools wheel
|
||||||
@@ -46,12 +40,6 @@ jobs:
|
|||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
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
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install -U pip setuptools wheel
|
pip install -U pip setuptools wheel
|
||||||
@@ -74,12 +62,6 @@ jobs:
|
|||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
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
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install -U pip setuptools wheel
|
pip install -U pip setuptools wheel
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ coreapi==2.3.3
|
|||||||
gitpython==3.1.9
|
gitpython==3.1.9
|
||||||
pre-commit==2.13.0
|
pre-commit==2.13.0
|
||||||
pytest==6.1.1
|
pytest==6.1.1
|
||||||
pytest-mypy-plugins==1.7.0
|
pytest-mypy-plugins==1.9.2
|
||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
types-toml==0.1.1
|
types-toml==0.1.1
|
||||||
-e ./django_stubs_ext
|
-e ./django_stubs_ext
|
||||||
|
|||||||
@@ -63,10 +63,7 @@
|
|||||||
main: |
|
main: |
|
||||||
from myapp.models import User
|
from myapp.models import User
|
||||||
reveal_type(User().my_pk) # N: Revealed type is "builtins.int*"
|
reveal_type(User().my_pk) # N: Revealed type is "builtins.int*"
|
||||||
reveal_type(User().id)
|
User().id # E: "User" has no attribute "id"
|
||||||
out: |
|
|
||||||
main:3: note: Revealed type is "Any"
|
|
||||||
main:3: error: "User" has no attribute "id"
|
|
||||||
installed_apps:
|
installed_apps:
|
||||||
- myapp
|
- myapp
|
||||||
files:
|
files:
|
||||||
|
|||||||
@@ -130,10 +130,7 @@
|
|||||||
main: |
|
main: |
|
||||||
from myapp.models import View
|
from myapp.models import View
|
||||||
reveal_type(View().app.views) # N: Revealed type is "django.db.models.manager.RelatedManager[myapp.models.View]"
|
reveal_type(View().app.views) # N: Revealed type is "django.db.models.manager.RelatedManager[myapp.models.View]"
|
||||||
reveal_type(View().app.unknown)
|
View().app.unknown # E: "App" has no attribute "unknown"
|
||||||
out: |
|
|
||||||
main:3: note: Revealed type is "Any"
|
|
||||||
main:3: error: "App" has no attribute "unknown"
|
|
||||||
installed_apps:
|
installed_apps:
|
||||||
- myapp
|
- myapp
|
||||||
- myapp2
|
- myapp2
|
||||||
|
|||||||
@@ -52,12 +52,8 @@
|
|||||||
b_instance = B()
|
b_instance = B()
|
||||||
reveal_type(b_instance.b_attr) # N: Revealed type is "builtins.int"
|
reveal_type(b_instance.b_attr) # N: Revealed type is "builtins.int"
|
||||||
|
|
||||||
reveal_type(b_instance.non_existent_attribute)
|
b_instance.non_existent_attribute # E: "B" has no attribute "non_existent_attribute"
|
||||||
b_instance.non_existent_attribute = 2
|
b_instance.non_existent_attribute = 2 # E: "B" has no attribute "non_existent_attribute"
|
||||||
out: |
|
|
||||||
main:5: note: Revealed type is "Any"
|
|
||||||
main:5: error: "B" has no attribute "non_existent_attribute"
|
|
||||||
main:6: error: "B" has no attribute "non_existent_attribute"
|
|
||||||
installed_apps:
|
installed_apps:
|
||||||
- myapp
|
- myapp
|
||||||
files:
|
files:
|
||||||
|
|||||||
@@ -18,11 +18,9 @@
|
|||||||
reveal_type(MyUser._meta.get_field('base_name')) # N: Revealed type is "django.db.models.fields.CharField[Any, Any]"
|
reveal_type(MyUser._meta.get_field('base_name')) # N: Revealed type is "django.db.models.fields.CharField[Any, Any]"
|
||||||
reveal_type(MyUser._meta.get_field('name')) # N: Revealed type is "django.db.models.fields.CharField[Any, Any]"
|
reveal_type(MyUser._meta.get_field('name')) # N: Revealed type is "django.db.models.fields.CharField[Any, Any]"
|
||||||
reveal_type(MyUser._meta.get_field('age')) # N: Revealed type is "django.db.models.fields.IntegerField[Any, Any]"
|
reveal_type(MyUser._meta.get_field('age')) # N: Revealed type is "django.db.models.fields.IntegerField[Any, Any]"
|
||||||
reveal_type(MyUser._meta.get_field('unknown'))
|
|
||||||
reveal_type(MyUser._meta.get_field('to_user')) # N: Revealed type is "django.db.models.fields.related.ForeignKey[Any, Any]"
|
reveal_type(MyUser._meta.get_field('to_user')) # N: Revealed type is "django.db.models.fields.related.ForeignKey[Any, Any]"
|
||||||
out: |
|
|
||||||
main:5: note: Revealed type is "Any"
|
MyUser._meta.get_field('unknown') # E: MyUser has no field named 'unknown'
|
||||||
main:5: error: MyUser has no field named 'unknown'
|
|
||||||
installed_apps:
|
installed_apps:
|
||||||
- myapp
|
- myapp
|
||||||
files:
|
files:
|
||||||
|
|||||||
@@ -30,10 +30,7 @@
|
|||||||
- case: fail_if_there_is_no_setting
|
- case: fail_if_there_is_no_setting
|
||||||
main: |
|
main: |
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
reveal_type(settings.NOT_EXISTING)
|
settings.NOT_EXISTING # E: 'Settings' object has no attribute 'NOT_EXISTING'
|
||||||
out: |
|
|
||||||
main:2: note: Revealed type is "Any"
|
|
||||||
main:2: error: 'Settings' object has no attribute 'NOT_EXISTING'
|
|
||||||
|
|
||||||
- case: override_default_setting_with_different_type_in_the_different_module
|
- case: override_default_setting_with_different_type_in_the_different_module
|
||||||
custom_settings: |
|
custom_settings: |
|
||||||
|
|||||||
Reference in New Issue
Block a user