Skip to content

Commit 6390ad1

Browse files
Fix Python 3.14 compatibility in AutoInit class annotations handling
Co-authored-by: cloneofghosts <10248058+cloneofghosts@users.noreply.github.com>
1 parent 0e57d59 commit 6390ad1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pirate_weather/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ class AutoInit:
3030
def __init__(self, **params):
3131
try:
3232
timezone = pytz.timezone(params.pop("timezone", None))
33-
except (pytz.UnknownTimeZoneError, AttributeError):
33+
except (pytz.UnknownTimeZoneError, AttributeError, TypeError):
3434
timezone = pytz.UTC
3535

36-
for field in self.__annotations__:
36+
for field in getattr(self.__class__, '__annotations__', {}):
3737
api_field = undo_snake_case_key(field)
38-
if self.__annotations__[field] == datetime:
38+
annotations = getattr(self.__class__, '__annotations__', {})
39+
if annotations.get(field) == datetime:
3940
params[api_field] = get_datetime_from_unix(
4041
params.get(api_field), timezone
4142
)

0 commit comments

Comments
 (0)