Skip to content

Commit f7eaab0

Browse files
committed
Fix or ignore typing issues
1 parent 178ce5e commit f7eaab0

File tree

7 files changed

+18
-13
lines changed

7 files changed

+18
-13
lines changed

src/audio_feeder/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
try:
77
from enum import StrEnum # type: ignore[attr-defined]
88
except ImportError:
9-
from backports.strenum import StrEnum # type: ignore[import]
9+
from backports.strenum import StrEnum # type: ignore[import,no-redef]
1010

1111
__all__ = ("Self", "StrEnum")

src/audio_feeder/file_probe.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class OverdriveMediaMarker:
6767
@classmethod
6868
def from_xml(cls, xml: str) -> typing.Sequence[Self]:
6969
root = lxml.etree.fromstring(xml)
70+
assert isinstance(root.tag, str)
7071
if root.tag != "Markers":
7172
raise ValueError(
7273
f"Unknown media marker tag: {root.tag}. " + "Should be 'Markers'"
@@ -197,6 +198,7 @@ def from_json(cls, json_dict: FFProbeReturnJSON) -> Self:
197198
if omm_tag in format_info.tags:
198199
omm_tags = OverdriveMediaMarker.from_xml(format_info.tags[omm_tag])
199200
omm_tags = sorted(omm_tags)
201+
assert format_info.duration is not None # TODO: Handle this gracefully
200202

201203
for num, start_tag, end_tag in zip(
202204
itertools.count(1),

src/audio_feeder/m4btools.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def _merge_subsets(
271271
"\n".join(_to_file_list_entry(x.path, x.start, x.end) for x in subsets)
272272
)
273273

274-
cmd_before = [
274+
cmd_before: Sequence[str] = (
275275
"ffmpeg",
276276
"-loglevel",
277277
"error",
@@ -289,9 +289,9 @@ def _merge_subsets(
289289
"0",
290290
"-c:a",
291291
audio_codec,
292-
]
292+
)
293293

294-
cmd_after = []
294+
cmd_after: Sequence[str] = ()
295295

296296
logging.debug("file list:\n%s", file_list.read_text())
297297
_try_video_variations(
@@ -332,7 +332,7 @@ def _extract_subset(
332332
if subset.end:
333333
subset_directives.extend(("-to", str(subset.end)))
334334

335-
cmd_before = [
335+
cmd_before: Sequence[str] = [
336336
"ffmpeg",
337337
"-loglevel",
338338
"error",
@@ -349,7 +349,7 @@ def _extract_subset(
349349
"copy",
350350
]
351351

352-
cmd_after = []
352+
cmd_after: Sequence[str] = ()
353353

354354
_try_video_variations(
355355
cmd_before,
@@ -413,7 +413,9 @@ def chapter_split_jobs(
413413

414414
job_pool.append(new_job)
415415

416-
if abs(chapter.end_time - file_infos[fpath].format_info.duration) < 0.25:
416+
duration = file_infos[fpath].format_info.duration
417+
assert duration is not None # TODO: Handle this gracefully
418+
if abs(chapter.end_time - duration) < 0.25:
417419
end_time = None
418420
else:
419421
end_time = chapter.end_time

src/audio_feeder/object_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ class BaseObject:
5050
id: ID
5151

5252
def to_dict(self) -> typing.Mapping[str, typing.Any]:
53-
return attrs.asdict(self)
53+
return attrs.asdict(self) # type: ignore[arg-type]
5454

5555
def to_dict_sparse(
5656
self, *, _filter=_filter_sparse
5757
) -> typing.Mapping[str, typing.Any]:
58-
return attrs.asdict(self, filter=_filter)
58+
return attrs.asdict(self, filter=_filter) # type: ignore[arg-type]
5959

6060
def copy(self: Self) -> Self:
6161
"""Make a new copy of this object."""
62-
return attrs.evolve(self)
62+
return attrs.evolve(self) # type: ignore[misc]
6363

6464

6565
# SqlAlchemy has problems with slots ☹

src/audio_feeder/rss_feeds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ def _executor() -> futures.Executor:
208208
file_hash = None
209209

210210
if entry_obj.file_metadata is None or m_rel_path not in entry_obj.file_metadata:
211+
# TODO: Use an assertion or fix fl.path possibly being None
211212
metadata_futures.append(
212213
_executor().submit(
213-
lambda fl, fh: (fl, fp.FileInfo.from_file(fl.path), fh),
214+
lambda fl, fh: (fl, fp.FileInfo.from_file(fl.path), fh), # type: ignore[arg-type]
214215
file_loc,
215216
file_hash,
216217
)

src/audio_feeder/updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# This technically violates PEP 484, but it works. See
3131
# https://github.com/python/mypy/issues/14023 for more details.
3232
_PBar = typing.TypeVar(
33-
"_PBar", bound=typing.Callable[[typing.Iterable[_T]], typing.Iterable[_T]]
33+
"_PBar", bound=typing.Callable[[typing.Iterable[_T]], typing.Iterable[_T]] # type: ignore[valid-type]
3434
)
3535

3636

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ description = Run typechecking
8585
deps =
8686
attrs
8787
click
88-
mypy>=0.991,<1
88+
mypy>=0.991
8989
types-requests
9090
types-lxml
9191
types-pyyaml

0 commit comments

Comments
 (0)