flake8-datetimez icon indicating copy to clipboard operation
flake8-datetimez copied to clipboard

pytz lint

Open kbehlers opened this issue 2 years ago • 2 comments

I'm interested in pytz linting, specifically preventing pytz timezone classes (BaseTzInfo) from being used directly as the tzinfo argument with datetime.datetime(tzinfo=) and with .replace(tzinfo=), since that is almost always an error.

Would you be open to a PR adding pytz added as a dependency and checks around those cases?

kbehlers avatar Sep 22 '22 17:09 kbehlers

You should probably avoid using pytz: https://blog.ganssle.io/articles/2018/03/pytz-fastest-footgun.html

djmattyg007 avatar Nov 12 '22 01:11 djmattyg007

@djmattyg007 Yes, I would agree 🙂 We have some legacy code in pytz that we aren't prepared to rewrite, but we also don't want any new usage of pytz sneaking into the codebase. It would be easier to enforce this with a linting rule since we can't yet remove pytz as a direct dependency and it is a downstream dependency of a lot of other packages we use at this point.

kbehlers avatar Nov 14 '22 22:11 kbehlers