File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import hashlib
34from typing import TYPE_CHECKING
45
56from pytest_mypy_plugins .collect import File
@@ -13,6 +14,12 @@ def django_plugin_hook(test_item: YamlTestItem) -> None:
1314 installed_apps = test_item .parsed_test_data .get ("installed_apps" , None )
1415 monkeypatch = test_item .parsed_test_data .get ("monkeypatch" , False )
1516
17+ # When the result of `Plugin.report_config_data` changes, the mypy cache is invalidated.
18+ # This slows down the test suite because test can be executed in any order, regularly invalidating shared cache.
19+ # To mitigate this, use different cache dirs based on the settings.
20+ config_hash = hashlib .md5 (f"{ installed_apps } { custom_settings } " .encode (), usedforsecurity = False ).hexdigest ()[:10 ]
21+ test_item .incremental_cache_dir += config_hash
22+
1623 if installed_apps and custom_settings :
1724 raise ValueError ('"installed_apps" and "custom_settings" are not compatible, please use one or the other' )
1825
You can’t perform that action at this time.
0 commit comments