Skip to content

Commit e6ae882

Browse files
Upgrade ruff and rename ruleset: TCHTC (#1626)
* Upgrade ruff to latest release v0.11.8 * Rename ruff ruleset: TCH → TC Ruff 0.8.0 changes the error codes for the rules in the flake8-type-checking category from TCH to TC. This matches changes that were made in the original flake8-type-checking plugin from which these rules were originally adapted. https://astral.sh/blog/ruff-v0.8.0#new-error-codes-for-flake8-type-checking-rules * Apply ruff/flake8-type-checking rules TC006 TC006 Add quotes to type expression in `typing.cast()` * Ignore ruff/Pylint warning PLW1508 PLW1508 Invalid type for environment variable default; expected `str` or `None` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4546189 commit e6ae882

File tree

9 files changed

+17
-16
lines changed

9 files changed

+17
-16
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
hooks:
1212
- id: pyproject-fmt
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.6.9
14+
rev: v0.11.8
1515
hooks:
1616
- id: ruff
1717
args: [ "--fix", "--unsafe-fixes", "--show-fixes", "--exit-non-zero-on-fix"]

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ lint.extend-select = [
7979
"RSE",
8080
"RUF012",
8181
"RUF100",
82-
"TCH",
82+
"TC",
8383
"W",
8484
]
8585
lint.ignore = [
8686
"PERF203",
87+
"PLW1508",
8788
]
8889
lint.isort = { known-first-party = [
8990
"helpers",

scripts/generate_man.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def main():
1414
sys.argv[0] = "pipx"
1515
parser, _ = get_command_parser()
16-
parser.man_short_description = cast(str, parser.description).splitlines()[1] # type: ignore[attr-defined]
16+
parser.man_short_description = cast("str", parser.description).splitlines()[1] # type: ignore[attr-defined]
1717

1818
manpage = Manpage(parser)
1919
body = str(manpage)

src/pipx/commands/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def package_name_from_spec(package_spec: str, python: str, *, pip_args: List[str
379379
# will use the pypi name
380380
package_name = pypi_name
381381
logger.info(f"Determined package name: {package_name}")
382-
logger.info(f"Package name determined in {time.time()-start_time:.1f}s")
382+
logger.info(f"Package name determined in {time.time() - start_time:.1f}s")
383383
return package_name
384384

385385
# check syntax and clean up spec and pip_args
@@ -390,7 +390,7 @@ def package_name_from_spec(package_spec: str, python: str, *, pip_args: List[str
390390
venv.create_venv(venv_args=[], pip_args=[])
391391
package_name = venv.install_package_no_deps(package_or_url=package_spec, pip_args=pip_args)
392392

393-
logger.info(f"Package name determined in {time.time()-start_time:.1f}s")
393+
logger.info(f"Package name determined in {time.time() - start_time:.1f}s")
394394
return package_name
395395

396396

src/pipx/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __init__(self, venv_container: VenvContainer) -> None:
163163
self.packages = [str(p.name) for p in sorted(venv_container.iter_venv_dirs())]
164164

165165
def use(self, prefix: str, **kwargs: Any) -> List[str]:
166-
return [f"{prefix}{x[len(prefix):]}" for x in self.packages if x.startswith(canonicalize_name(prefix))]
166+
return [f"{prefix}{x[len(prefix) :]}" for x in self.packages if x.startswith(canonicalize_name(prefix))]
167167

168168

169169
def get_pip_args(parsed_args: Dict[str, str]) -> List[str]:

src/pipx/pipx_metadata_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _convert_legacy_metadata(self, metadata_dict: Dict[str, Any]) -> Dict[str, A
114114
raise PipxError(
115115
f"""
116116
{self.venv_dir.name}: Unknown metadata version
117-
{metadata_dict['pipx_metadata_version']}. Perhaps it was
117+
{metadata_dict["pipx_metadata_version"]}. Perhaps it was
118118
installed with a later version of pipx.
119119
"""
120120
)

src/pipx/venv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def install_package_no_deps(self, package_or_url: str, pip_args: List[str]) -> s
348348
def get_venv_metadata_for_package(self, package_name: str, package_extras: Set[str]) -> VenvMetadata:
349349
data_start = time.time()
350350
venv_metadata = inspect_venv(package_name, package_extras, self.bin_path, self.python_path, self.man_path)
351-
logger.info(f"get_venv_metadata_for_package: {1e3*(time.time()-data_start):.0f}ms")
351+
logger.info(f"get_venv_metadata_for_package: {1e3 * (time.time() - data_start):.0f}ms")
352352
return venv_metadata
353353

354354
def update_package_metadata(

tests/test_animate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_delay_suppresses_output(capsys, monkeypatch):
6666
@pytest.mark.parametrize(
6767
"env_columns,expected_frame_message",
6868
[
69-
(45, f"{TEST_STRING_40_CHAR:.{45-6}}..."),
69+
(45, f"{TEST_STRING_40_CHAR:.{45 - 6}}..."),
7070
(46, f"{TEST_STRING_40_CHAR}"),
7171
(47, f"{TEST_STRING_40_CHAR}"),
7272
],
@@ -87,7 +87,7 @@ def test_line_lengths_emoji(capsys, monkeypatch, env_columns, expected_frame_mes
8787
@pytest.mark.parametrize(
8888
"env_columns,expected_frame_message",
8989
[
90-
(43, f"{TEST_STRING_40_CHAR:.{43-4}}"),
90+
(43, f"{TEST_STRING_40_CHAR:.{43 - 4}}"),
9191
(44, f"{TEST_STRING_40_CHAR}"),
9292
(45, f"{TEST_STRING_40_CHAR}"),
9393
],

tests/test_install.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,15 @@ def test_passed_python_and_force_flag_warning(pipx_temp_env, capsys):
409409

410410
assert not run_pipx_cli(["install", "black", "--force"])
411411
captured = capsys.readouterr()
412-
assert (
413-
"--python is ignored when --force is passed." not in captured.out
414-
), "Should only print warning if both flags present"
412+
assert "--python is ignored when --force is passed." not in captured.out, (
413+
"Should only print warning if both flags present"
414+
)
415415

416416
assert not run_pipx_cli(["install", "pycowsay", "--force"])
417417
captured = capsys.readouterr()
418-
assert (
419-
"--python is ignored when --force is passed." not in captured.out
420-
), "Should not print warning if package does not exist yet"
418+
assert "--python is ignored when --force is passed." not in captured.out, (
419+
"Should not print warning if package does not exist yet"
420+
)
421421

422422

423423
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)