Skip to content

Commit

Permalink
chore(lint): update ruff rules
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Aug 14, 2024
1 parent 041aea1 commit 4fa35c4
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 26 deletions.
7 changes: 0 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py38-plus]
exclude: ^(src/pdm/models/in_process/.*\.py|install-pdm\.py)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.5.6'
hooks:
Expand Down
2 changes: 1 addition & 1 deletion install-pdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tempfile import TemporaryDirectory
from typing import Sequence

if sys.version_info < (3, 8):
if sys.version_info < (3, 8): # noqa: UP036
sys.exit("Python 3.8 or above is required to install PDM.")

_plat = platform.system()
Expand Down
2 changes: 1 addition & 1 deletion install-pdm.py.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e1c7f6455fa7ffc50cbc13e4d49c06dfaaf8e9b74d0c9b46287bf767f6a4e4fc install-pdm.py
cdaae475a16ae781e06c7211c7b075df1b508470b0dc144bbb73acf9a8389f91 install-pdm.py
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ extend-select = [
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FA", # flake8-future-annotations
"PGH", # pygrep-hooks
"RUF", # ruff
"W", # pycodestyle
"UP", # pyupgrade
"YTT", # flake8-2020
]
extend-ignore = ["B018", "B019", "RUF018"]
Expand Down
6 changes: 3 additions & 3 deletions src/pdm/cli/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def print_results(
if normalize_name(name) in working_set:
dist = working_set[normalize_name(name)]
if dist.version == latest:
ui.echo(" INSTALLED: %s (latest)" % dist.version)
ui.echo(f" INSTALLED: {dist.version} (latest)")
else:
ui.echo(" INSTALLED: %s" % dist.version)
ui.echo(" LATEST: %s" % latest)
ui.echo(f" INSTALLED: {dist.version}")
ui.echo(f" LATEST: {latest}")
except UnicodeEncodeError:
pass

Expand Down
2 changes: 1 addition & 1 deletion src/pdm/models/in_process/sysconfig_get_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_paths(kind="default", vars=None):
if kind == "user" and not running_under_virtualenv():
scheme = _get_user_scheme()
if scheme not in scheme_names:
raise ValueError("{} is not a valid scheme on the system, or user site may be disabled.".format(scheme))
raise ValueError(f"{scheme} is not a valid scheme on the system, or user site may be disabled.")
return sysconfig.get_paths(scheme, vars=vars)
else:
if sys.platform == "darwin" and "osx_framework_library" in scheme_names and kind == "prefix":
Expand Down
8 changes: 1 addition & 7 deletions src/pdm/models/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,7 @@ def _transport_for(self, source: RepositoryConfig) -> httpx.BaseTransport:
def _make_user_agent(self) -> str:
import platform

return "pdm/{} {}/{} {}/{}".format(
__version__,
platform.python_implementation(),
platform.python_version(),
platform.system(),
platform.release(),
)
return f"pdm/{__version__} {platform.python_implementation()}/{platform.python_version()} {platform.system()}/{platform.release()}"

def on_response(self, response: httpx.Response) -> None:
from unearth.utils import ARCHIVE_EXTENSIONS
Expand Down
4 changes: 2 additions & 2 deletions src/pdm/pep582/sitecustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def patch_sysconfig(libpath):
"purelib": "{pep582_base}/lib",
"platlib": "{pep582_base}/lib",
"include": "{pep582_base}/include",
"scripts": "{pep582_base}/%s" % bin_prefix,
"scripts": f"{{pep582_base}}/{bin_prefix}",
"data": "{pep582_base}",
"prefix": "{pep582_base}",
"headers": "{pep582_base}/include",
Expand Down Expand Up @@ -110,7 +110,7 @@ def main():
self_path = os.path.normcase(os.path.dirname(os.path.abspath(__file__)))
sys.path[:] = [path for path in sys.path if os.path.normcase(path) != self_path]

if sys.version_info[0] == 2:
if sys.version_info[0] == 2: # noqa: UP036
load_next_sitecustomize_py2()
else:
load_next_sitecustomize_py3()
Expand Down
2 changes: 1 addition & 1 deletion src/pdm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def pdm_scheme(base: str) -> dict[str, str]:
"purelib": "{pep582_base}/lib",
"platlib": "{pep582_base}/lib",
"include": "{pep582_base}/include",
"scripts": "{pep582_base}/%s" % bin_prefix,
"scripts": f"{{pep582_base}}/{bin_prefix}",
"data": "{pep582_base}",
"prefix": "{pep582_base}",
"headers": "{pep582_base}/include",
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/test_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def test_use_python_by_version(project, pdm):

@pytest.mark.skipif(os.name != "posix", reason="Run on POSIX platforms only")
def test_use_wrapper_python(project):
wrapper_script = """#!/bin/bash
exec "{}" "$@"
""".format(sys.executable)
wrapper_script = f"""#!/bin/bash
exec "{sys.executable}" "$@"
"""
shim_path = project.root.joinpath("python_shim.sh")
shim_path.write_text(wrapper_script)
shim_path.chmod(0o755)
Expand Down

0 comments on commit 4fa35c4

Please sign in to comment.