Skip to content

Commit bab77df

Browse files
committed
Use newer ruff style
This updates `ruff` in `.pre-commmit-config.yaml` from 0.6.0 to 0.11.12, changes its `id` from the legacay `ruff` alias to `ruff-check` (which is better distinguished from `ruff-format`, which we also have a hook for), and applies the few style changes it newly recommends throughout the code. The style changes seem to make things slightly clearer overall. This also updates some other pre-commit hooks, but those don't require any changes to the code. Currently the `ruff` dependency in `requirements-dev.txt` doesn't specify a version, so no change is needed there. This update may be seen as bringing the `pre-commit` version in line with what users will usually have locally with `pip install -e ".[test]"`. The `pre-commit` hooks are how linting is currently done on CI, so this is updating `ruff` for CI. That's the most significnt effect of this change. (`pre-commit` is run for linting on CI probably much more often than it is used locally, to manage pre-commit hooks or otherwise, in GitPython development.)
1 parent 8576534 commit bab77df

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
repos:
22
- repo: https://github.com/codespell-project/codespell
3-
rev: v2.3.0
3+
rev: v2.4.1
44
hooks:
55
- id: codespell
66
additional_dependencies: [tomli]
77
exclude: ^test/fixtures/
88

99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.6.0
10+
rev: v0.11.12
1111
hooks:
12-
- id: ruff
12+
- id: ruff-check
1313
args: ["--fix"]
1414
exclude: ^git/ext/
1515
- id: ruff-format
@@ -23,7 +23,7 @@ repos:
2323
exclude: ^test/fixtures/polyglot$|^git/ext/
2424

2525
- repo: https://github.com/pre-commit/pre-commit-hooks
26-
rev: v4.6.0
26+
rev: v5.0.0
2727
hooks:
2828
- id: end-of-file-fixer
2929
exclude: ^test/fixtures/|COPYING|LICENSE
@@ -33,6 +33,6 @@ repos:
3333
- id: check-merge-conflict
3434

3535
- repo: https://github.com/abravalheri/validate-pyproject
36-
rev: v0.19
36+
rev: v0.24.1
3737
hooks:
3838
- id: validate-pyproject

git/cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def pump_stream(
207207
)
208208
if stderr_handler:
209209
error_str: Union[str, bytes] = (
210-
"error: process killed because it timed out." f" kill_after_timeout={kill_after_timeout} seconds"
210+
f"error: process killed because it timed out. kill_after_timeout={kill_after_timeout} seconds"
211211
)
212212
if not decode_streams and isinstance(p_stderr, BinaryIO):
213213
# Assume stderr_handler needs binary input.
@@ -1319,7 +1319,7 @@ def communicate() -> Tuple[AnyStr, AnyStr]:
13191319
out, err = proc.communicate()
13201320
watchdog.cancel()
13211321
if kill_check.is_set():
1322-
err = 'Timeout: the command "%s" did not complete in %d ' "secs." % (
1322+
err = 'Timeout: the command "%s" did not complete in %d secs.' % (
13231323
" ".join(redacted_command),
13241324
timeout,
13251325
)

git/refs/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def from_line(cls, line: bytes) -> "RefLogEntry":
126126
elif len(fields) == 2:
127127
info, msg = fields
128128
else:
129-
raise ValueError("Line must have up to two TAB-separated fields." " Got %s" % repr(line_str))
129+
raise ValueError("Line must have up to two TAB-separated fields. Got %s" % repr(line_str))
130130
# END handle first split
131131

132132
oldhexsha = info[:40]

git/repo/fun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def rev_parse(repo: "Repo", rev: str) -> AnyGitObject:
405405
# END end handle tag
406406
except (IndexError, AttributeError) as e:
407407
raise BadName(
408-
f"Invalid revision spec '{rev}' - not enough " f"parent commits to reach '{token}{int(num)}'"
408+
f"Invalid revision spec '{rev}' - not enough parent commits to reach '{token}{int(num)}'"
409409
) from e
410410
# END exception handling
411411
# END parse loop

test/test_git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ def test_environment(self, rw_dir):
747747

748748
path = osp.join(rw_dir, "failing-script.sh")
749749
with open(path, "wt") as stream:
750-
stream.write("#!/usr/bin/env sh\n" "echo FOO\n")
750+
stream.write("#!/usr/bin/env sh\necho FOO\n")
751751
os.chmod(path, 0o777)
752752

753753
rw_repo = Repo.init(osp.join(rw_dir, "repo"))

test/test_quick_doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_cloned_repo_object(self, local_dir):
173173
# [15-test_cloned_repo_object]
174174
def print_files_from_git(root, level=0):
175175
for entry in root:
176-
print(f'{"-" * 4 * level}| {entry.path}, {entry.type}')
176+
print(f"{'-' * 4 * level}| {entry.path}, {entry.type}")
177177
if entry.type == "tree":
178178
print_files_from_git(entry, level + 1)
179179

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy