From 87c7aa45119aa240fa351391525558dff673ede9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 07:04:50 +0000 Subject: [PATCH 1/2] Bump mypy from 1.20.2 to 2.1.0 Bumps [mypy](https://github.com/python/mypy) from 1.20.2 to 2.1.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.20.2...v2.1.0) --- updated-dependencies: - dependency-name: mypy dependency-version: 2.1.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a86bc4a..7a91e1f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,5 @@ types-decorator types-PyYAML types-setuptools types-regex -mypy==1.20.2 +mypy==2.1.0 -e . From 80338a4e1e31121a1a5f3c103cb42fe5c70de926 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 09:08:05 +0000 Subject: [PATCH 2/2] Fix tests for mypy 2.1.0 compatibility Agent-Logs-Url: https://github.com/typeddjango/pytest-mypy-plugins/sessions/d362aeb8-8460-45d3-a5d0-c9f3cb43219f Co-authored-by: sobolevn <4660275+sobolevn@users.noreply.github.com> --- pytest_mypy_plugins/item.py | 28 +++++++++++++++++-- pytest_mypy_plugins/tests/test_mypy_cache.py | 6 +++- .../tests/test_site_packages.py | 10 ++++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pytest_mypy_plugins/item.py b/pytest_mypy_plugins/item.py index 922f400..8fa50c4 100644 --- a/pytest_mypy_plugins/item.py +++ b/pytest_mypy_plugins/item.py @@ -1,6 +1,7 @@ import importlib import io import os +import re import shutil import subprocess import sys @@ -92,6 +93,17 @@ class ReturnCodes: FATAL_ERROR = 2 +def _get_sqlite_num_shards(cache_dir: str) -> int: + """Return the number of SQLite shards in the cache directory, or 0 if none exist.""" + cache_dir_path = Path(cache_dir) + shard_files = [f for f in cache_dir_path.glob("cache.*.db") if re.match(r"^cache\.\d+\.db$", f.name)] + if shard_files: + return len(shard_files) + if (cache_dir_path / "cache.db").is_file(): + return 1 + return 0 + + def run_mypy_typechecking(cmd_options: List[str], stdout: TextIO, stderr: TextIO) -> int: fscache = FileSystemCache() sources, options = process_options(cmd_options, fscache=fscache) @@ -374,7 +386,16 @@ def remove_cache_files(self, fpath_no_suffix: Path) -> None: # Build entry names to remove for each path component so namespace-package # cache entries are also cleaned (e.g. "pkg.*", "pkg/sub.*", "pkg/sub/mod.*"). - suffixes = (".meta.json", ".data.json", ".err.json", ".meta.ff", ".data.ff", ".err.ff") + suffixes = ( + ".meta.json", + ".data.json", + ".err.json", + ".meta_ex.json", + ".meta.ff", + ".data.ff", + ".err.ff", + ".meta_ex.ff", + ) entries: list[str] = [] accumulated = "" for i, part in enumerate(fpath_no_suffix.parts): @@ -388,8 +409,9 @@ def remove_cache_files(self, fpath_no_suffix: Path) -> None: entries.extend(accumulated + s for s in suffixes) stores: list[MetadataStore] = [] - if os.path.isfile(os.path.join(cache_dir, "cache.db")): - stores.append(SqliteMetadataStore(cache_dir)) + num_shards = _get_sqlite_num_shards(cache_dir) + if num_shards > 0: + stores.append(SqliteMetadataStore(cache_dir, num_shards=num_shards)) stores.append(FilesystemMetadataStore(cache_dir)) for store in stores: diff --git a/pytest_mypy_plugins/tests/test_mypy_cache.py b/pytest_mypy_plugins/tests/test_mypy_cache.py index 70aac48..4427683 100644 --- a/pytest_mypy_plugins/tests/test_mypy_cache.py +++ b/pytest_mypy_plugins/tests/test_mypy_cache.py @@ -1,3 +1,4 @@ +import re import subprocess from collections.abc import Generator from pathlib import Path @@ -212,7 +213,10 @@ def make_yaml_test_file( def get_created_cache_files(cache_dir: Path, module_rel_paths_no_suffix: tuple[str, ...]) -> list[str]: stores: list[MetadataStore] = [] cache_dir_str = str(cache_dir) - if (cache_dir / "cache.db").is_file(): + shard_files = [f for f in cache_dir.glob("cache.*.db") if re.match(r"^cache\.\d+\.db$", f.name)] + if shard_files: + stores.append(SqliteMetadataStore(cache_dir_str, num_shards=len(shard_files))) + elif (cache_dir / "cache.db").is_file(): stores.append(SqliteMetadataStore(cache_dir_str)) if cache_dir.is_dir(): stores.append(FilesystemMetadataStore(cache_dir_str)) diff --git a/pytest_mypy_plugins/tests/test_site_packages.py b/pytest_mypy_plugins/tests/test_site_packages.py index e766c34..fc45318 100644 --- a/pytest_mypy_plugins/tests/test_site_packages.py +++ b/pytest_mypy_plugins/tests/test_site_packages.py @@ -1,8 +1,8 @@ import os.path -import site import subprocess from pathlib import Path +import mypy import pytest @@ -155,7 +155,9 @@ def make_yaml_test_file( file_base_name: str = "test-case", ) -> None: output_path = root_dir.joinpath(file_base_name).with_suffix(".yml") - site_packages_path: Path | str = Path(site.getsitepackages()[0]) - site_packages_path = os.path.relpath(site_packages_path, start=output_path) - contents = contents.format(site_packages_path=site_packages_path) + # Use the directory containing the installed mypy package as the site-packages path, + # since mypy may be installed in a user site-packages directory rather than the system one. + site_packages_path: Path = Path(mypy.__file__).parent.parent + site_packages_path_str = os.path.relpath(site_packages_path, start=output_path) + contents = contents.format(site_packages_path=site_packages_path_str) output_path.write_text(contents)