mirror of
https://github.com/davidhalter/django-stubs.git
synced 2026-03-05 06:34:16 +08:00
add settings support
This commit is contained in:
@@ -24,16 +24,6 @@
|
||||
if TYPE_CHECKING:
|
||||
reveal_type(MyModel.user) # N: Revealed type is 'django.contrib.auth.models.User*'
|
||||
|
||||
- case: missing_settings_ignored_flag
|
||||
main: |
|
||||
from django.conf import settings
|
||||
reveal_type(settings.NO_SUCH_SETTING) # N: Revealed type is 'Any'
|
||||
files:
|
||||
- path: pyproject.toml
|
||||
content: |
|
||||
[tool.django-stubs]
|
||||
ignore_missing_settings = true
|
||||
|
||||
- case: generate_pyproject_toml_and_settings_file_from_installed_apps_key
|
||||
main: |
|
||||
from myapp.models import MyModel
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
- case: settings_loaded_from_different_files
|
||||
disable_cache: true
|
||||
main: |
|
||||
from django.conf import settings
|
||||
# standard settings
|
||||
reveal_type(settings.AUTH_USER_MODEL) # N: Revealed type is 'builtins.str'
|
||||
reveal_type(settings.ROOT_DIR) # N: Revealed type is 'builtins.str'
|
||||
reveal_type(settings.APPS_DIR) # N: Revealed type is 'pathlib.Path'
|
||||
reveal_type(settings.OBJ) # N: Revealed type is 'django.utils.functional.LazyObject'
|
||||
reveal_type(settings.NUMBERS) # N: Revealed type is 'builtins.list[builtins.str*]'
|
||||
reveal_type(settings.DICT) # N: Revealed type is 'builtins.dict[Any, Any]'
|
||||
files:
|
||||
@@ -19,9 +19,6 @@
|
||||
SECRET_KEY = 112233
|
||||
NUMBERS = ['one', 'two']
|
||||
DICT = {} # type: ignore
|
||||
|
||||
from django.utils.functional import LazyObject
|
||||
OBJ = LazyObject()
|
||||
- path: base.py
|
||||
content: |
|
||||
from pathlib import Path
|
||||
@@ -33,6 +30,7 @@
|
||||
from django.conf import settings
|
||||
reveal_type(settings.AUTH_USER_MODEL) # N: Revealed type is 'builtins.str'
|
||||
reveal_type(settings.AUTHENTICATION_BACKENDS) # N: Revealed type is 'typing.Sequence[builtins.str]'
|
||||
installed_apps: []
|
||||
|
||||
- case: fail_if_there_is_no_setting
|
||||
main: |
|
||||
|
||||
Reference in New Issue
Block a user