Skip to content

Commit ed25d19

Browse files
committed
Migrate to ruff
Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent 8d65b8b commit ed25d19

8 files changed

Lines changed: 36 additions & 32 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
---
2-
default_language_version:
3-
# force all unspecified python hooks to run python3
4-
python: python3
52
repos:
63
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v5.0.0
4+
rev: v6.0.0
85
hooks:
96
- id: check-executables-have-shebangs
107
- id: check-merge-conflict
118
- id: check-yaml
129
- id: end-of-file-fixer
1310
- id: trailing-whitespace
14-
- repo: https://github.com/pycqa/flake8
15-
rev: 7.1.1
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.15.10
1613
hooks:
17-
- id: flake8
18-
- repo: https://github.com/psf/black
19-
rev: 24.10.0
20-
hooks:
21-
- id: black
14+
- id: ruff-check
15+
args: ['--fix', '--unsafe-fixes']
16+
- id: ruff-format

git_pw/api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ def _handle_error(
123123

124124
else:
125125
LOG.error(
126-
'Failed to %s resource. Is your configuration '
127-
'correct?' % operation
126+
'Failed to %s resource. Is your configuration correct?' % operation
128127
)
129128
LOG.error("Use the '--debug' flag for more information")
130129

git_pw/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def update_cmd(patch_ids, commit_ref, state, delegate, archived, fmt):
248248
"""
249249
for patch_id in patch_ids:
250250
LOG.debug(
251-
'Updating patch: id=%d, commit_ref=%s, state=%s, ' 'archived=%s',
251+
'Updating patch: id=%d, commit_ref=%s, state=%s, archived=%s',
252252
patch_id,
253253
commit_ref,
254254
state,

git_pw/series.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ def _format_submission(submission):
186186
metavar='SUBMITTER',
187187
multiple=True,
188188
help=(
189-
'Show only series by these submitters. Should be an '
190-
'email, name or ID.'
189+
'Show only series by these submitters. Should be an email, name or ID.'
191190
),
192191
)
193192
@utils.date_options()

git_pw/shell.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
metavar='TOKEN',
2626
envvar='PW_TOKEN',
2727
help=(
28-
"Authentication token. "
29-
"Defaults to the value of 'git config pw.token'."
28+
"Authentication token. Defaults to the value of 'git config pw.token'."
3029
),
3130
)
3231
@click.option(

pyproject.toml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
[build-system]
2-
requires = ["pbr>=5.7.0", "setuptools>=36.6.0"]
2+
requires = ["pbr>=6.1.1"]
33
build-backend = "pbr.build"
44

5-
[tool.black]
5+
[tool.ruff]
66
line-length = 79
7-
skip-string-normalization = true
7+
8+
[tool.ruff.format]
9+
quote-style = "preserve"
10+
docstring-code-format = true
11+
12+
[tool.ruff.lint]
13+
select = ["E4", "E7", "E9", "F", "S"]
14+
ignore = [
15+
# we only use asserts for type narrowing
16+
"S101",
17+
# FIXME: Add timeouts to requests
18+
"S113",
19+
# client tool can use subprocess as they like
20+
"S603",
21+
]
22+
23+
[tool.ruff.lint.per-file-ignores]
24+
"tests/*" = ["S"]
25+
"examples/*" = ["S"]

tests/test_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_git_config(mock_subprocess):
2626
def test_git_config_unicode(mock_subprocess):
2727
value = utils.git_config('foo')
2828

29-
assert value == u'\U0001f937'
29+
assert value == '\U0001f937'
3030
mock_subprocess.assert_called_once_with(['git', 'config', 'foo'])
3131

3232

@@ -90,7 +90,7 @@ def test_echo_via_pager_env_default(mock_inner, mock_tabulate, mock_config):
9090

9191

9292
def _test_tabulate(fmt):
93-
output = [(b'foo', 'bar', u'baz', '😀', None, 1)]
93+
output = [(b'foo', 'bar', 'baz', '😀', None, 1)]
9494
headers = ('col1', 'colb', 'colIII', 'colX', 'colY', 'colZ')
9595

9696
result = utils._tabulate(output, headers, fmt)
@@ -136,7 +136,7 @@ def test_tabulate_yaml(mock_dump):
136136
{
137137
'col1': b'foo',
138138
'colb': 'bar',
139-
'coliii': u'baz',
139+
'coliii': 'baz',
140140
'colx': '😀',
141141
'coly': None,
142142
'colz': 1,

tox.ini

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
minversion = 3.1
2+
minversion = 4.6
33
envlist = pep8,mypy,clean,py{39,310,311,312,313},report
44

55
[testenv]
@@ -48,13 +48,7 @@ commands =
4848
sphinx-build {posargs:-E -W} docs docs/_build/html
4949

5050
[testenv:man]
51-
# Does not currently support Python 3.12
52-
# https://github.com/click-contrib/click-man/pull/64
53-
basepython = 3.11
5451
deps =
55-
click-man~=0.4.0
52+
click-man~=0.5.1
5653
commands =
5754
click-man git-pw
58-
59-
[flake8]
60-
show-source = true

0 commit comments

Comments
 (0)