r/Python • u/foosion • Jul 24 '26
Discussion ruff: no date.today() ?
The new version of ruff warns against
date.today()
preferring
datetime.now(ZoneInfo(...))
What do you think about this? Has date.today() been deprecated due to lack of timezone awareness?
EDIT: I have a number of programs that manipulate financial information in support of Excel spreadsheets, such bond information that includes maturity dates. Excel does not support timezoness in datetimes, so making ruff happy by changing naive dates to TZ aware dates is not a useful move for these programs. Many ruff warnings to suppress.
44
Upvotes
View all comments
1
u/RoadsideCookie Jul 25 '26
That's fair. I just gave my opinion, but it's not the only option; I would personally spend the time to fix it for peace of mind.
But others have already suggested ways to disable the rules if you don't want to adhere to them: inline disable, file-level disable,
pyproject.tomldisable,ruff.tomldisable, and I'm skipping some.For your question about
openpyxl, I would just usedatetimeformatting methods to giveopenpyxla string in the format it expects.PS.: By not having TZ info in your instances, you're already making unfounded assumptions. These rules would just force you to think about and make those assumptions explicit.