Skip to content

Commit

Permalink
lint: migrate formatter from black to ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Jan 29, 2025
1 parent d72bc71 commit 3504c1c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
5 changes: 1 addition & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
Expand Down
6 changes: 0 additions & 6 deletions nvitop-exporter/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,5 @@ Documentation = "https://nvitop.readthedocs.io"
[tool.setuptools.packages.find]
include = ["nvitop_exporter", "nvitop_exporter.*"]

[tool.black]
safe = true
line-length = 100
skip-string-normalization = true
target-version = ["py37"]

[tool.ruff]
extend = "../pyproject.toml"
3 changes: 1 addition & 2 deletions nvitop/api/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def command_join(cmdline: list[str]) -> str:
"""Return a shell-escaped string from command line arguments."""
if len(cmdline) == 1 and not (
# May be modified by `setproctitle`
os.path.isfile(cmdline[0])
and os.path.isabs(cmdline[0])
os.path.isfile(cmdline[0]) and os.path.isabs(cmdline[0])
):
return cmdline[0]
return ' '.join(map(add_quotes, cmdline))
Expand Down
9 changes: 2 additions & 7 deletions nvitop/tui/library/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,8 @@ def send_signal(self, sig):

def interrupt(self):
try:
self.send_signal(
(
signal.SIGINT
if not host.WINDOWS
else signal.CTRL_C_EVENT # pylint: disable=no-member
),
)
# pylint: disable-next=no-member
self.send_signal(signal.SIGINT if not host.WINDOWS else signal.CTRL_C_EVENT)
except SystemError:
pass

Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ Documentation = "https://nvitop.readthedocs.io"
[tool.setuptools.packages.find]
include = ["nvitop", "nvitop.*"]

[tool.black]
line-length = 100
skip-string-normalization = true
target-version = ["py37"]

[tool.mypy]
# Sync with requires-python
python_version = "3.8" # appease mypy for syntax errors in numpy stubs
Expand Down Expand Up @@ -118,6 +113,10 @@ line-length = 100
output-format = "full"
src = ["nvitop", "nvitop-exporter/nvitop_exporter"]

[tool.ruff.format]
quote-style = "single"
docstring-code-format = false

[tool.ruff.lint]
select = [
"E", "W", # pycodestyle
Expand Down Expand Up @@ -158,6 +157,9 @@ ignore = [
"W505",
# ANN401: dynamically typed expressions (typing.Any) are disallowed
"ANN401",
# COM812: missing trailing comma
# covered by `ruff format`
"COM812",
# FURB189: use the `UserDict`, `UserList`, and `UserString` instead
# internally subclassing `dict`, `list`, and `str`
"FURB189",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def vcs_version(name: str, path: Path | str) -> Generator[ModuleType]:

extra_requirements = {
'lint': [
'black >= 24.0.0, < 25.0.0a0',
'ruff',
'pylint[spelling]',
'mypy',
'typing-extensions',
Expand Down

0 comments on commit 3504c1c

Please sign in to comment.