Код: Выделить всё
from datetime import datetime
def tle_request(date_time: list[int]) -> datetime:
# Attempting to create a datetime object using unpacking
general_date: datetime = datetime(date_time[0], date_time[1], date_time[2]) # This causes a mypy error
return general_date
# Example usage
my_time = tle_request([2023, 9, 27])
print(f"Hello {my_time}")
Код: Выделить всё
❯ python main.py
Hello 2023-09-27 00:00:00
Код: Выделить всё
mypyКод: Выделить всё
❯ mypy main.py
main.py:5: error: Argument 1 to "datetime" has incompatible type "*list[int]"; expected "tzinfo | None" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Код: Выделить всё
❯ mypy main.py
Success: no issues found in 1 source file
Подробнее здесь: https://stackoverflow.com/questions/790 ... -unpacking