Skip to content

Commit

Permalink
Apply simple Ruff fixes after upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
jherland committed Oct 23, 2024
1 parent 3146b0d commit 13f74de
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion fawltydeps/extract_declared_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down
8 changes: 4 additions & 4 deletions fawltydeps/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -26,16 +26,16 @@ 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.
# This goes for both the uv and pip install methods.

# 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"""
Expand All @@ -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():
Expand All @@ -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
Expand Down Expand Up @@ -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
):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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={
Expand All @@ -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={
Expand All @@ -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"],
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_extract_imports_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
2 changes: 1 addition & 1 deletion tests/test_traverse_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down

0 comments on commit 13f74de

Please sign in to comment.