Skip to content

lint: replace flake8 with ruff 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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixing lints / noqa
  • Loading branch information
Borda committed Mar 11, 2024
commit aa9298a37f1bbdecfbfe9b13026c81374abdc2d7
8 changes: 4 additions & 4 deletions git/index/base.py
Original file line number Diff line number Diff 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_path or self._file_path)
stream = lfd.open(write=True, stream=True)

Expand Down Expand Up @@ -397,7 +397,7 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile
with TemporaryFileSwap(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.
return index
# END index merge handling

Expand Down Expand 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 Down Expand 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)
except GitCommandError:
# Without parsing stdout we don't know what failed.
raise CheckoutError(
raise CheckoutError( # noqa: B904
"Some files could not be checked out from the index, probably because they didn't exist.",
failed_files,
[],
Expand Down
2 changes: 1 addition & 1 deletion git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ def exists(self) -> bool:

try:
try:
self.path
self.path # noqa: B018
return True
except Exception:
return False
Expand Down
2 changes: 1 addition & 1 deletion git/objects/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _list_traverse(

if not as_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
return out
# 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 deletions git/refs/symbolic.py
Original file line number Diff line number Diff 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):
return False
else:
Expand All @@ -510,7 +510,7 @@ def is_detached(self) -> bool:
instead to another reference.
"""
try:
self.ref
self.ref # noqa: B018
return False
except TypeError:
return True
Expand Down
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,17 @@ lint.select = [
# "UP", # see: https://docs.astral.sh/ruff/rules/#pyupgrade-up
]
lint.extend-select = [
"A", # see: https://pypi.org/project/flake8-builtins
#"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", "W503"
"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]
#"setup.py" = ["ANN202", "ANN401"]
#"docs/source/conf.py" = ["A001", "D103"]
#"src/**" = ["ANN401"]
#"tests/**" = ["S101", "ANN001", "ANN201", "ANN202", "ANN401"]
[tool.ruff.lint.per-file-ignores]
"test/**" = ["B018"]