Skip to content

Commit 49855bc

Browse files
committed
git-review-rebase: fix linters warnings.
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@vates.tech>
1 parent f62e879 commit 49855bc

8 files changed

Lines changed: 45 additions & 14 deletions

File tree

‎scripts/git-review-rebase/pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies = [
3333

3434
[dependency-groups]
3535
dev = [
36+
"pyright>=1.1.408",
3637
"pytest>=9.0.2",
3738
"pytest-asyncio>=1.3.0",
3839
"black>=24.10.0",

‎scripts/git-review-rebase/requirements/dev.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# generated with update_requirements.py, do not edit manually
2+
pyright>=1.1.408
23
pytest>=9.0.2
34
pytest-asyncio>=1.3.0
45
black>=24.10.0

‎scripts/git-review-rebase/requirements/update_requirements.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@
44
import tomllib
55
from pathlib import Path
66

7-
parser = argparse.ArgumentParser(description="Convert the dependencies from pyproject.toml in requirements.txt files")
7+
parser = argparse.ArgumentParser(
8+
description="Convert the dependencies from pyproject.toml in requirements.txt files"
9+
)
810
args = parser.parse_args()
911

1012
PROJECT_DIR = Path(__file__).parent.parent
1113
HEADER = "# generated with update_requirements.py, do not edit manually"
1214

13-
with open(f'{PROJECT_DIR}/pyproject.toml', 'rb') as f:
15+
with open(f"{PROJECT_DIR}/pyproject.toml", "rb") as f:
1416
pyproject = tomllib.load(f)
1517

1618

17-
main_deps = pyproject['project']['dependencies']
18-
with open(f'{PROJECT_DIR}/requirements/base.txt', 'w') as f:
19+
main_deps = pyproject["project"]["dependencies"]
20+
with open(f"{PROJECT_DIR}/requirements/base.txt", "w") as f:
1921
print(HEADER, file=f)
2022
for dep in main_deps:
2123
print(dep, file=f)
2224

23-
dev_deps = pyproject['dependency-groups']['dev']
24-
with open(f'{PROJECT_DIR}/requirements/dev.txt', 'w') as f:
25+
dev_deps = pyproject["dependency-groups"]["dev"]
26+
with open(f"{PROJECT_DIR}/requirements/dev.txt", "w") as f:
2527
print(HEADER, file=f)
2628
for dep in dev_deps:
2729
print(dep, file=f)
28-
print('-r base.txt', file=f)
30+
print("-r base.txt", file=f)

‎scripts/git-review-rebase/src/git_review_rebase/commit_matching.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ def init_matches(self) -> None:
7777
right_commit = self.repo.get(right_commit_id)
7878
assert isinstance(right_commit, pygit2.Commit)
7979
self.commit_matches[right_commit_id] = RebasedCommitMatch(
80-
None, self.repo.get(right_commit_id), CommitMatchInfoFlag.Added
80+
None, right_commit, CommitMatchInfoFlag.Added
8181
)
8282
self.commit_matches.update(left_commit_matches)

‎scripts/git-review-rebase/src/git_review_rebase/git_utils.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Git utility functions for repository operations."""
22

33
import multiprocessing
4+
from multiprocessing.managers import DictProxy
45

56
import pygit2
67
from pygit2 import Walker
@@ -42,13 +43,12 @@ def cached_patchid_ref(revision: str) -> str:
4243
return f"refs/patchids/from_revision/" f"{revision[:2]}/{revision[2:4]}/{revision[4:]}"
4344

4445

45-
_repo = None
46-
_commit_by_patchid_str = None
46+
_repo: None | pygit2.Repository = None
47+
_commit_by_patchid_str: None | DictProxy = None
4748

4849

4950
def patchid(repo: pygit2.Repository, commit: pygit2.Commit, cache_flags: CacheFlags) -> pygit2.Oid:
50-
if cache_flags:
51-
cached_ref = cached_patchid_ref(str(commit.id))
51+
cached_ref = cached_patchid_ref(str(commit.id))
5252
try:
5353
if CacheFlags.READ_FROM_CACHE not in cache_flags:
5454
raise KeyError("Do not use the cache")
@@ -70,7 +70,10 @@ def patchid_map_fn(
7070
"""Given a revision stuff the commits_patchid dict with its patchid."""
7171
if _repo is None:
7272
raise RuntimeError("_repo needs to be defined")
73+
if _commit_by_patchid_str is None:
74+
raise RuntimeError("_commit_by_patchid_str needs to be defined")
7375
commit = _repo.get(pygit2.Oid(hex=revision))
76+
assert isinstance(commit, pygit2.Commit)
7477
_commit_by_patchid_str[str(patchid(_repo, commit, cache_flags))] = revision
7578

7679

‎scripts/git-review-rebase/src/git_review_rebase/ui/diff_table.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async def add_blame_info(
161161
assert self.right_commit is not None
162162
right = await self.prefix(self.right_diff, self.right_commit, right_text)
163163
left = await self.prefix(self.left_diff, self.left_commit, left_text)
164-
return left, right
164+
return left, right # pyright: ignore[reportPossiblyUnboundVariable]
165165

166166
async def get_row_from_line(self, line: str) -> tuple[Text, Text, Text]:
167167
if not line:

‎scripts/git-review-rebase/src/git_review_rebase/ui/rebase_table.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,5 @@ def commit_filtered_out():
139139
left_cell,
140140
markers_from_match_type(rebased_commit_match.match_info),
141141
right_cell,
142-
key=commit_oid, # type: ignore
142+
key=commit_oid, # type: ignore
143143
)

‎scripts/git-review-rebase/uv.lock‎

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)