Created
November 17, 2024 19:57
-
-
Save foxmask/a26f0c171e4a4ba1737ff7d2eb0e7611 to your computer and use it in GitHub Desktop.
mypy Unsupported operand types for + ("str" and "timedelta") [operator]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maillepaille.py:10: error: Incompatible types in assignment (expression has type "datetime", variable has type "str") [assignment] | |
maillepaille.py:15: error: Incompatible types in assignment (expression has type "date", variable has type "str") [assignment] | |
maillepaille.py:17: error: Incompatible types in assignment (expression has type "datetime", variable has type "str") [assignment] | |
maillepaille.py:19: error: Unsupported operand types for + ("str" and "timedelta") [operator] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date, datetime, timedelta, timezone | |
import pytz | |
yesterday = "" | |
now = datetime.now(tz=pytz.timezone("Europe/London")) | |
today = date.today() | |
if yesterday: | |
yesterday = datetime.strptime(yesterday, "%Y-%m-%d").replace(tzinfo=timezone.utc) | |
start_of_day = yesterday | |
else: | |
yesterday = today - timedelta(days=1, seconds=-1) | |
start_of_day = datetime(now.year, now.month, now.day) | |
end_of_day = start_of_day + timedelta(days=1, seconds=-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nomme la variable différement quand c'est une chaîne et une date alors, ça aidera mypy à suivre.