Skip to content

Commit

Permalink
Add suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Miauwkeru committed Oct 10, 2023
1 parent 7b9f958 commit 7d63d78
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flow/record/fieldtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from backports.zoneinfo import ZoneInfo, ZoneInfoNotFoundError
HAS_ZONE_INFO = True
except ImportError:
warnings.waring("Could not use zoneinfo, using the default timezone 'UTC'.")
HAS_ZONE_INFO = False

Check warning on line 24 in flow/record/fieldtypes/__init__.py

View check run for this annotation

Codecov / codecov/patch

flow/record/fieldtypes/__init__.py#L24

Added line #L24 was not covered by tests


Expand Down Expand Up @@ -56,13 +55,15 @@ def flow_record_tz(*, default_tz: str = "UTC") -> Optional[ZoneInfo | UTC]:
Returns:
None if ``FLOW_RECORD_TZ=NONE`` otherwise ``ZoneInfo(FLOW_RECORD_TZ)`` or ``UTC`` if ZoneInfo is not found.
"""
if not HAS_ZONE_INFO:
return UTC

tz = os.environ.get("FLOW_RECORD_TZ", default_tz)
if tz.upper() == "NONE":
return None

if not HAS_ZONE_INFO:
warnings.warn("Cannot use FLOW_RECORD_TZ due to missing zoneinfo module, defaulting to 'UTC'.")
return UTC

Check warning on line 65 in flow/record/fieldtypes/__init__.py

View check run for this annotation

Codecov / codecov/patch

flow/record/fieldtypes/__init__.py#L64-L65

Added lines #L64 - L65 were not covered by tests

try:
return ZoneInfo(tz)
except ZoneInfoNotFoundError as exc:
Expand Down

0 comments on commit 7d63d78

Please sign in to comment.