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

lint: replaceflake8 withruff check#1862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 3 commits intogitpython-developers:mainfromBorda:lint/ruff
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions.flake8
View file
Open in desktop

This file was deleted.

13 changes: 6 additions & 7 deletions.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,14 +14,13 @@ repos:
name:black (format)
exclude:^git/ext/

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

-repo:https://github.com/shellcheck-py/shellcheck-py
Expand Down
2 changes: 1 addition & 1 deletionREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -187,7 +187,7 @@ The same linting, and running tests on all the different supported Python versio
Specific tools:

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

Orchestration tools:

Expand Down
8 changes: 4 additions & 4 deletionsgit/index/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -248,7 +248,7 @@ def write(
# Make sure we have our entries read before getting a write lock.
# Otherwise it would be done when streaming.
# This can happen if one doesn't change the index, but writes it right away.
self.entries
self.entries# noqa: B018
lfd=LockedFD(file_pathorself._file_path)
stream=lfd.open(write=True,stream=True)

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

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

args.append("--stdin")
kwargs["as_process"]=True
Expand DownExpand Up@@ -1379,7 +1379,7 @@ def handle_stderr(proc: "Popen[bytes]", iter_checked_out_files: Iterable[PathLik
self._flush_stdin_and_wait(proc,ignore_stdout=True)
exceptGitCommandError:
# Without parsing stdout we don't know what failed.
raiseCheckoutError(
raiseCheckoutError(# noqa: B904
"Some files could not be checked out from the index, probably because they didn't exist.",
failed_files,
[],
Expand Down
6 changes: 5 additions & 1 deletiongit/objects/blob.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,11 @@
frommimetypesimportguess_type
from .importbase

fromgit.typesimportLiteral

try:
fromtypingimportLiteral
exceptImportError:
fromtyping_extensionsimportLiteral

__all__= ("Blob",)

Expand Down
7 changes: 6 additions & 1 deletiongit/objects/commit.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,12 @@
Dict,
)

fromgit.typesimportPathLike,Literal
fromgit.typesimportPathLike

try:
fromtypingimportLiteral
exceptImportError:
fromtyping_extensionsimportLiteral

ifTYPE_CHECKING:
fromgit.repoimportRepo
Expand Down
9 changes: 7 additions & 2 deletionsgit/objects/submodule/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,12 @@
fromtypingimportCallable,Dict,Mapping,Sequence,TYPE_CHECKING,cast
fromtypingimportAny,Iterator,Union

fromgit.typesimportCommit_ish,Literal,PathLike,TBD
fromgit.typesimportCommit_ish,PathLike,TBD

try:
fromtypingimportLiteral
exceptImportError:
fromtyping_extensionsimportLiteral

ifTYPE_CHECKING:
fromgit.indeximportIndexFile
Expand DownExpand Up@@ -1445,7 +1450,7 @@ def exists(self) -> bool:

try:
try:
self.path
self.path# noqa: B018
returnTrue
exceptException:
returnFalse
Expand Down
5 changes: 4 additions & 1 deletiongit/objects/tag.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,10 @@

fromtypingimportList,TYPE_CHECKING,Union

fromgit.typesimportLiteral
try:
fromtypingimportLiteral
exceptImportError:
fromtyping_extensionsimportLiteral

ifTYPE_CHECKING:
fromgit.repoimportRepo
Expand Down
7 changes: 6 additions & 1 deletiongit/objects/tree.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,12 @@
TYPE_CHECKING,
)

fromgit.typesimportPathLike,Literal
fromgit.typesimportPathLike

try:
fromtypingimportLiteral
exceptImportError:
fromtyping_extensionsimportLiteral

ifTYPE_CHECKING:
fromgit.repoimportRepo
Expand Down
2 changes: 1 addition & 1 deletiongit/objects/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -439,7 +439,7 @@ def _list_traverse(

ifnotas_edge:
out:IterableList[Union["Commit","Submodule","Tree","Blob"]]=IterableList(id)
out.extend(self.traverse(as_edge=as_edge,*args,**kwargs))
out.extend(self.traverse(as_edge=as_edge,*args,**kwargs))# noqa: B026
returnout
# Overloads in subclasses (mypy doesn't allow typing self: subclass).
# Union[IterableList['Commit'], IterableList['Submodule'], IterableList[Union['Submodule', 'Tree', 'Blob']]]
Expand Down
4 changes: 2 additions & 2 deletionsgit/refs/symbolic.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -496,7 +496,7 @@ def is_valid(self) -> bool:
valid object or reference.
"""
try:
self.object
self.object# noqa: B018
except (OSError,ValueError):
returnFalse
else:
Expand All@@ -510,7 +510,7 @@ def is_detached(self) -> bool:
instead to another reference.
"""
try:
self.ref
self.ref# noqa: B018
returnFalse
exceptTypeError:
returnTrue
Expand Down
36 changes: 35 additions & 1 deletionpyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,6 @@ warn_unreachable = true
show_error_codes =true
implicit_reexport =true
# strict = true

# TODO: Remove when 'gitdb' is fully annotated.
exclude = ["^git/ext/gitdb"]
[[tool.mypy.overrides]]
Expand All@@ -47,3 +46,38 @@ omit = ["*/git/ext/*"]
line-length =120
target-version = ["py37"]
extend-exclude ="git/ext/gitdb"

[tool.ruff]
target-version ="py37"
line-length =120
# Exclude a variety of commonly ignored directories.
exclude = [
"git/ext/",
"doc",
"build",
"dist",
]
# Enable Pyflakes `E` and `F` codes by default.
lint.select = [
"E",
"W",# see: https://pypi.org/project/pycodestyle
"F",# see: https://pypi.org/project/pyflakes
# "I", #see: https://pypi.org/project/isort/
# "S", # see: https://pypi.org/project/flake8-bandit
# "UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up
]
lint.extend-select = [
#"A", # see: https://pypi.org/project/flake8-builtins
"B",# see: https://pypi.org/project/flake8-bugbear
"C4",# see: https://pypi.org/project/flake8-comprehensions
"TCH004",# see: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
]
lint.ignore = [
"E203",
"E731",# Do not assign a `lambda` expression, use a `def`
]
lint.ignore-init-module-imports =true
lint.unfixable = ["F401"]

[tool.ruff.lint.per-file-ignores]
"test/**" = ["B018"]
2 changes: 0 additions & 2 deletionsrequirements-dev.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,5 @@

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

flake8-type-checking;python_version>="3.8"# checks for TYPE_CHECKING only imports

pytest-icdiff
# pytest-profiling

[8]ページ先頭

©2009-2025 Movatter.jp