-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
The new release of mypy 1.0.0 exposed a problem in the typing of this module.
The issue
Consider the following code:
from backports.zoneinfo import ZoneInfo
tzinfo = ZoneInfo("Pacific/Rarotonga") # Type errorType-checking this with mypy will result in the following error:
repro.py:3: error: Cannot instantiate abstract class "ZoneInfo" with abstract attributes "dst", "tzname" and "utcoffset" [abstract]
The solution
After some investigation, I noticed that the type stub file of backports.zoneinfo does not contain type information for the abstract methods of ZoneInfo. The solution would be to add types for these methods.
I don't mind making a PR for this if you want to make a new release including this fix. Let me know.
The workaround
A workaround for dealing with this issue is to import ZoneInfo from the submodule directly:
from backports.zoneinfo._zoneinfo import ZoneInfo
tzinfo = ZoneInfo("Pacific/Rarotonga") # OKYevheniiSemendiak, calebho, andersk, osheroff, Melebius and 1 morealexander-beedie
Metadata
Metadata
Assignees
Labels
No labels