Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use ruff-format replace black #2356

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.292'
rev: 'v0.1.3'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]

- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- id: ruff-format

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
Expand Down
5 changes: 3 additions & 2 deletions install-pdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def _add_to_path(target: Path) -> None:
winreg.SetValueEx(env_key, "PATH", 0, type_, new_value)

_echo(
"Post-install: {} is added to PATH env, please restart your terminal "
"to take effect".format(colored("green", value))
"Post-install: {} is added to PATH env, please restart your terminal " "to take effect".format(
vvanglro marked this conversation as resolved.
Show resolved Hide resolved
colored("green", value)
)
)
else:
paths = [os.path.normcase(p) for p in os.getenv("PATH", "").split(os.pathsep)]
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ workflow = [
"pycomplete~=0.3"
]

[tool.black]
line-length = 120
target-version = ["py37", "py38", "py39", "py310"]

[tool.ruff]
line-length = 120
extend-select = [
Expand Down
3 changes: 1 addition & 2 deletions src/pdm/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@


if (
sys.version_info >= (3, 9)
and not (sys.version_info[:2] == (3, 9) and sys.platform == "win32")
sys.version_info >= (3, 9) and not (sys.version_info[:2] == (3, 9) and sys.platform == "win32")
# a bug on windows+py39 that zipfile path is not normalized
):

Expand Down
3 changes: 2 additions & 1 deletion src/pdm/formats/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def _convert_req(name: str, req_dict: RequirementDict | list[RequirementDict]) -
req_dict["marker"] = str(functools.reduce(operator.and_, markers)).replace('"', "'")
if "rev" in req_dict or "branch" in req_dict or "tag" in req_dict:
req_dict["ref"] = req_dict.pop(
"rev", req_dict.pop("tag", req_dict.pop("branch", None)) # type: ignore[arg-type]
"rev",
req_dict.pop("tag", req_dict.pop("branch", None)), # type: ignore[arg-type]
)
yield Requirement.from_req_dict(name, req_dict).as_line()

Expand Down
4 changes: 3 additions & 1 deletion src/pdm/models/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ def get_dependencies_from_metadata(self) -> list[str]:
"""Get the dependencies of a candidate from metadata."""
extras = self.req.extras or ()
return filter_requirements_with_extras(
self.req.project_name, self.metadata.requires or [], extras # type: ignore[arg-type]
self.req.project_name, # type: ignore[arg-type]
self.metadata.requires or [],
extras,
)

def should_cache(self) -> bool:
Expand Down
8 changes: 4 additions & 4 deletions src/pdm/models/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def python_specifier(spec: str | PySpecSet) -> str:
if not applicable_cans and allow_prereleases is None:
# No non-pre-releases is found, force pre-releases now
applicable_cans = LazySequence(
c for c in cans if requirement.specifier.contains(c.version, True) # type: ignore[arg-type, union-attr]
c
for c in cans
if requirement.specifier.contains(c.version, True) # type: ignore[arg-type, union-attr]
)
applicable_cans_python_compatible = LazySequence(filter_candidates_with_requires_python(applicable_cans))
if applicable_cans_python_compatible:
Expand Down Expand Up @@ -342,9 +344,7 @@ def get_hashes(self, candidate: Candidate) -> list[FileHash]:
of a given package version.
"""
if (
candidate.req.is_vcs
or candidate.req.is_file_or_url
and candidate.req.is_local_dir # type: ignore[attr-defined]
candidate.req.is_vcs or candidate.req.is_file_or_url and candidate.req.is_local_dir # type: ignore[attr-defined]
):
return []
if candidate.hashes:
Expand Down
4 changes: 1 addition & 3 deletions tests/cli/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def test_sync_with_index_change(project, index, pdm):
project.pyproject.metadata["requires-python"] = ">=3.6"
project.pyproject.metadata["dependencies"] = ["future-fstrings"]
project.pyproject.write()
index[
"/simple/future-fstrings/"
] = b"""
index["/simple/future-fstrings/"] = b"""
<html>
<body>
<h1>future-fstrings</h1>
Expand Down
4 changes: 1 addition & 3 deletions tests/cli/test_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def test_use_python_by_version(project, pdm):
def test_use_wrapper_python(project):
wrapper_script = """#!/bin/bash
exec "{}" "$@"
""".format(
sys.executable
)
""".format(sys.executable)
shim_path = project.root.joinpath("python_shim.sh")
shim_path.write_text(wrapper_script)
shim_path.chmod(0o755)
Expand Down
Loading