Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitedb8d26

Browse files
authored
Merge pull request#1862 from Borda/lint/ruff
lint: replace `flake8` with `ruff` check
2 parents49cb48a +5f889c4 commitedb8d26

13 files changed

+77
-50
lines changed

‎.flake8

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎.pre-commit-config.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ repos:
1414
name:black (format)
1515
exclude:^git/ext/
1616

17-
-repo:https://github.com/PyCQA/flake8
18-
rev:6.1.0
17+
-repo:https://github.com/astral-sh/ruff-pre-commit
18+
rev:v0.3.0
1919
hooks:
20-
-id:flake8
21-
additional_dependencies:
22-
-flake8-bugbear==23.9.16
23-
-flake8-comprehensions==3.14.0
24-
-flake8-typing-imports==1.14.0
20+
#- id: ruff-format # todo: eventually replace Black with Ruff for consistency
21+
# args: ["--preview"]
22+
-id:ruff
23+
args:["--fix"]
2524
exclude:^doc|^git/ext/
2625

2726
-repo:https://github.com/shellcheck-py/shellcheck-py

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ The same linting, and running tests on all the different supported Python versio
187187
Specific tools:
188188

189189
- Configurations for`mypy`,`pytest`,`coverage.py`, and`black` are in`./pyproject.toml`.
190-
- Configuration for`flake8` is in the`./.flake8` file.
190+
- Configuration for`ruff` is in the`pyproject.toml` file.
191191

192192
Orchestration tools:
193193

