Skip to content

Commit c97ade0

Browse files
committed
Fix mypy issue
1 parent 3c716c6 commit c97ade0

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

src/e3/anod/checkout.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,14 @@ def update_external(
167167
],
168168
output=PIPE,
169169
).out
170-
ignore_list = [
171-
f"/{f.strip().rstrip('/')}"
172-
for f in ignore_list_lines.splitlines()
173-
]
174-
logger.debug("Ignore in external: %s", ignore_list)
170+
if ignore_list_lines is None:
171+
ignore_list = []
172+
else:
173+
ignore_list = [
174+
f"/{f.strip().rstrip('/')}"
175+
for f in ignore_list_lines.splitlines()
176+
]
177+
logger.debug("Ignore in external: %s", ignore_list)
175178
except Exception: # defensive code
176179
# don't crash on exception
177180
pass
@@ -226,7 +229,12 @@ def update_git(
226229
# Do the remote addition manually as in that context we can ignore
227230
# safely any error returned by this command.
228231
try:
229-
remote_list = g.git_cmd(["remote"], output=PIPE).out.splitlines()
232+
output_str = g.git_cmd(["remote"], output=PIPE).out
233+
234+
remote_list = []
235+
if output_str:
236+
remote_list = output_str.splitlines()
237+
230238
if remote_name not in remote_list:
231239
g.git_cmd(["remote", "add", remote_name, url])
232240
except Exception: # defensive code

src/e3/vcs/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def describe(self, commit: str = HEAD) -> str:
187187
:raise: GitError
188188
"""
189189
p = self.git_cmd(["describe", "--always", commit], output=PIPE)
190-
return p.out.strip()
190+
return p.out.strip() # type: ignore
191191

192192
def write_local_diff(self, stream: IO[str]) -> None:
193193
"""Write local changes in the working tree in stream.
@@ -371,4 +371,4 @@ def rev_parse(self, refspec: str = HEAD) -> str:
371371
:raise: GitError
372372
"""
373373
p = self.git_cmd(["rev-parse", "--revs-only", refspec], output=PIPE, error=PIPE)
374-
return p.out.strip()
374+
return p.out.strip() # type: ignore

src/e3/vcs/svn.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,30 @@ def svn_cmd(self, cmd: SVNCmd, **kwargs: Any) -> e3.os.process.Run:
170170
)
171171
return p
172172

173-
def get_info(self, item: str) -> str:
173+
def get_info(self, item: str) -> Optional[str]:
174174
"""Return a specific item shown by svn info.
175175
176176
The --show-item option is only available from 1.9.
177177
:raise: SVNError
178178
"""
179179
info = self.svn_cmd(["info"], output=PIPE).out
180-
m = re.search(rf"^{item}: *(.*)\n", info, flags=re.M)
180+
m = re.search(rf"^{item}: *(.*)\n", info, flags=re.M) # type: ignore
181181
if m is None:
182182
logger.debug("svn info result:\n%s", info)
183183
raise SVNError(f"Cannot fetch item {item} from svn_info", origin="get_info")
184-
return m.group(1).strip()
184+
185+
return m.group(1).strip() # type: ignore
185186

186187
@property
187-
def url(self) -> str:
188+
def url(self) -> Optional[str]:
188189
"""Return the last URL used for the checkout.
189190
190191
:raise: SVNError
191192
"""
192193
return self.get_info("URL")
193194

194195
@property
195-
def current_revision(self) -> str:
196+
def current_revision(self) -> Optional[str]:
196197
"""Return the current revision.
197198
198199
:raise: SVNError
@@ -229,7 +230,9 @@ def is_clean_svn_dir(dir_path: str) -> tuple[bool, bool]:
229230
"""Return a tuple (True if dir is SVN directory, True if clean)."""
230231
if os.path.exists(os.path.join(dir_path, ".svn")):
231232
try:
232-
status = self.svn_cmd(["status"], output=PIPE).out.strip()
233+
status = self.svn_cmd(
234+
["status"], output=PIPE
235+
).out.strip() # type: ignore
233236
except SVNError: # defensive code
234237
return False, False
235238
if "warning: W" in status:

0 commit comments

Comments
 (0)