Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove find_dependent_paths and depenent path cleanup #85

Merged
merged 1 commit into from
Oct 19, 2021
Merged
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
16 changes: 1 addition & 15 deletions pytest_mypy_plugins/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,6 @@ def remove_cache_files(self, fpath_no_suffix: Path) -> None:
):
parent_dir.rmdir()

def find_dependent_paths(self, path: Path) -> List[Path]:
py_module = ".".join(path.with_suffix("").parts)
dependants = []
for dirpath, _, filenames in os.walk(self.incremental_cache_dir):
for filename in filenames:
path = Path(dirpath) / filename
if f'"{py_module}"' in path.read_text():
dependants.append(path.with_suffix("").with_suffix(""))
return dependants

def typecheck_in_new_subprocess(
self, execution_path: Path, mypy_cmd_options: List[Any]
) -> Tuple[int, Tuple[str, str]]:
Expand Down Expand Up @@ -293,16 +283,12 @@ def runtest(self) -> None:

finally:
temp_dir.cleanup()
# remove created modules and all their dependants from cache
# remove created modules
if not self.disable_cache:
for file in self.files:
path = Path(file.path)
self.remove_cache_files(path.with_suffix(""))

dependants = self.find_dependent_paths(path)
for dependant in dependants:
self.remove_cache_files(dependant)

assert not os.path.exists(temp_dir.name)

def prepare_mypy_cmd_options(self, execution_path: Path) -> List[str]:
Expand Down