‎git/index/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def write(
248248
# Make sure we have our entries read before getting a write lock.
249249
# Otherwise it would be done when streaming.
250250
# This can happen if one doesn't change the index, but writes it right away.
251-
self.entries
251+
self.entries# noqa: B018
252252
lfd=LockedFD(file_pathorself._file_path)
253253
stream=lfd.open(write=True,stream=True)
254254

@@ -397,7 +397,7 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile
397397
withTemporaryFileSwap(join_path_native(repo.git_dir,"index")):
398398
repo.git.read_tree(*arg_list,**kwargs)
399399
index=cls(repo,tmp_index)
400-
index.entries# Force it to read the file as we will delete the temp-file.
400+
index.entries#noqa: B018 #Force it to read the file as we will delete the temp-file.
401401
returnindex
402402
# END index merge handling
403403

@@ -1339,7 +1339,7 @@ def handle_stderr(proc: "Popen[bytes]", iter_checked_out_files: Iterable[PathLik
13391339
# Make sure we have our entries loaded before we start checkout_index, which
13401340
# will hold a lock on it. We try to get the lock as well during our entries
13411341
# initialization.
1342-
self.entries
1342+
self.entries# noqa: B018
13431343

13441344
args.append("--stdin")
13451345
kwargs["as_process"]=True
@@ -1379,7 +1379,7 @@ def handle_stderr(proc: "Popen[bytes]", iter_checked_out_files: Iterable[PathLik
13791379
self._flush_stdin_and_wait(proc,ignore_stdout=True)
13801380
exceptGitCommandError:
13811381
# Without parsing stdout we don't know what failed.
1382-
raiseCheckoutError(
1382+
raiseCheckoutError(# noqa: B904
13831383
"Some files could not be checked out from the index, probably because they didn't exist.",
13841384
failed_files,
13851385
[],

‎git/objects/blob.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
frommimetypesimportguess_type
77
from .importbase
88

9-
fromgit.typesimportLiteral
9+
10+
try:
11+
fromtypingimportLiteral
12+
exceptImportError:
13+
fromtyping_extensionsimportLiteral
1014

1115
__all__= ("Blob",)
1216

‎git/objects/commit.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@
4444
Dict,
4545
)
4646

47-
fromgit.typesimportPathLike,Literal
47+
fromgit.typesimportPathLike
48+
49+
try:
50+
fromtypingimportLiteral
51+
exceptImportError:
52+
fromtyping_extensionsimportLiteral
4853

4954
ifTYPE_CHECKING:
5055
fromgit.repoimportRepo

‎git/objects/submodule/base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@
4444
fromtypingimportCallable,Dict,Mapping,Sequence,TYPE_CHECKING,cast
4545
fromtypingimportAny,Iterator,Union
4646

47-
fromgit.typesimportCommit_ish,Literal,PathLike,TBD
47+
fromgit.typesimportCommit_ish,PathLike,TBD
48+
49+
try:
50+
fromtypingimportLiteral
51+
exceptImportError:
52+
fromtyping_extensionsimportLiteral
4853

4954
ifTYPE_CHECKING:
5055
fromgit.indeximportIndexFile
@@ -1445,7 +1450,7 @@ def exists(self) -> bool:
14451450

14461451
try:
14471452
try:
1448-
self.path
1453+
self.path# noqa: B018
14491454
returnTrue
14501455
exceptException:
14511456
returnFalse

‎git/objects/tag.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
fromtypingimportList,TYPE_CHECKING,Union
1818

19-
fromgit.typesimportLiteral
19+
try:
20+
fromtypingimportLiteral
21+
exceptImportError:
22+
fromtyping_extensionsimportLiteral
2023

2124
ifTYPE_CHECKING:
2225
fromgit.repoimportRepo

‎git/objects/tree.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@
3131
TYPE_CHECKING,
3232
)
3333

34-
fromgit.typesimportPathLike,Literal
34+
fromgit.typesimportPathLike
35+
36+
try:
37+
fromtypingimportLiteral
38+
exceptImportError:
39+
fromtyping_extensionsimportLiteral
3540

3641
ifTYPE_CHECKING:
3742
fromgit.repoimportRepo

‎git/objects/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def _list_traverse(
439439

440440
ifnotas_edge:
441441
out:IterableList[Union["Commit","Submodule","Tree","Blob"]]=IterableList(id)
442-
out.extend(self.traverse(as_edge=as_edge,*args,**kwargs))
442+
out.extend(self.traverse(as_edge=as_edge,*args,**kwargs))# noqa: B026
443443
returnout
444444
# Overloads in subclasses (mypy doesn't allow typing self: subclass).
445445
# Union[IterableList['Commit'], IterableList['Submodule'], IterableList[Union['Submodule', 'Tree', 'Blob']]]

‎git/refs/symbolic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def is_valid(self) -> bool:
496496
valid object or reference.
497497
"""
498498
try:
499-
self.object
499+
self.object# noqa: B018
500500
except (OSError,ValueError):
501501
returnFalse
502502
else:
@@ -510,7 +510,7 @@ def is_detached(self) -> bool:
510510
instead to another reference.
511511
"""
512512
try:
513-
self.ref
513+
self.ref# noqa: B018
514514
returnFalse
515515
exceptTypeError:
516516
returnTrue

‎pyproject.toml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ warn_unreachable = true
2929
show_error_codes =true
3030
implicit_reexport =true
3131
# strict = true
32-
3332
# TODO: Remove when 'gitdb' is fully annotated.
3433
exclude = ["^git/ext/gitdb"]
3534
[[tool.mypy.overrides]]
@@ -47,3 +46,38 @@ omit = ["*/git/ext/*"]
4746
line-length =120
4847
target-version = ["py37"]
4948
extend-exclude ="git/ext/gitdb"
49+
50+
[tool.ruff]
51+
target-version ="py37"
52+
line-length =120
53+
# Exclude a variety of commonly ignored directories.
54+
exclude = [
55+
"git/ext/",
56+
"doc",
57+
"build",
58+
"dist",
59+
]
60+
# Enable Pyflakes `E` and `F` codes by default.
61+
lint.select = [
62+
"E",
63+
"W",# see: https://pypi.org/project/pycodestyle
64+
"F",# see: https://pypi.org/project/pyflakes
65+
# "I", #see: https://pypi.org/project/isort/
66+
# "S", # see: https://pypi.org/project/flake8-bandit
67+
# "UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up
68+
]
69+
lint.extend-select = [
70+
#"A", # see: https://pypi.org/project/flake8-builtins
71+
"B",# see: https://pypi.org/project/flake8-bugbear
72+
"C4",# see: https://pypi.org/project/flake8-comprehensions
73+
"TCH004",# see: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
74+
]
75+
lint.ignore = [
76+
"E203",
77+
"E731",# Do not assign a `lambda` expression, use a `def`
78+
]
79+
lint.ignore-init-module-imports =true
80+
lint.unfixable = ["F401"]
81+
82+
[tool.ruff.lint.per-file-ignores]
83+
"test/**" = ["B018"]

‎requirements-dev.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33

44
# libraries for additional local testing/linting - to be added to test-requirements.txt when all pass
55

6-
flake8-type-checking;python_version>="3.8"# checks for TYPE_CHECKING only imports
7-
86
pytest-icdiff
97
# pytest-profiling

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp