Skip to content

Commit 2a360ab

Browse files
committed
Fix or ignore typing issues
1 parent 550f882 commit 2a360ab

File tree

8 files changed

+14
-8
lines changed

8 files changed

+14
-8
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ def chapter_split_jobs(
385385

386386
job_pool.append(new_job)
387387

388-
if abs(chapter.end_time - file_infos[fpath].format_info.duration) < 0.25:
388+
duration = file_infos[fpath].format_info.duration
389+
assert duration is not None # TODO: Handle this gracefully
390+
if abs(chapter.end_time - duration) < 0.25:
389391
end_time = None
390392
else:
391393
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/sql_database_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import attrs
1313
import sqlalchemy as sa
14+
import sqlalchemy.types
1415
from sqlalchemy import orm
1516

1617
from . import _object_types as ot

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)