mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-06 20:24:31 +08:00
add default for MYPY_DJANGO_CONFIG
This commit is contained in:
@@ -26,7 +26,7 @@ in your `mypy.ini` file.
|
||||
|
||||
## Configuration
|
||||
|
||||
In order to specify config file, set `MYPY_DJANGO_CONFIG` environment variable with path to the config file.
|
||||
In order to specify config file, set `MYPY_DJANGO_CONFIG` environment variable with path to the config file. Default is `./mypy_django.ini`
|
||||
|
||||
Config file format (.ini):
|
||||
```
|
||||
|
||||
@@ -113,8 +113,8 @@ class DjangoPlugin(Plugin):
|
||||
monkeypatch.restore_original_load_graph()
|
||||
monkeypatch.restore_original_dependencies_handling()
|
||||
|
||||
config_fpath = os.environ.get('MYPY_DJANGO_CONFIG')
|
||||
if config_fpath:
|
||||
config_fpath = os.environ.get('MYPY_DJANGO_CONFIG', 'mypy_django.ini')
|
||||
if config_fpath and os.path.exists(config_fpath):
|
||||
self.config = Config.from_config_file(config_fpath)
|
||||
self.django_settings = self.config.django_settings_module
|
||||
else:
|
||||
|
||||
@@ -20,4 +20,16 @@ django_settings = mysettings
|
||||
|
||||
[file mysettings.py]
|
||||
MY_SETTING: int = 1
|
||||
[out]
|
||||
[out]
|
||||
|
||||
[CASE mypy_django_ini_in_current_directory_is_a_default]
|
||||
from django.conf import settings
|
||||
reveal_type(settings.MY_SETTING) # E: Revealed type is 'builtins.int'
|
||||
|
||||
[file mypy_django.ini]
|
||||
[[mypy_django_plugin]
|
||||
django_settings = mysettings
|
||||
|
||||
[file mysettings.py]
|
||||
MY_SETTING: int = 1
|
||||
[out]
|
||||
|
||||
Reference in New Issue
Block a user