From 29b135013c78215a8498f364f3a463bf92c1c055 Mon Sep 17 00:00:00 2001 From: Matthew Broadway Date: Sun, 17 Nov 2024 16:29:03 +0000 Subject: [PATCH] upgrade to latest packages --- .pre-commit-config.yaml | 8 +- src/maturin_import_hook/_resolve_project.py | 14 +- src/maturin_import_hook/project_importer.py | 2 +- tests/README.md | 4 +- tests/maturin | 2 +- tests/package_resolver/Cargo.lock | 123 +++++++++++------- tests/requirements.txt | 4 +- tests/resolved.json | 2 +- tests/test_import_hook/common.py | 6 +- tests/test_import_hook/conftest.py | 3 +- .../logging_reload_helper.py | 3 +- .../test_import_hook/test_project_importer.py | 12 +- .../test_rust_file_importer.py | 10 +- tests/test_import_hook/test_site.py | 1 + tests/test_import_hook/test_utilities.py | 4 +- 15 files changed, 112 insertions(+), 86 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 546870f..4001a5c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-yaml - id: check-toml @@ -8,13 +8,13 @@ repos: - id: trailing-whitespace - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.9 + rev: v0.7.4 hooks: - id: ruff-format - id: ruff args: [ --fix ] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.0 + rev: v1.13.0 hooks: # note: mypy runs in an isolated environment and so has no access to third party packages - id: mypy @@ -26,6 +26,6 @@ repos: hooks: - id: codespell - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.41.0 + rev: v0.42.0 hooks: - id: markdownlint-fix diff --git a/src/maturin_import_hook/_resolve_project.py b/src/maturin_import_hook/_resolve_project.py index c89eb6f..f1d8395 100644 --- a/src/maturin_import_hook/_resolve_project.py +++ b/src/maturin_import_hook/_resolve_project.py @@ -60,7 +60,7 @@ def get_value(self, keys: list[str], required_type: type[_T]) -> Optional[_T]: def find_cargo_manifest(project_dir: Path) -> Optional[Path]: pyproject_path = project_dir / "pyproject.toml" - if pyproject_path.exists(): + if pyproject_path.is_file(): pyproject_data = pyproject_path.read_text() if "manifest-path" in pyproject_data: pyproject = _TomlFile.from_string(pyproject_path, pyproject_data) @@ -69,17 +69,17 @@ def find_cargo_manifest(project_dir: Path) -> Optional[Path]: return project_dir / relative_manifest_path manifest_path = project_dir / "Cargo.toml" - if manifest_path.exists(): + if manifest_path.is_file(): return manifest_path manifest_path = project_dir / "rust/Cargo.toml" - if manifest_path.exists(): + if manifest_path.is_file(): return manifest_path return None -def is_maybe_maturin_project(project_dir: Path) -> bool: +def is_maybe_maturin_project(directory: Path) -> bool: """note: this function does not check if this really is a maturin project for simplicity.""" - return (project_dir / "pyproject.toml").exists() and find_cargo_manifest(project_dir) is not None + return (directory / "pyproject.toml").is_file() and find_cargo_manifest(directory) is not None class ProjectResolver: @@ -247,8 +247,8 @@ def _get_immediate_path_dependencies(manifest_dir_path: Path, cargo: _TomlFile) path_dependencies = [] for dependency in cargo.get_value_or_default(["dependencies"], dict, {}).values(): if isinstance(dependency, dict): - relative_path = dependency.get("path", None) - if relative_path is not None: + relative_path: Any = dependency.get("path", None) + if relative_path is not None and isinstance(relative_path, str): path_dependencies.append((manifest_dir_path / relative_path).resolve()) return path_dependencies diff --git a/src/maturin_import_hook/project_importer.py b/src/maturin_import_hook/project_importer.py index 33c6ba8..4ab87f3 100644 --- a/src/maturin_import_hook/project_importer.py +++ b/src/maturin_import_hook/project_importer.py @@ -104,7 +104,7 @@ def find_maturin(self) -> Path: return self._maturin_path def invalidate_caches(self) -> None: - """called by importlib.invalidate_caches()""" + """called by `importlib.invalidate_caches()`""" logger.info("clearing cache") self._resolver.clear_cache() _find_maturin_project_above.cache_clear() diff --git a/tests/README.md b/tests/README.md index 50ff759..363ad32 100644 --- a/tests/README.md +++ b/tests/README.md @@ -33,12 +33,14 @@ To update maturin: - update the submodule to the maturin commit you want to update to - re-run the `package_resolver` to update `resolved.json` (see `package_resolver/README.md` for instructions) -- update `requirements.txt` to match the packages and versions used by the maturin ci (`.github/workflows.test.yml`) +- update `requirements.txt` to match the packages and versions installed by the maturin ci + (see `pip install` commands in `maturin/.github/workflows/test.yml`) - check the `uniffi` package version listed in the `Cargo.toml` of any of the `uniffi-*` test crates and update `uniffi-bindgen` in `requirements.txt` to match. - check that no crates have been added to `test-crates` that should be excluded from the import hook tests. If so, add them to `IGNORED_TEST_CRATES` in `common.py` - update the version check in the import hook to ensure it allows using the new version +- run the tests to ensure everything still works ## Notes diff --git a/tests/maturin b/tests/maturin index 894231c..aebaded 160000 --- a/tests/maturin +++ b/tests/maturin @@ -1 +1 @@ -Subproject commit 894231c644c2d7a9a31349c86b3f3c431b74d615 +Subproject commit aebadedec43a92a1ba0fe94980c84f37122aa5b3 diff --git a/tests/package_resolver/Cargo.lock b/tests/package_resolver/Cargo.lock index c2dfb31..cb6fa44 100644 --- a/tests/package_resolver/Cargo.lock +++ b/tests/package_resolver/Cargo.lock @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "cargo-xwin" -version = "0.16.4" +version = "0.16.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6c3dd7f20fdd197397532ac882e918cfe1d56f262a97ded7460a50e031e06b" +checksum = "471f6fff351fc5ab837ce7223637f7c20048e4a846708e7e58fda64db9d3a8b9" dependencies = [ "anyhow", "cargo-config2", @@ -254,18 +254,21 @@ dependencies = [ [[package]] name = "cargo-zigbuild" -version = "0.18.4" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65004153e67ac23be88a8e244304a872d727b2aa08654dcabfbecd1fdea4a488" +checksum = "20de66555d3ebec780021a7cd51aafe92b9e8f4fa648ef1f12e9c723b76c9764" dependencies = [ "anyhow", + "cargo-config2", "cargo-options", "cargo_metadata", "clap", + "crc", "dirs", "fs-err", "path-slash", "rustc_version", + "rustflags", "semver", "serde", "serde_json", @@ -383,9 +386,9 @@ dependencies = [ [[package]] name = "clap_complete_command" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "183495371ea78d4c9ff638bfc6497d46fed2396e4f9c50aebc1278a4a9919a3d" +checksum = "da8e198c052315686d36371e8a3c5778b7852fc75cc313e4e11eeb7a644a1b62" dependencies = [ "clap", "clap_complete", @@ -394,9 +397,9 @@ dependencies = [ [[package]] name = "clap_complete_nushell" -version = "0.1.11" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d02bc8b1a18ee47c4d2eec3fb5ac034dc68ebea6125b1509e9ccdffcddce66e" +checksum = "315902e790cc6e5ddd20cbd313c1d0d49db77f191e149f96397230fb82a17677" dependencies = [ "clap", "clap_complete", @@ -411,7 +414,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] @@ -464,6 +467,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.3.2" @@ -726,8 +744,8 @@ dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.4", - "regex-syntax 0.8.2", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", ] [[package]] @@ -792,7 +810,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata 0.4.4", + "regex-automata 0.4.9", "same-file", "walkdir", "winapi-util", @@ -949,7 +967,7 @@ dependencies = [ [[package]] name = "maturin" -version = "1.6.0" +version = "1.7.4" dependencies = [ "anyhow", "base64 0.21.7", @@ -991,6 +1009,7 @@ dependencies = [ "rustc_version", "rustls", "rustls-pemfile", + "same-file", "semver", "serde", "serde_json", @@ -1183,9 +1202,9 @@ checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" [[package]] name = "pep440_rs" -version = "0.5.0" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15efd4d885c29126cc93e12af3087896e2518bd5ca0fb328c19c4ef9cecfa8be" +checksum = "466eada3179c2e069ca897b99006cbb33f816290eaeec62464eea907e22ae385" dependencies = [ "once_cell", "serde", @@ -1196,9 +1215,9 @@ dependencies = [ [[package]] name = "pep508_rs" -version = "0.4.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1455babf8edd3eedcdfcb39700e455a4bb189e71b4f1fa0eacc9b244cc5a55e6" +checksum = "3f8877489a99ccc80012333123e434f84e645fe1ede3b30e9d3b815887a12979" dependencies = [ "derivative", "once_cell", @@ -1266,9 +1285,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -1284,9 +1303,9 @@ dependencies = [ [[package]] name = "pyproject-toml" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b80f889b6d413c3f8963a2c7db03f95dd6e1d85e1074137cb2013ea2faa8898" +checksum = "ef7061023bcb58a0fc4a4bbe9819c13b0dca7c2abc14da14f5ecc1532ab3a36a" dependencies = [ "indexmap 2.2.6", "pep440_rs", @@ -1403,14 +1422,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.4", - "regex-syntax 0.8.2", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", ] [[package]] @@ -1424,13 +1443,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.5", ] [[package]] @@ -1441,9 +1460,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rfc2047-decoder" @@ -1482,6 +1501,12 @@ dependencies = [ "semver", ] +[[package]] +name = "rustflags" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7fc92159fb50a431c5da366f7627751fe7263cf867f8a30f27fa6063ba02ac0" + [[package]] name = "rustix" version = "0.38.30" @@ -1574,7 +1599,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] @@ -1588,22 +1613,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] @@ -1731,9 +1756,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -1753,9 +1778,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" @@ -1802,22 +1827,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] @@ -1925,7 +1950,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] @@ -2035,9 +2060,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" @@ -2423,7 +2448,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.87", ] [[package]] diff --git a/tests/requirements.txt b/tests/requirements.txt index 3345486..4483a2c 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,9 +1,9 @@ -e .. uv -maturin==1.6.0 +maturin==1.7.4 pytest junit2html -uniffi-bindgen==0.27.0 +uniffi-bindgen==0.28.0 cffi # required for pyo3-mixed diff --git a/tests/resolved.json b/tests/resolved.json index c490138..d009a4e 100644 --- a/tests/resolved.json +++ b/tests/resolved.json @@ -1,5 +1,5 @@ { - "commit": "894231c644c2d7a9a31349c86b3f3c431b74d615", + "commit": "aebadedec43a92a1ba0fe94980c84f37122aa5b3", "crates": { "cffi-mixed": { "cargo_manifest_path": "Cargo.toml", diff --git a/tests/test_import_hook/common.py b/tests/test_import_hook/common.py index ac4f492..127d9a5 100644 --- a/tests/test_import_hook/common.py +++ b/tests/test_import_hook/common.py @@ -87,9 +87,9 @@ def resolved_packages() -> dict[str, Optional[ResolvedPackage]]: assert git_path is not None cmd = [git_path, "rev-parse", "HEAD"] current_commit_hash = subprocess.check_output(cmd, cwd=MATURIN_DIR).decode().strip() - assert ( - current_commit_hash == commit_hash - ), "the maturin submodule is not in sync with resolved.json. See package_resolver/README.md for details" + assert current_commit_hash == commit_hash, ( + "the maturin submodule is not in sync with resolved.json. See package_resolver/README.md for details" + ) _RESOLVED_PACKAGES = { crate_name: None if crate_data is None else ResolvedPackage.from_dict(crate_data) diff --git a/tests/test_import_hook/conftest.py b/tests/test_import_hook/conftest.py index 8747c0e..254b434 100644 --- a/tests/test_import_hook/conftest.py +++ b/tests/test_import_hook/conftest.py @@ -5,6 +5,7 @@ from pathlib import Path import pytest + from maturin_import_hook import reset_logger from maturin_import_hook._building import get_default_build_dir @@ -19,7 +20,7 @@ log.info("running tests with %s", sys.executable) -@pytest.fixture() +@pytest.fixture def workspace(tmp_path: Path) -> Iterator[Path]: try: yield tmp_path diff --git a/tests/test_import_hook/project_importer_helpers/logging_reload_helper.py b/tests/test_import_hook/project_importer_helpers/logging_reload_helper.py index 052a6cf..3534df8 100644 --- a/tests/test_import_hook/project_importer_helpers/logging_reload_helper.py +++ b/tests/test_import_hook/project_importer_helpers/logging_reload_helper.py @@ -1,8 +1,9 @@ import importlib -import maturin_import_hook import test_project # type: ignore[missing-import] +import maturin_import_hook + maturin_import_hook.install() # install after importing so that the first reload triggers a build print("reload start", flush=True) diff --git a/tests/test_import_hook/test_project_importer.py b/tests/test_import_hook/test_project_importer.py index 9e4dd64..981b10f 100644 --- a/tests/test_import_hook/test_project_importer.py +++ b/tests/test_import_hook/test_project_importer.py @@ -13,6 +13,7 @@ from typing import Optional import pytest + from maturin_import_hook.project_importer import DefaultProjectFileSearcher, _load_dist_info from .common import ( @@ -462,14 +463,14 @@ def test_rebuild_on_change_to_path_dependency(workspace: Path) -> None: """), ) - output1, duration1 = run_python_code(check_installed) + output1, _duration1 = run_python_code(check_installed) assert "21 is half 42: True" in output1 assert "21 is half 63: False" in output1 transitive_dep_lib = transitive_dep_dir / "src/lib.rs" transitive_dep_lib.write_text(transitive_dep_lib.read_text().replace("x + y == sum", "x + x + y == sum")) - output2, duration2 = run_python_code(check_installed) + output2, _duration2 = run_python_code(check_installed) assert "21 is half 42: False" in output2 assert "21 is half 63: True" in output2 @@ -1079,12 +1080,7 @@ def test_default_rebuild(self, workspace: Path, is_mixed: bool) -> None: self._create_clean_project(workspace, is_mixed) output, _ = run_python_code(self._logging_helper()) - pattern = ( - 'building "test_project"\n' - 'rebuilt and loaded package "test_project" in [0-9.]+s\n' - "value 10\n" - "SUCCESS\n" - ) + pattern = 'building "test_project"\nrebuilt and loaded package "test_project" in [0-9.]+s\nvalue 10\nSUCCESS\n' check_match(output, pattern, flags=re.MULTILINE) @pytest.mark.parametrize("is_mixed", [False, True]) diff --git a/tests/test_import_hook/test_rust_file_importer.py b/tests/test_import_hook/test_rust_file_importer.py index b734ee5..3852278 100644 --- a/tests/test_import_hook/test_rust_file_importer.py +++ b/tests/test_import_hook/test_rust_file_importer.py @@ -614,7 +614,7 @@ def _create_clean_package(self, package_path: Path, *, reload_helper: bool = Fal return rs_path, py_path def test_maturin_detection(self, workspace: Path) -> None: - rs_path, py_path = self._create_clean_package(workspace / "package") + _rs_path, py_path = self._create_clean_package(workspace / "package") env = os.environ.copy() env["PATH"] = remove_executable_from_path(env["PATH"], "maturin") @@ -639,7 +639,7 @@ def test_default_rebuild(self, workspace: Path) -> None: """By default, when a module is out of date the import hook logs messages before and after rebuilding but hides the underlying details. """ - rs_path, py_path = self._create_clean_package(workspace / "package") + _rs_path, py_path = self._create_clean_package(workspace / "package") output, _ = run_python([str(py_path)], workspace) pattern = 'building "my_script"\nrebuilt and loaded module "my_script" in [0-9.]+s\nget_num 10\nSUCCESS\n' @@ -647,7 +647,7 @@ def test_default_rebuild(self, workspace: Path) -> None: def test_default_up_to_date(self, workspace: Path) -> None: """By default, when the module is up-to-date nothing is printed.""" - rs_path, py_path = self._create_clean_package(workspace / "package") + _rs_path, py_path = self._create_clean_package(workspace / "package") run_python([str(py_path)], workspace) # run once to rebuild @@ -709,7 +709,7 @@ def test_default_compile_warning(self, workspace: Path) -> None: @pytest.mark.skipif(not RELOAD_SUPPORTED, reason="reload not supported") def test_reload(self, workspace: Path) -> None: - rs_path, py_path = self._create_clean_package(workspace / "package", reload_helper=True) + _rs_path, py_path = self._create_clean_package(workspace / "package", reload_helper=True) output1, _ = run_python([str(py_path)], workspace) output1 = remove_ansii_escape_characters(output1) @@ -733,7 +733,7 @@ def test_reset_logger_without_configuring(self, workspace: Path) -> None: """If reset_logger is called then by default logging level INFO is not printed (because the messages are handled by the root logger). """ - rs_path, py_path = self._create_clean_package(workspace / "package") + _rs_path, py_path = self._create_clean_package(workspace / "package") output, _ = run_python([str(py_path), "RESET_LOGGER"], workspace) assert output == "get_num 10\nSUCCESS\n" diff --git a/tests/test_import_hook/test_site.py b/tests/test_import_hook/test_site.py index bc8a915..7e29a12 100644 --- a/tests/test_import_hook/test_site.py +++ b/tests/test_import_hook/test_site.py @@ -2,6 +2,7 @@ from textwrap import dedent import pytest + from maturin_import_hook._site import ( has_automatic_installation, insert_automatic_installation, diff --git a/tests/test_import_hook/test_utilities.py b/tests/test_import_hook/test_utilities.py index 0bf9347..1ca03a6 100644 --- a/tests/test_import_hook/test_utilities.py +++ b/tests/test_import_hook/test_utilities.py @@ -9,6 +9,7 @@ from typing import cast import pytest + from maturin_import_hook._building import BuildCache, BuildStatus, Freshness, get_installation_freshness from maturin_import_hook._resolve_project import _ProjectResolveError, _resolve_project, _TomlFile from maturin_import_hook.error import ImportHookError @@ -221,8 +222,7 @@ def test_read_error(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> No assert freshness == Freshness(False, "failed to read installed files", None, None) expected_error = re.escape( - "error reading source file mtimes: " - f"PermissionError(13, 'Permission denied') ({unreadable_dir / 'source'})" + f"error reading source file mtimes: PermissionError(13, 'Permission denied') ({unreadable_dir / 'source'})" ) with pytest.raises(ImportHookError, match=expected_error): get_installation_freshness([unreadable_dir / "source"], [readable_dir / "install"], readable_status)