Skip to content

Commit 8d897bb

Browse files
committed
lint: migrate formatter from black to ruff format
1 parent d72bc71 commit 8d897bb

File tree

6 files changed

+10
-26
lines changed

6 files changed

+10
-26
lines changed

.pre-commit-config.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ repos:
2929
hooks:
3030
- id: ruff
3131
args: [--fix, --exit-non-zero-on-fix]
32-
- repo: https://github.com/psf/black
33-
rev: 24.10.0
34-
hooks:
35-
- id: black
32+
- id: ruff-format
3633
- repo: https://github.com/asottile/pyupgrade
3734
rev: v3.19.1
3835
hooks:
@@ -53,7 +50,7 @@ repos:
5350
^docs/source/conf.py$
5451
)
5552
- repo: https://github.com/codespell-project/codespell
56-
rev: v2.4.0
53+
rev: v2.4.1
5754
hooks:
5855
- id: codespell
5956
additional_dependencies: [".[toml]"]

nvitop-exporter/pyproject.toml

-6
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,5 @@ Documentation = "https://nvitop.readthedocs.io"
6565
[tool.setuptools.packages.find]
6666
include = ["nvitop_exporter", "nvitop_exporter.*"]
6767

68-
[tool.black]
69-
safe = true
70-
line-length = 100
71-
skip-string-normalization = true
72-
target-version = ["py37"]
73-
7468
[tool.ruff]
7569
extend = "../pyproject.toml"

nvitop/api/process.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ def command_join(cmdline: list[str]) -> str:
9595
"""Return a shell-escaped string from command line arguments."""
9696
if len(cmdline) == 1 and not (
9797
# May be modified by `setproctitle`
98-
os.path.isfile(cmdline[0])
99-
and os.path.isabs(cmdline[0])
98+
os.path.isfile(cmdline[0]) and os.path.isabs(cmdline[0])
10099
):
101100
return cmdline[0]
102101
return ' '.join(map(add_quotes, cmdline))

nvitop/tui/library/selection.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,8 @@ def send_signal(self, sig):
121121

122122
def interrupt(self):
123123
try:
124-
self.send_signal(
125-
(
126-
signal.SIGINT
127-
if not host.WINDOWS
128-
else signal.CTRL_C_EVENT # pylint: disable=no-member
129-
),
130-
)
124+
# pylint: disable-next=no-member
125+
self.send_signal(signal.SIGINT if not host.WINDOWS else signal.CTRL_C_EVENT)
131126
except SystemError:
132127
pass
133128

pyproject.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ Documentation = "https://nvitop.readthedocs.io"
6767
[tool.setuptools.packages.find]
6868
include = ["nvitop", "nvitop.*"]
6969

70-
[tool.black]
71-
line-length = 100
72-
skip-string-normalization = true
73-
target-version = ["py37"]
74-
7570
[tool.mypy]
7671
# Sync with requires-python
7772
python_version = "3.8" # appease mypy for syntax errors in numpy stubs
@@ -118,6 +113,10 @@ line-length = 100
118113
output-format = "full"
119114
src = ["nvitop", "nvitop-exporter/nvitop_exporter"]
120115

116+
[tool.ruff.format]
117+
quote-style = "single"
118+
docstring-code-format = false
119+
121120
[tool.ruff.lint]
122121
select = [
123122
"E", "W", # pycodestyle

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def vcs_version(name: str, path: Path | str) -> Generator[ModuleType]:
7272

7373
extra_requirements = {
7474
'lint': [
75-
'black >= 24.0.0, < 25.0.0a0',
75+
'ruff',
7676
'pylint[spelling]',
7777
'mypy',
7878
'typing-extensions',

0 commit comments

Comments
 (0)