Skip to content

Commit

Permalink
Fix mypy type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronkollasch committed Nov 13, 2022
1 parent 2e661c5 commit 781252a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/photomanager/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _create(
@click.argument("paths", nargs=-1, type=click.Path())
# fmt: on
def _index(
db: Union[str, PathLike] = None,
db: Optional[Union[str, PathLike]] = None,
source: Optional[Union[str, PathLike]] = None,
file: Optional[Union[str, PathLike]] = None,
paths: Iterable[Union[str, PathLike]] = tuple(),
Expand Down
7 changes: 5 additions & 2 deletions src/photomanager/photofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def to_dict(self) -> dict:
return asdict(self)


def datetime_str_to_object(ts_str: str, tz_default: tzinfo = None) -> datetime:
def datetime_str_to_object(
ts_str: str,
tz_default: Optional[tzinfo] = None,
) -> datetime:
"""Parses a datetime string into a datetime object"""
dt = None
if "." in ts_str:
Expand All @@ -186,7 +189,7 @@ def datetime_str_to_object(ts_str: str, tz_default: tzinfo = None) -> datetime:
except ValueError:
pass # failed parsing is handled below
if dt is not None:
if dt.tzinfo is None:
if dt.tzinfo is None and tz_default is not None:
dt = dt.replace(tzinfo=tz_default)
return dt
raise ValueError(f"Could not parse datetime str: {repr(ts_str)}")
Expand Down
4 changes: 2 additions & 2 deletions src/photomanager/pyexiftool/pyexiftool_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ def make_chunk_jobs(
class AsyncExifTool(AsyncWorkerQueue):
def __init__(
self,
executable_: str = None,
executable_: str = "",
num_workers: int = os.cpu_count() or 1,
show_progress: bool = True,
batch_size: int = 20,
):
super(AsyncExifTool, self).__init__(
num_workers=num_workers, show_progress=show_progress
)
self.executable = executable if executable_ is None else executable_
self.executable = executable if not executable_ else executable_
self.running = False
self.queue = None
self.batch_size = batch_size
Expand Down

0 comments on commit 781252a

Please sign in to comment.