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
6 changes: 5 additions & 1 deletion pytest_mypy_plugins/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,11 @@ def remove_cache_files(self, fpath_no_suffix: Path) -> None:
pass
store.commit()
finally:
store.close()
# ``MetadataStore.close`` was added in mypy 1.20; guard for older
# mypy versions that are still within our supported range (>=1.3).
close = getattr(store, "close", None)
if close is not None:
close()

def execute_extension_hook(self) -> None:
extension_hook_fqname = self.config.option.mypy_extension_hook
Expand Down
5 changes: 4 additions & 1 deletion pytest_mypy_plugins/tests/test_mypy_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ def get_created_cache_files(cache_dir: Path, module_rel_paths_no_suffix: tuple[s
if any(entry.startswith(rel_path + ".") for rel_path in module_rel_paths_no_suffix):
created.append(entry)
finally:
store.close()
# See PR #188: mypy < 1.20 does not have MetadataStore.close
close = getattr(store, "close", None)
if close is not None:
close()

return created