add default for MYPY_DJANGO_CONFIG

This commit is contained in:
Maxim Kurnikov
2019-02-13 23:02:49 +03:00
parent dcd9ee0bb8
commit f30cd092f1
3 changed files with 16 additions and 4 deletions

View File

@@ -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):
```

View File

@@ -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:

View File

@@ -21,3 +21,15 @@ django_settings = mysettings
[file mysettings.py]
MY_SETTING: int = 1
[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]