Skip to content

Commit 3aed2ca

Browse files
authored
Merge pull request #1865 from Borda/ruff/black
lint: switch Black with `ruff-format`
2 parents edb8d26 + 1b8812a commit 3aed2ca

File tree

15 files changed

+55
-117
lines changed

15 files changed

+55
-117
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ jobs:
1616
- uses: pre-commit/action@v3.0.1
1717
with:
1818
extra_args: --all-files --hook-stage manual
19-
env:
20-
SKIP: black-format

.pre-commit-config.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
repos:
2-
- repo: https://github.com/psf/black-pre-commit-mirror
3-
rev: 23.9.1
4-
hooks:
5-
- id: black
6-
alias: black-check
7-
name: black (check)
8-
args: [--check, --diff]
9-
exclude: ^git/ext/
10-
stages: [manual]
11-
12-
- id: black
13-
alias: black-format
14-
name: black (format)
15-
exclude: ^git/ext/
162

173
- repo: https://github.com/astral-sh/ruff-pre-commit
184
rev: v0.3.0
195
hooks:
20-
#- id: ruff-format # todo: eventually replace Black with Ruff for consistency
21-
# args: ["--preview"]
6+
- id: ruff-format
7+
exclude: ^git/ext/
228
- id: ruff
239
args: ["--fix"]
2410
exclude: ^doc|^git/ext/

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
.PHONY: all lint clean release force_release
1+
.PHONY: all clean release force_release
22

33
all:
44
@awk -F: '/^[[:alpha:]].*:/ && !/^all:/ {print $$1}' Makefile
55

6-
lint:
7-
SKIP=black-format pre-commit run --all-files --hook-stage manual
8-
96
clean:
107
rm -rf build/ dist/ .eggs/ .tox/
118

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ To lint, and apply automatic code formatting, run:
165165
pre-commit run --all-files
166166
```
167167

168-
- Linting without modifying code can be done with: `make lint`
169-
- Auto-formatting without other lint checks can be done with: `black .`
170-
171168
To typecheck, run:
172169

173170
```bash

git/cmd.py

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,8 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
495495
if mode in quiet:
496496
pass
497497
elif mode in warn or mode in error:
498-
err = (
499-
dedent(
500-
"""\
498+
err = dedent(
499+
"""\
501500
%s
502501
All git commands will error until this is rectified.
503502
@@ -510,40 +509,35 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
510509
Example:
511510
export %s=%s
512511
"""
513-
)
514-
% (
515-
err,
516-
cls._refresh_env_var,
517-
"|".join(quiet),
518-
"|".join(warn),
519-
"|".join(error),
520-
cls._refresh_env_var,
521-
quiet[0],
522-
)
512+
) % (
513+
err,
514+
cls._refresh_env_var,
515+
"|".join(quiet),
516+
"|".join(warn),
517+
"|".join(error),
518+
cls._refresh_env_var,
519+
quiet[0],
523520
)
524521

525522
if mode in warn:
526523
_logger.critical(err)
527524
else:
528525
raise ImportError(err)
529526
else:
530-
err = (
531-
dedent(
532-
"""\
527+
err = dedent(
528+
"""\
533529
%s environment variable has been set but it has been set with an invalid value.
534530
535531
Use only the following values:
536532
- %s: for no message or exception
537533
- %s: for a warning message (logging level CRITICAL, displayed by default)
538534
- %s: for a raised exception
539535
"""
540-
)
541-
% (
542-
cls._refresh_env_var,
543-
"|".join(quiet),
544-
"|".join(warn),
545-
"|".join(error),
546-
)
536+
) % (
537+
cls._refresh_env_var,
538+
"|".join(quiet),
539+
"|".join(warn),
540+
"|".join(error),
547541
)
548542
raise ImportError(err)
549543

@@ -565,13 +559,11 @@ def is_cygwin(cls) -> bool:
565559

566560
@overload
567561
@classmethod
568-
def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str:
569-
...
562+
def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str: ...
570563

571564
@overload
572565
@classmethod
573-
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str:
574-
...
566+
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str: ...
575567

576568
@classmethod
577569
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> PathLike:
@@ -932,8 +924,7 @@ def execute(
932924
command: Union[str, Sequence[Any]],
933925
*,
934926
as_process: Literal[True],
935-
) -> "AutoInterrupt":
936-
...
927+
) -> "AutoInterrupt": ...
937928

938929
@overload
939930
def execute(
@@ -942,8 +933,7 @@ def execute(
942933
*,
943934
as_process: Literal[False] = False,
944935
stdout_as_string: Literal[True],
945-
) -> Union[str, Tuple[int, str, str]]:
946-
...
936+
) -> Union[str, Tuple[int, str, str]]: ...
947937

948938
@overload
949939
def execute(
@@ -952,8 +942,7 @@ def execute(
952942
*,
953943
as_process: Literal[False] = False,
954944
stdout_as_string: Literal[False] = False,
955-
) -> Union[bytes, Tuple[int, bytes, str]]:
956-
...
945+
) -> Union[bytes, Tuple[int, bytes, str]]: ...
957946

958947
@overload
959948
def execute(
@@ -963,8 +952,7 @@ def execute(
963952
with_extended_output: Literal[False],
964953
as_process: Literal[False],
965954
stdout_as_string: Literal[True],
966-
) -> str:
967-
...
955+
) -> str: ...
968956

969957
@overload
970958
def execute(
@@ -974,8 +962,7 @@ def execute(
974962
with_extended_output: Literal[False],
975963
as_process: Literal[False],
976964
stdout_as_string: Literal[False],
977-
) -> bytes:
978-
...
965+
) -> bytes: ...
979966

