Skip to content

Commit ffdcfc9

Browse files
committed
fixed pyright issues
1 parent 859fcd1 commit ffdcfc9

6 files changed

Lines changed: 36 additions & 30 deletions

File tree

progressbar/multi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def update(force=True, write=True): # pragma: no cover
227227
self._label_bar(bar_)
228228
bar_.update(force=force)
229229
if write:
230-
yield bar_.fd.line
230+
yield typing.cast(
231+
stream.LastLineStream, bar_.fd).line
231232

232233
if bar_.finished():
233234
yield from self._render_finished_bar(bar_, now, expired, update)

progressbar/terminal/base.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def clear_line(n):
145145
class _CPR(str): # pragma: no cover
146146
_response_lock = threading.Lock()
147147

148-
def __call__(self, stream):
149-
res = ''
148+
def __call__(self, stream) -> tuple[int, int]:
149+
res : str = ''
150150

151151
with self._response_lock:
152152
stream.write(str(self))
@@ -158,14 +158,17 @@ def __call__(self, stream):
158158
if char is not None:
159159
res += char
160160

161-
res = res[2:-1].split(';')
161+
res_list = res[2:-1].split(';')
162162

163-
res = tuple(int(item) if item.isdigit() else item for item in res)
163+
res_list = tuple(int(item)
164+
if item.isdigit()
165+
else item
166+
for item in res_list)
164167

165-
if len(res) == 1:
166-
return res[0]
168+
if len(res_list) == 1:
169+
return types.cast(tuple[int, int], res_list[0])
167170

168-
return res
171+
return types.cast(tuple[int, int], tuple(res_list))
169172

170173
def row(self, stream):
171174
row, _ = self(stream)
@@ -491,7 +494,7 @@ def _start_template(self):
491494
def _end_template(self):
492495
return super().__call__(self._end_code)
493496

494-
def __call__(self, text):
497+
def __call__(self, text, *args):
495498
return self._start_template + text + self._end_template
496499

497500

progressbar/terminal/stream.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ def flush(self) -> None:
2424
def isatty(self) -> bool:
2525
return self.stream.isatty()
2626

27-
def read(self, __n: int = -1) -> typing.AnyStr:
27+
def read(self, __n: int = -1) -> str:
2828
return self.stream.read(__n)
2929

3030
def readable(self) -> bool:
3131
return self.stream.readable()
3232

33-
def readline(self, __limit: int = -1) -> typing.AnyStr:
33+
def readline(self, __limit: int = -1) -> str:
3434
return self.stream.readline(__limit)
3535

36-
def readlines(self, __hint: int = -1) -> list[typing.AnyStr]:
36+
def readlines(self, __hint: int = -1) -> list[str]:
3737
return self.stream.readlines(__hint)
3838

3939
def seek(self, __offset: int, __whence: int = 0) -> int:
@@ -51,13 +51,13 @@ def truncate(self, __size: int | None = None) -> int:
5151
def writable(self) -> bool:
5252
return self.stream.writable()
5353

54-
def writelines(self, __lines: Iterable[typing.AnyStr]) -> None:
54+
def writelines(self, __lines: Iterable[str]) -> None:
5555
return self.stream.writelines(__lines)
5656

57-
def __next__(self) -> typing.AnyStr:
57+
def __next__(self) -> str:
5858
return self.stream.__next__()
5959

60-
def __iter__(self) -> Iterator[typing.AnyStr]:
60+
def __iter__(self) -> Iterator[str]:
6161
return self.stream.__iter__()
6262

6363
def __exit__(
@@ -94,27 +94,27 @@ def write(self, data):
9494

9595

9696
class LastLineStream(TextIOOutputWrapper):
97-
line: typing.AnyStr = ''
97+
line: str = ''
9898

9999
def seekable(self) -> bool:
100100
return False
101101

102102
def readable(self) -> bool:
103103
return True
104104

105-
def read(self, __n: int = -1) -> typing.AnyStr:
105+
def read(self, __n: int = -1) -> str:
106106
if __n < 0:
107107
return self.line
108108
else:
109109
return self.line[:__n]
110110

111-
def readline(self, __limit: int = -1) -> typing.AnyStr:
111+
def readline(self, __limit: int = -1) -> str:
112112
if __limit < 0:
113113
return self.line
114114
else:
115115
return self.line[:__limit]
116116

117-
def write(self, data: typing.AnyStr) -> int:
117+
def write(self, data: str) -> int:
118118
self.line = data
119119
return len(data)
120120

@@ -126,11 +126,11 @@ def truncate(self, __size: int | None = None) -> int:
126126

127127
return len(self.line)
128128

129-
def __iter__(self) -> typing.Generator[typing.AnyStr, typing.Any,
129+
def __iter__(self) -> typing.Generator[str, typing.Any,
130130
typing.Any]:
131131
yield self.line
132132

133-
def writelines(self, __lines: Iterable[typing.AnyStr]) -> None:
133+
def writelines(self, __lines: Iterable[str]) -> None:
134134
line = ''
135135
# Walk through the lines and take the last one
136136
for line in __lines: # noqa: B007

progressbar/widgets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,11 +1470,11 @@ class JobStatusBar(Bar, VariableMixin):
14701470
failure_marker: The marker to use for failed jobs.
14711471
'''
14721472

1473-
success_fg_color: terminal.OptionalColor | None = colors.green
1474-
success_bg_color: terminal.OptionalColor | None = None
1473+
success_fg_color: terminal.Color | None = colors.green
1474+
success_bg_color: terminal.Color | None = None
14751475
success_marker: str = '█'
1476-
failure_fg_color: terminal.OptionalColor | None = colors.red
1477-
failure_bg_color: terminal.OptionalColor | None = None
1476+
failure_fg_color: terminal.Color | None = colors.red
1477+
failure_bg_color: terminal.Color | None = None
14781478
failure_marker: str = 'X'
14791479
job_markers: list[str]
14801480

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,10 @@ exclude_lines = [
181181
'if types.TYPE_CHECKING:',
182182
'@typing.overload',
183183
]
184+
185+
[tool.pyright]
186+
include= ['progressbar']
187+
exclude= ['examples']
188+
ignore= ['docs']
189+
190+
reportIncompatibleMethodOverride = false

pyrightconfig.json

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

0 commit comments

Comments
 (0)