Skip to content

Commit c248a76

Browse files
authored
chore: cleanup Ruff a bit (#783)
1 parent 1fe4437 commit c248a76

9 files changed

+26
-28
lines changed

docs/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import os
1717
import sys
1818

19-
try:
20-
import importlib.metadata as metadata
21-
except ImportError:
19+
if sys.version_info >= (3, 8):
20+
from importlib import metadata
21+
else:
2222
import importlib_metadata as metadata
2323

2424
# If extensions (or modules to document with autodoc) are in another directory,

nox/_option_set.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import argparse
2222
import collections
2323
import functools
24-
from argparse import ArgumentError as ArgumentError
24+
from argparse import ArgumentError as ArgumentError # noqa: PLC0414
2525
from argparse import ArgumentParser, Namespace
2626
from collections.abc import Callable, Iterable
2727
from typing import Any

nox/_options.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,8 @@ def _force_venv_backend_merge_func(
128128
raise ValueError(
129129
"You can not use `--no-venv` with a non-none `--force-venv-backend`"
130130
)
131-
else:
132-
return "none"
133-
else:
134-
return command_args.force_venv_backend or noxfile_args.force_venv_backend # type: ignore[no-any-return]
131+
return "none"
132+
return command_args.force_venv_backend or noxfile_args.force_venv_backend # type: ignore[no-any-return]
135133

136134

137135
def _envdir_merge_func(

nox/_parametrize.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def update_param_specs(
168168
combined_specs = []
169169
for new_spec in new_specs:
170170
for spec in param_specs:
171-
spec = spec.copy()
172-
spec.update(new_spec)
173-
combined_specs.append(spec)
171+
spec_copy = spec.copy()
172+
spec_copy.update(new_spec)
173+
combined_specs.append(spec_copy)
174174
return combined_specs

nox/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from packaging.version import InvalidVersion, Version
2323

2424
if sys.version_info >= (3, 8):
25-
import importlib.metadata as metadata
25+
from importlib import metadata
2626
else:
2727
import importlib_metadata as metadata
2828

nox/logger.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ def _get_format(colorlog: bool, add_timestamp: bool) -> str:
2727
if colorlog:
2828
if add_timestamp:
2929
return "%(cyan)s%(name)s > [%(asctime)s] %(log_color)s%(message)s"
30-
else:
31-
return "%(cyan)s%(name)s > %(log_color)s%(message)s"
32-
else:
33-
if add_timestamp:
34-
return "%(name)s > [%(asctime)s] %(message)s"
35-
else:
36-
return "%(name)s > %(message)s"
30+
return "%(cyan)s%(name)s > %(log_color)s%(message)s"
31+
32+
if add_timestamp:
33+
return "%(name)s > [%(asctime)s] %(message)s"
34+
35+
return "%(name)s > %(message)s"
3736

3837

3938
class NoxFormatter(logging.Formatter):

nox/sessions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def conda_install(
562562
raise ValueError("At least one argument required to install().")
563563

564564
if self._runner.global_config.no_install and venv._reused:
565-
return None
565+
return
566566

567567
# Escape args that should be (conda-specific; pip install does not need this)
568568
args = _dblquote_pkg_install_args(args)
@@ -645,7 +645,7 @@ def install(self, *args: str, **kwargs: Any) -> None:
645645
raise ValueError("At least one argument required to install().")
646646

647647
if self._runner.global_config.no_install and venv._reused:
648-
return None
648+
return
649649

650650
if "silent" not in kwargs:
651651
kwargs["silent"] = True

pyproject.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,21 @@ extend-select = [
7474
"C4", # flake8-comprehensions
7575
"ICN", # flake8-import-conventions
7676
"ISC", # flake8-implicit-str-concat
77+
"PL", # pylint
7778
"PGH", # pygrep-hooks
7879
"PIE", # flake8-pie
7980
"RUF", # Ruff-specific
8081
"SIM", # flake8-simplify
8182
"UP", # pyupgrade
8283
"YTT", # flake8-2020
84+
"EXE", # flake8-executable
8385
]
8486
ignore = [
85-
"ISC001", # Conflicts with formatter
87+
"ISC001", # Conflicts with formatter
88+
"PLR09", # Too many X
89+
"PLR2004", # Magic value used in comparison
8690
]
8791

88-
[tool.ruff]
89-
target-version = "py37"
90-
9192
[tool.isort]
9293
profile = "black"
9394

tests/test_main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import nox.registry
2929
import nox.sessions
3030

31-
try:
32-
import importlib.metadata as metadata
33-
except ImportError:
31+
if sys.version_info >= (3, 8):
32+
from importlib import metadata
33+
else:
3434
import importlib_metadata as metadata
3535

3636

0 commit comments

Comments
 (0)