try:
import zoneinfo
except:
from backports import zoneinfo
The solution that I found to make mypy happy is: import sys
if sys.version_info >= (3, 9):
import zoneinfo
else:
from backports import zoneinfo
I have no idea why mypy is happy.If I can get type hinting to work, it does detect certain errors in certain situations. But the whole thing takes too much work. The syntax is awkward and klunky. I'm not always sure that mypy actually catches typing errors, even with the --strict flag. And Python package management is already a shit show, but when I add mypy to the mix, it spews incomprehensible error messages that I have no idea how to fix.
I'm starting to look at Golang to replace my Python usage. If I'm going to do the work of adding typing info, I'd rather do it in a language that has static type checking from the very beginning. And being able to compile down to a single binary is appealing.