diff --git a/src/audio_feeder/_compat.py b/src/audio_feeder/_compat.py index 93df4f7..fa5db20 100644 --- a/src/audio_feeder/_compat.py +++ b/src/audio_feeder/_compat.py @@ -6,6 +6,6 @@ try: from enum import StrEnum # type: ignore[attr-defined] except ImportError: - from backports.strenum import StrEnum # type: ignore[import] + from backports.strenum import StrEnum # type: ignore[import,no-redef] __all__ = ("Self", "StrEnum") diff --git a/src/audio_feeder/file_probe.py b/src/audio_feeder/file_probe.py index 8d2e4f4..121937c 100644 --- a/src/audio_feeder/file_probe.py +++ b/src/audio_feeder/file_probe.py @@ -67,6 +67,7 @@ class OverdriveMediaMarker: @classmethod def from_xml(cls, xml: str) -> typing.Sequence[Self]: root = lxml.etree.fromstring(xml) + assert isinstance(root.tag, str) if root.tag != "Markers": raise ValueError( f"Unknown media marker tag: {root.tag}. " + "Should be 'Markers'" @@ -197,6 +198,7 @@ def from_json(cls, json_dict: FFProbeReturnJSON) -> Self: if omm_tag in format_info.tags: omm_tags = OverdriveMediaMarker.from_xml(format_info.tags[omm_tag]) omm_tags = sorted(omm_tags) + assert format_info.duration is not None # TODO: Handle this gracefully for num, start_tag, end_tag in zip( itertools.count(1), diff --git a/src/audio_feeder/m4btools.py b/src/audio_feeder/m4btools.py index 312ffc3..0b3173e 100644 --- a/src/audio_feeder/m4btools.py +++ b/src/audio_feeder/m4btools.py @@ -385,7 +385,9 @@ def chapter_split_jobs( job_pool.append(new_job) - if abs(chapter.end_time - file_infos[fpath].format_info.duration) < 0.25: + duration = file_infos[fpath].format_info.duration + assert duration is not None # TODO: Handle this gracefully + if abs(chapter.end_time - duration) < 0.25: end_time = None else: end_time = chapter.end_time diff --git a/src/audio_feeder/object_handler.py b/src/audio_feeder/object_handler.py index 5fd2916..a004b36 100644 --- a/src/audio_feeder/object_handler.py +++ b/src/audio_feeder/object_handler.py @@ -50,16 +50,16 @@ class BaseObject: id: ID def to_dict(self) -> typing.Mapping[str, typing.Any]: - return attrs.asdict(self) + return attrs.asdict(self) # type: ignore[arg-type] def to_dict_sparse( self, *, _filter=_filter_sparse ) -> typing.Mapping[str, typing.Any]: - return attrs.asdict(self, filter=_filter) + return attrs.asdict(self, filter=_filter) # type: ignore[arg-type] def copy(self: Self) -> Self: """Make a new copy of this object.""" - return attrs.evolve(self) + return attrs.evolve(self) # type: ignore[misc] # SqlAlchemy has problems with slots ☹ diff --git a/src/audio_feeder/rss_feeds.py b/src/audio_feeder/rss_feeds.py index 8e6c8b9..9d35de7 100644 --- a/src/audio_feeder/rss_feeds.py +++ b/src/audio_feeder/rss_feeds.py @@ -208,9 +208,10 @@ def _executor() -> futures.Executor: file_hash = None if entry_obj.file_metadata is None or m_rel_path not in entry_obj.file_metadata: + # TODO: Use an assertion or fix fl.path possibly being None metadata_futures.append( _executor().submit( - lambda fl, fh: (fl, fp.FileInfo.from_file(fl.path), fh), + lambda fl, fh: (fl, fp.FileInfo.from_file(fl.path), fh), # type: ignore[arg-type] file_loc, file_hash, ) diff --git a/src/audio_feeder/sql_database_handler.py b/src/audio_feeder/sql_database_handler.py index f5b5efa..15c47c6 100644 --- a/src/audio_feeder/sql_database_handler.py +++ b/src/audio_feeder/sql_database_handler.py @@ -11,6 +11,7 @@ import attrs import sqlalchemy as sa +import sqlalchemy.types from sqlalchemy import orm from . import _object_types as ot diff --git a/src/audio_feeder/updater.py b/src/audio_feeder/updater.py index 90d6f76..e81d62f 100644 --- a/src/audio_feeder/updater.py +++ b/src/audio_feeder/updater.py @@ -30,7 +30,7 @@ # This technically violates PEP 484, but it works. See # https://github.com/python/mypy/issues/14023 for more details. _PBar = typing.TypeVar( - "_PBar", bound=typing.Callable[[typing.Iterable[_T]], typing.Iterable[_T]] + "_PBar", bound=typing.Callable[[typing.Iterable[_T]], typing.Iterable[_T]] # type: ignore[valid-type] ) diff --git a/tox.ini b/tox.ini index 766938b..31f9c99 100644 --- a/tox.ini +++ b/tox.ini @@ -85,7 +85,7 @@ description = Run typechecking deps = attrs click - mypy>=0.991,<1 + mypy>=0.991 types-requests types-lxml types-pyyaml