Skip to content

Commit 29daeca

Browse files
authored
Merge pull request #1035 from zapta/main
Fixed a few mypy reported type errors.
2 parents fa42502 + 0eea180 commit 29daeca

5 files changed

Lines changed: 15 additions & 65 deletions

File tree

‎apio/common/apio_console.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import os
1414
import traceback
1515
from dataclasses import dataclass
16-
from typing import Optional, List, NoReturn
16+
from typing import Optional, List, NoReturn, Literal
1717
from rich.console import Console
1818
from rich.ansi import AnsiDecoder
1919
from rich.theme import Theme
@@ -107,7 +107,9 @@ def configure(
107107
terminal_mode = AUTO_TERMINAL
108108

109109
# -- Determine console color system parameter.
110-
color_system = "auto" if theme.colors_enabled else None
110+
color_system: Literal["auto"] | None = (
111+
"auto" if theme.colors_enabled else None
112+
)
111113

112114
# -- Determine console's force_terminal parameter.
113115
if terminal_mode == FORCE_TERMINAL:
@@ -285,8 +287,8 @@ def cerror(*text_lines: str) -> None:
285287

286288
def fatal_error(
287289
*error_text_lines: str,
288-
info: List[str] | str = None,
289-
cause: Exception = None,
290+
info: List[str] | str | None = None,
291+
cause: Exception | None = None,
290292
) -> NoReturn:
291293
"""Prints one or more error lines, then optional info lines, and then
292294
exists the program with an error status."""

‎apio/utils/util.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class AsyncPipe(Thread):
3636
from an internal thread. Used to process in real time scons output to
3737
show its progress."""
3838

39-
def __init__(self, line_callback=None):
39+
def __init__(self, line_callback=None) -> None:
4040
"""If line_callback is not None, it is called for each line as
4141
line_callback(line:str, terminator:str) where line is the line content
4242
and terminator is one of:
@@ -54,28 +54,28 @@ def __init__(self, line_callback=None):
5454
self._fd_read, self._fd_write = os.pipe()
5555

5656
# -- A list of lines received so far.
57-
self._lines_buffer = []
57+
self._lines_buffer: List[str] = []
5858

5959
self.start()
6060

61-
def get_buffer(self):
61+
def get_buffer(self) -> List[str]:
6262
"""DOC: TODO"""
6363

6464
return self._lines_buffer
6565

66-
def fileno(self):
66+
def fileno(self) -> int:
6767
"""DOC: TODO"""
6868

6969
return self._fd_write
7070

71-
def _handle_incoming_line(self, bfr: bytearray, terminator: str):
71+
def _handle_incoming_line(self, bfr: bytearray, terminator: str) -> None:
7272
"""Handle a new incoming line.
7373
Bfr is a bytes with the line's content, possibly empty.
7474
See __init__ for the description of terminator.
7575
"""
7676
# -- Convert the line's bytes to a string. Replace invalid utf-8
7777
# -- chars with "�"
78-
line = bfr.decode("utf-8", errors="replace")
78+
line: str = bfr.decode("utf-8", errors="replace")
7979

8080
# -- Append to the lines log buffer.
8181
self._lines_buffer.append(line)
@@ -84,7 +84,7 @@ def _handle_incoming_line(self, bfr: bytearray, terminator: str):
8484
if self.outcallback:
8585
self.outcallback(line, terminator)
8686

87-
def run(self):
87+
def run(self) -> None:
8888
"""DOC: TODO"""
8989

9090
# -- Prepare a buffer for collecting the line chars, excluding

‎scripts/diff_jsonc.py‎

Lines changed: 0 additions & 52 deletions
This file was deleted.

‎scripts/generate_commands_help.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def extract_command_list(node: dict, node_path: List[str]) -> list[List[str]]:
2525
return result
2626

2727

28-
def get_commands_list() -> List[str]:
28+
def get_commands_list() -> List[List[str]]:
2929
"""Run 'apio apio get-commands' and extract the commands list."""
3030

3131
# -- Get the command hierarchy as a JSON doc.

‎tasks.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def clean_task(_: Context):
253253
assert isinstance(repo_root, Path)
254254

255255
# -- Collect items to delete.
256-
items = []
256+
items: List[Path] = []
257257
# -- Collect top level items first so they will be deleted first.
258258
items.extend(repo_root.glob(".tox"))
259259
items.extend(repo_root.glob("_site"))

0 commit comments

Comments
 (0)