Skip to content

Commit e142ba8

Browse files
committed
Fix mypy issues in primer
1 parent 4e0e78d commit e142ba8

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

pylint/testutils/_primer/package_to_lint.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import logging
88
from pathlib import Path
99

10-
import git
10+
from git.cmd import Git
11+
from git.repo import Repo
1112

1213
PRIMER_DIRECTORY_PATH = Path("tests") / ".pylint_primer_tests"
1314

@@ -92,22 +93,22 @@ def lazy_clone(self) -> str: # pragma: no cover
9293
"depth": 1,
9394
}
9495
logging.info("Directory does not exists, cloning: %s", options)
95-
repo = git.Repo.clone_from(**options)
96-
return repo.head.object.hexsha
96+
repo = Repo.clone_from(
97+
url=self.url, to_path=self.clone_directory, branch=self.branch, depth=1
98+
)
99+
return str(repo.head.object.hexsha)
97100

98-
remote_sha1_commit = (
99-
git.cmd.Git().ls_remote(self.url, self.branch).split("\t")[0]
100-
)
101-
local_sha1_commit = git.Repo(self.clone_directory).head.object.hexsha
101+
remote_sha1_commit = Git().ls_remote(self.url, self.branch).split("\t")[0]
102+
local_sha1_commit = Repo(self.clone_directory).head.object.hexsha
102103
if remote_sha1_commit != local_sha1_commit:
103104
logging.info(
104105
"Remote sha is '%s' while local sha is '%s': pulling new commits",
105106
remote_sha1_commit,
106107
local_sha1_commit,
107108
)
108-
repo = git.Repo(self.clone_directory)
109+
repo = Repo(self.clone_directory)
109110
origin = repo.remotes.origin
110111
origin.pull()
111112
else:
112113
logging.info("Repository already up to date.")
113-
return remote_sha1_commit
114+
return str(remote_sha1_commit)

pylint/testutils/_primer/primer_prepare_command.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
44
from __future__ import annotations
55

6-
import git
6+
from git.cmd import Git
7+
from git.repo import Repo
78

89
from pylint.testutils._primer.primer_command import PrimerCommand
910

@@ -18,13 +19,13 @@ def run(self) -> None:
1819
commit_string += local_commit + "_"
1920
elif self.config.check:
2021
for package, data in self.packages.items():
21-
local_commit = git.Repo(data.clone_directory).head.object.hexsha
22+
local_commit = Repo(data.clone_directory).head.object.hexsha
2223
print(f"Found '{package}' at commit '{local_commit}'.")
2324
commit_string += local_commit + "_"
2425
elif self.config.make_commit_string:
2526
for package, data in self.packages.items():
2627
remote_sha1_commit = (
27-
git.cmd.Git().ls_remote(data.url, data.branch).split("\t")[0]
28+
Git().ls_remote(data.url, data.branch).split("\t")[0]
2829
)
2930
print(f"'{package}' remote is at commit '{remote_sha1_commit}'.")
3031
commit_string += remote_sha1_commit + "_"

0 commit comments

Comments
 (0)