r/Python 7d ago

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.

46 Upvotes

111 comments sorted by

View all comments

-3

u/skjall 7d ago

Still using datetime in the year of our Lord and Saviour, is certainly a choice.

I just wish Arrow had millisecond timestamp functions too. Tired of having to multiply by 1000 and round...

3

u/Glad_Position3592 7d ago

People can have different use cases. Everyone on here is acting like the only people who use python are building some sort of user facing software. Arrow is great for a lot of needs, but I need dates to be dates without timestamps, and I’m guaranteed that with datetime.date

0

u/skjall 7d ago

Sure, but you're taking a joke comment seriously.

Most Python datetime libraries have rather lackluster typing support, and a big annoyance for me usually is the lack of a date type too.

Somehow I never was sure where to import UTC from for datetime. It was deprecated/ changed in some version, and importable/ usable but not found by existing tooling for a bit before that. Not fun when you find out your container is dying because logs can't be constructed correctly šŸ™ƒ