diff --git a/fawltydeps/extract_declared_dependencies.py b/fawltydeps/extract_declared_dependencies.py index 37a8d636..2702abf0 100644 --- a/fawltydeps/extract_declared_dependencies.py +++ b/fawltydeps/extract_declared_dependencies.py @@ -165,7 +165,7 @@ def parse_value(value: str) -> Iterator[DeclaredDependency]: # See: https://github.com/nexB/pip-requirements-parser/pull/17 # https://github.com/nexB/pip-requirements-parser/pull/19#discussion_r1379279880 - temp_file = NamedTemporaryFile( + temp_file = NamedTemporaryFile( # noqa: SIM115 "wt", delete=False, # we prefer utf8 encoded strings, but ... diff --git a/fawltydeps/packages.py b/fawltydeps/packages.py index d9efc63b..d30b2a85 100644 --- a/fawltydeps/packages.py +++ b/fawltydeps/packages.py @@ -412,8 +412,8 @@ def _venv_create(venv_dir: Path, uv_exe: Optional[str] = None) -> None: if uv_exe is None: # use venv module venv.create(venv_dir, clear=True, with_pip=True) else: - subprocess.run( - [uv_exe, "venv", "--python", sys.executable, str(venv_dir)], # noqa: S603 + subprocess.run( # noqa: S603 + [uv_exe, "venv", "--python", sys.executable, str(venv_dir)], check=True, ) @@ -474,8 +474,8 @@ def install_helper(*packages: str) -> int: Return the subprocess exit code from the install process. """ argv = cls._venv_install_cmd(venv_dir, uv_exe) + list(packages) - proc = subprocess.run( - argv, # noqa: S603 + proc = subprocess.run( # noqa: S603 + argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, diff --git a/tests/conftest.py b/tests/conftest.py index 18f7bbf5..370d9d0b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,7 +14,7 @@ from .project_helpers import TarballPackage -@pytest.fixture() +@pytest.fixture def inside_tmp_path(monkeypatch, tmp_path): """Convenience fixture to run a test with CWD set to tmp_path. @@ -26,8 +26,8 @@ def inside_tmp_path(monkeypatch, tmp_path): return tmp_path -@pytest.fixture() -def local_pypi(request, monkeypatch): # noqa: PT004 +@pytest.fixture +def local_pypi(request, monkeypatch): cache_dir = TarballPackage.cache_dir(request.config.cache) TarballPackage.get_tarballs(request.config.cache) # Make sure we install from the local repo, and not from PyPI. @@ -35,7 +35,7 @@ def local_pypi(request, monkeypatch): # noqa: PT004 # uv does not (yet) allow this to be configured via the environment, so we # need to go via a temporary config file: - tmp_uv_config = NamedTemporaryFile("wt", delete=False, suffix=".toml") + tmp_uv_config = NamedTemporaryFile("wt", delete=False, suffix=".toml") # noqa: SIM115 try: tmp_uv_config.write( dedent(f""" @@ -58,7 +58,7 @@ def local_pypi(request, monkeypatch): # noqa: PT004 Path(tmp_uv_config.name).unlink() -@pytest.fixture() +@pytest.fixture def write_tmp_files(tmp_path: Path): def _inner(file_contents: Dict[str, Union[str, bytes]]) -> Path: for filename, contents in file_contents.items(): @@ -74,7 +74,7 @@ def _inner(file_contents: Dict[str, Union[str, bytes]]) -> Path: return _inner -@pytest.fixture() +@pytest.fixture def fake_venv(tmp_path): def create_one_fake_venv( fake_packages: Dict[str, Set[str]], *, venv_dir: Optional[Path] = None @@ -105,7 +105,7 @@ def create_one_fake_venv( return create_one_fake_venv -@pytest.fixture() +@pytest.fixture def isolate_default_resolver( fake_venv: Callable[[Dict[str, Set[str]]], Tuple[Path, Path]], monkeypatch ): @@ -139,7 +139,7 @@ def inner(fake_packages: Dict[str, Set[str]]) -> Path: return inner -@pytest.fixture() +@pytest.fixture def fake_project(write_tmp_files, fake_venv): # noqa: C901 """Create a temporary Python project with the given contents/properties. @@ -226,9 +226,9 @@ def format_pixi_toml(deps: Deps, extras: ExtraDeps) -> str: [dependencies] """ ) + "\n".join(f'{dep} = "*"' for dep in deps) - for feature, deps in extras.items(): + for feature, extra_deps in extras.items(): ret += f"\n[feature.{feature}.dependencies]\n" - ret += "\n".join(f'{dep} = "*"' for dep in deps) + ret += "\n".join(f'{dep} = "*"' for dep in extra_deps) return ret def format_deps( @@ -281,7 +281,7 @@ def create_one_fake_project( return create_one_fake_project -@pytest.fixture() +@pytest.fixture def project_with_setup_and_requirements(fake_project): return fake_project( files_with_declared_deps={ @@ -296,7 +296,7 @@ def project_with_setup_and_requirements(fake_project): ) -@pytest.fixture() +@pytest.fixture def project_with_setup_with_cfg_pyproject_and_requirements(fake_project): return fake_project( files_with_declared_deps={ @@ -321,7 +321,7 @@ def project_with_setup_with_cfg_pyproject_and_requirements(fake_project): ) -@pytest.fixture() +@pytest.fixture def project_with_multiple_python_files(fake_project): return fake_project( declared_deps=["pandas", "click"], @@ -334,7 +334,7 @@ def project_with_multiple_python_files(fake_project): ) -@pytest.fixture() +@pytest.fixture def setup_fawltydeps_config(write_tmp_files): """Write a custom tmp_path/pyproject.toml with a [tool.fawltydeps] section. diff --git a/tests/test_extract_imports_simple.py b/tests/test_extract_imports_simple.py index b643c4db..d66a6819 100644 --- a/tests/test_extract_imports_simple.py +++ b/tests/test_extract_imports_simple.py @@ -76,7 +76,7 @@ def cell_template(cell_type: str, source: List[str]): return json.dumps(notebook, indent=2) -@pytest.fixture() +@pytest.fixture def write_code_sources(write_tmp_files): """A wrapper around write_tmp_files() that return CodeSource objects.""" diff --git a/tests/test_settings.py b/tests/test_settings.py index d6730959..a4aa1767 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -76,7 +76,7 @@ def make_settings_dict(**kwargs): return ret -@pytest.fixture() +@pytest.fixture def setup_env(monkeypatch): """Allow setup of fawltydeps_* env vars in a test case.""" diff --git a/tests/test_traverse_project.py b/tests/test_traverse_project.py index b28f330a..4fef5ea5 100644 --- a/tests/test_traverse_project.py +++ b/tests/test_traverse_project.py @@ -43,7 +43,7 @@ class TraverseProjectVector: # These are the exceptions we expect to be raised, or warnings to be logged expect_raised: Optional[Type[Exception]] = None expect_warnings: List[str] = dataclasses.field(default_factory=list) - skip_me: Callable[[], Optional[str]] = lambda: None # noqa: E731 + skip_me: Callable[[], Optional[str]] = lambda: None def on_windows(msg: str) -> Callable[[], Optional[str]]: