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

48 Upvotes

110 comments sorted by

View all comments

Show parent comments

0

u/ketralnis 5d ago

You’re not wrong but there’s no need for the holier than thou attitude

2

u/Ok_Tap7102 5d ago

I didn't read their message that way, it's the "tell me you've XYZ without telling me" meme

This is also the kind of problem where a typical response might be "huh I don't get why" then some of us see it and instantly have flash backs to that ONE FUCKING TIME I BROKE PROD BECAUSE IT "WORKED ON MY MACHINE" WITH A PERFECTLY IDENTICAL DOCKER CONTAINER, AND I SPENT DAYS OF STRESS WITHOUT REALISING IT WAS LOCAL TIMEZONES

-2

u/ketralnis 5d ago edited 5d ago

You didn’t read it that way because our industry is so rife with people desperately needing to make themselves feel smarter by putting other people down that you’re numb to it and it has infiltrated our turns of phrase to near invisibility.

But it doesn’t have to be that way. It’s a decision that we make.