980967
def execute(
981968
self,
@@ -1387,8 +1374,9 @@ def __call__(self, **kwargs: Any) -> "Git":
13871374
return self
13881375

13891376
@overload
1390-
def _call_process(self, method: str, *args: None, **kwargs: None) -> str:
1391-
... # If no args were given, execute the call with all defaults.
1377+
def _call_process(
1378+
self, method: str, *args: None, **kwargs: None
1379+
) -> str: ... # If no args were given, execute the call with all defaults.
13921380

13931381
@overload
13941382
def _call_process(
@@ -1398,14 +1386,12 @@ def _call_process(
13981386
as_process: Literal[True],
13991387
*args: Any,
14001388
**kwargs: Any,
1401-
) -> "Git.AutoInterrupt":
1402-
...
1389+
) -> "Git.AutoInterrupt": ...
14031390

14041391
@overload
14051392
def _call_process(
14061393
self, method: str, *args: Any, **kwargs: Any
1407-
) -> Union[str, bytes, Tuple[int, Union[str, bytes], str], "Git.AutoInterrupt"]:
1408-
...
1394+
) -> Union[str, bytes, Tuple[int, Union[str, bytes], str], "Git.AutoInterrupt"]: ...
14091395

14101396
def _call_process(
14111397
self, method: str, *args: Any, **kwargs: Any

git/compat.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,11 @@
6969

7070

7171
@overload
72-
def safe_decode(s: None) -> None:
73-
...
72+
def safe_decode(s: None) -> None: ...
7473

7574

7675
@overload
77-
def safe_decode(s: AnyStr) -> str:
78-
...
76+
def safe_decode(s: AnyStr) -> str: ...
7977

8078

8179
def safe_decode(s: Union[AnyStr, None]) -> Optional[str]:
@@ -91,13 +89,11 @@ def safe_decode(s: Union[AnyStr, None]) -> Optional[str]:
9189

9290

9391
@overload
94-
def safe_encode(s: None) -> None:
95-
...
92+
def safe_encode(s: None) -> None: ...
9693

9794

9895
@overload
99-
def safe_encode(s: AnyStr) -> bytes:
100-
...
96+
def safe_encode(s: AnyStr) -> bytes: ...
10197

10298

10399
def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:
@@ -113,13 +109,11 @@ def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:
113109

114110

115111
@overload
116-
def win_encode(s: None) -> None:
117-
...
112+
def win_encode(s: None) -> None: ...
118113

119114

120115
@overload
121-
def win_encode(s: AnyStr) -> bytes:
122-
...
116+
def win_encode(s: AnyStr) -> bytes: ...
123117

124118

125119
def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:

git/index/fun.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ def read_cache(
286286
# 4 bytes length of chunk
287287
# Repeated 0 - N times
288288
extension_data = stream.read(~0)
289-
assert (
290-
len(extension_data) > 19
291-
), "Index Footer was not at least a sha on content as it was only %i bytes in size" % len(extension_data)
289+
assert len(extension_data) > 19, (
290+
"Index Footer was not at least a sha on content as it was only %i bytes in size" % len(extension_data)
291+
)
292292

293293
content_sha = extension_data[-20:]
294294

git/objects/fun.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,11 @@ def _find_by_name(tree_data: MutableSequence[EntryTupOrNone], name: str, is_dir:
152152

153153

154154
@overload
155-
def _to_full_path(item: None, path_prefix: str) -> None:
156-
...
155+
def _to_full_path(item: None, path_prefix: str) -> None: ...
157156

158157

159158
@overload
160-
def _to_full_path(item: EntryTup, path_prefix: str) -> EntryTup:
161-
...
159+
def _to_full_path(item: EntryTup, path_prefix: str) -> EntryTup: ...
162160

163161

164162
def _to_full_path(item: EntryTupOrNone, path_prefix: str) -> EntryTupOrNone:

git/objects/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable):
188188
_map_id_to_type: Dict[int, Type[IndexObjUnion]] = {
189189
commit_id: Submodule,
190190
blob_id: Blob,
191-
symlink_id: Blob
191+
symlink_id: Blob,
192192
# Tree ID added once Tree is defined.
193193
}
194194

git/objects/util.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ def list_traverse(self: T_TIobj, *args: Any, **kwargs: Any) -> IterableList[T_TI
620620
return super()._list_traverse(*args, **kwargs)
621621

622622
@overload # type: ignore
623-
def traverse(self: T_TIobj) -> Iterator[T_TIobj]:
624-
...
623+
def traverse(self: T_TIobj) -> Iterator[T_TIobj]: ...
625624

626625
@overload
627626
def traverse(
@@ -633,8 +632,7 @@ def traverse(
633632
visit_once: bool,
634633
ignore_self: Literal[True],
635634
as_edge: Literal[False],
636-
) -> Iterator[T_TIobj]:
637-
...
635+
) -> Iterator[T_TIobj]: ...
638636

639637
@overload
640638
def traverse(
@@ -646,8 +644,7 @@ def traverse(
646644
visit_once: bool,
647645
ignore_self: Literal[False],
648646
as_edge: Literal[True],
649-
) -> Iterator[Tuple[Union[T_TIobj, None], T_TIobj]]:
650-
...
647+
) -> Iterator[Tuple[Union[T_TIobj, None], T_TIobj]]: ...
651648

652649
@overload
653650
def traverse(
@@ -659,8 +656,7 @@ def traverse(
659656
visit_once: bool,
660657
ignore_self: Literal[True],
661658
as_edge: Literal[True],
662-
) -> Iterator[Tuple[T_TIobj, T_TIobj]]:
663-
...
659+
) -> Iterator[Tuple[T_TIobj, T_TIobj]]: ...
664660

665661
def traverse(
666662
self: T_TIobj,

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