Skip to content

Commit

Permalink
Fix or ignore typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pganssle committed Nov 12, 2024
1 parent 550f882 commit 2a360ab
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/audio_feeder/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 2 additions & 0 deletions src/audio_feeder/file_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 3 additions & 1 deletion src/audio_feeder/m4btools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/audio_feeder/object_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ☹
Expand Down
3 changes: 2 additions & 1 deletion src/audio_feeder/rss_feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
1 change: 1 addition & 0 deletions src/audio_feeder/sql_database_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import attrs
import sqlalchemy as sa
import sqlalchemy.types
from sqlalchemy import orm

from . import _object_types as ot
Expand Down
2 changes: 1 addition & 1 deletion src/audio_feeder/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ description = Run typechecking
deps =
attrs
click
mypy>=0.991,<1
mypy>=0.991
types-requests
types-lxml
types-pyyaml
Expand Down

0 comments on commit 2a360ab

Please sign in to comment.