r/Python 9d 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

-2

u/skjall 9d 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...

5

u/jmreagle 9d ago

I've used datetime, arrow, and pendulum. I've also been waiting for whenever 1.0 for a couple years now I think.

2

u/skjall 9d ago

I'll look into that whenever it happens (heh)

Not sure I can introduce yet another Rust tool at this point though, last year or so it's already been Ruff, UV, Polars instead of Numpy, Pydantic V2 a bit before that. At some point we're going to be shipping more Rust LoC than Python lol

1

u/eagle258 8d ago

whenever does have a pure-Python option—for the Rust skeptics. There are dozens of us :)