Skip to content

Commit

Permalink
Cleanup mixed returns found using CodeQL
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronkollasch committed Aug 19, 2022
1 parent 8d986f0 commit 30dadc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/photomanager/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def sizeof_fmt(num: int) -> str:
return "0 bytes"
if num == 1:
return "1 byte"
return f"{num} bytes"


def path_is_relative_to(
Expand All @@ -55,7 +56,7 @@ def path_is_relative_to(
def tz_str_to_tzinfo(tz: str):
"""
Convert a timezone string (e.g. -0400) to a tzinfo
If "local", return None
If "local" or could not convert, return None
"""
if tz == "local":
return None
Expand All @@ -64,6 +65,7 @@ def tz_str_to_tzinfo(tz: str):
except ValueError:
logger = logging.getLogger(__name__)
logger.error(f"Could not parse timezone string: {tz}")
return None


class DatabaseException(PhotoManagerBaseException):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from photomanager.photofile import NAME_MAP_ENC, PhotoFile

sizeof_fmt_expected_results = [
(-1, None),
(-1, "-1 bytes"),
(0, "0 bytes"),
(1, "1 byte"),
(1023, "1023 bytes"),
Expand Down

0 comments on commit 30dadc3

Please sign in to comment.