From 5cc7ba2f4a1e082bfa13a27fec5f7225a83e9e84 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 10:17:44 -0700 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#365) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- pyproject.toml | 27 ++++++++++++++++++++++----- src/pipdeptree/_adapter.py | 3 ++- tests/_models/test_package.py | 3 ++- tests/conftest.py | 3 ++- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 48555f4..c933161 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,12 +15,12 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.8.0" + rev: "2.0.3" hooks: - id: pyproject-fmt additional_dependencies: ["tox>=4.12.1"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.4.3" + rev: "v0.4.4" hooks: - id: ruff-format - id: ruff diff --git a/pyproject.toml b/pyproject.toml index e19e570..17e12d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,8 +69,14 @@ version.source = "vcs" [tool.ruff] line-length = 120 target-version = "py38" -lint.isort = { known-first-party = ["pipdeptree"], required-imports = ["from __future__ import annotations"] } -lint.select = ["ALL"] +lint.isort = { known-first-party = [ + "pipdeptree", +], required-imports = [ + "from __future__ import annotations", +] } +lint.select = [ + "ALL", +] lint.ignore = [ "S101", # asserts allowed "INP001", # no implicit namespace @@ -109,13 +115,24 @@ ignore-words-list = "master" [tool.coverage] html.show_contexts = true html.skip_covered = false -paths.source = ["src", ".tox/*/lib/python*/site-packages", "*/src"] +paths.source = [ + "src", + ".tox/*/lib/python*/site-packages", + "*/src", +] run.parallel = true -run.plugins = ["covdefaults"] +run.plugins = [ + "covdefaults", +] report.fail_under = 88 subtract_omit = "*/__main__.py" [tool.mypy] show_error_codes = true strict = true -overrides = [{ module = ["graphviz.*", "virtualenv.*"], ignore_missing_imports = true }] +overrides = [ + { module = [ + "graphviz.*", + "virtualenv.*", + ], ignore_missing_imports = true }, +] diff --git a/src/pipdeptree/_adapter.py b/src/pipdeptree/_adapter.py index 9db084b..6117724 100644 --- a/src/pipdeptree/_adapter.py +++ b/src/pipdeptree/_adapter.py @@ -1,5 +1,6 @@ from __future__ import annotations +import locale from json import JSONDecodeError from pathlib import Path from typing import TYPE_CHECKING @@ -70,6 +71,6 @@ def editable_project_location(self) -> str | None: result = None egg_link_path = egg_link_path_from_sys_path(self.raw_name) if egg_link_path: - with Path(egg_link_path).open("r") as f: + with Path(egg_link_path).open("r", encoding=locale.getpreferredencoding(False)) as f: result = f.readline().rstrip() return result diff --git a/tests/_models/test_package.py b/tests/_models/test_package.py index 273b92c..6a62d4c 100644 --- a/tests/_models/test_package.py +++ b/tests/_models/test_package.py @@ -1,5 +1,6 @@ from __future__ import annotations +import locale import sys from importlib.metadata import PackageNotFoundError from pathlib import Path @@ -29,7 +30,7 @@ def test_guess_version_setuptools(mocker: MockerFixture) -> None: def test_package_as_frozen_repr(tmp_path: Path, mocker: MockerFixture) -> None: file_path = tmp_path / "foo.egg-link" - with Path(file_path).open("w") as f: + with Path(file_path).open("w", encoding=locale.getpreferredencoding(False)) as f: f.write("/A/B/foo") mock_path = sys.path.copy() mock_path.append(str(tmp_path)) diff --git a/tests/conftest.py b/tests/conftest.py index 555d60a..b04e539 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ from __future__ import annotations +import locale from pathlib import Path from random import shuffle from typing import TYPE_CHECKING, Callable, Iterator @@ -75,7 +76,7 @@ def fake_dist(tmp_path: Path) -> Path: fake_dist_path = fake_site_pkgs / "bar-2.4.5.dist-info" fake_dist_path.mkdir(parents=True) fake_metadata = Path(fake_dist_path) / "METADATA" - with Path(fake_metadata).open("w") as f: + with Path(fake_metadata).open("w", encoding=locale.getpreferredencoding(False)) as f: f.write("Metadata-Version: 2.3\n" "Name: bar\n" "Version: 2.4.5\n") return fake_dist_path