Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mypy_django_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,10 @@ def parse_ini_file(self, filepath: Path) -> None:
self.strict_settings = parser.getboolean(section, "strict_settings", fallback=True)
except ValueError:
exit_with_error(INVALID_BOOL_SETTING.format(key="strict_settings"))

def to_json(self) -> Dict[str, Any]:
"""We use this method to reset mypy cache via `report_config_data` hook."""
return {
"django_settings_module": self.django_settings_module,
"strict_settings": self.strict_settings,
}
7 changes: 6 additions & 1 deletion mypy_django_plugin/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import itertools
import sys
from functools import partial
from typing import Callable, Dict, List, Optional, Tuple, Type
from typing import Any, Callable, Dict, List, Optional, Tuple, Type

from mypy.modulefinder import mypy_path
from mypy.nodes import MypyFile, TypeInfo
Expand All @@ -14,6 +14,7 @@
FunctionContext,
MethodContext,
Plugin,
ReportConfigContext,
)
from mypy.types import Type as MypyType

Expand Down Expand Up @@ -331,6 +332,10 @@ def get_dynamic_class_hook(self, fullname: str) -> Optional[Callable[[DynamicCla
return create_new_manager_class_from_as_manager_method
return None

def report_config_data(self, ctx: ReportConfigContext) -> Dict[str, Any]:
# Cache would be cleared if any settings do change.
return self.plugin_config.to_json()


def plugin(version: str) -> Type[NewSemanalDjangoPlugin]:
return NewSemanalDjangoPlugin