-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
bugSomething isn't workingSomething isn't working
Description
PEP 695, Python 3.12+
This function gives 2 errors
def strip_utc[T](obj: T) -> T:
"""Remove UTC from datetime objects inside lists or dicts."""
if isinstance(obj, datetime):
return obj.replace(tzinfo=None) # <<<<<<<<<<<<<<<<
if isinstance(obj, list):
return cast(
T,
[strip_utc(i) if isinstance(i, list | dict | datetime) else i for i in obj],
)
if isinstance(obj, dict):
res = dict.copy(obj)
for k, v in res.items():
if isinstance(v, list | dict | datetime):
res[k] = strip_utc(v)
return res # <<<<<<<<<<<<<<<<<<<<<<<<<<
return objerror: Incompatible return value type (got "datetime", expected "T") [return-value]
error: Incompatible return value type (got "dict[Any, list | dict | datetime]", expected "T") [return-value]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working