|
1 | 1 | import types
|
2 | 2 | from contextlib import ContextDecorator
|
3 |
| -from datetime import date, datetime as datetime, time, timedelta as timedelta, tzinfo as tzinfo |
| 3 | +from datetime import date, datetime as datetime, time, timedelta as timedelta, tzinfo as tzinfo, timezone |
4 | 4 | from typing import Optional, Union, Type
|
5 | 5 |
|
| 6 | +from pytz import BaseTzInfo |
| 7 | + |
6 | 8 | _AnyTime = Union[time, datetime]
|
7 | 9 |
|
8 | 10 | class UTC(tzinfo):
|
@@ -30,10 +32,14 @@ class LocalTimezone(ReferenceLocalTimezone):
|
30 | 32 |
|
31 | 33 | utc: UTC = ...
|
32 | 34 |
|
33 |
| -def get_fixed_timezone(offset: Union[timedelta, int]) -> tzinfo: ... |
34 |
| -def get_default_timezone() -> tzinfo: ... |
| 35 | +def get_fixed_timezone(offset: Union[timedelta, int]) -> timezone: ... |
| 36 | +def get_default_timezone() -> BaseTzInfo: ... |
35 | 37 | def get_default_timezone_name() -> str: ...
|
36 |
| -def get_current_timezone() -> tzinfo: ... |
| 38 | + |
| 39 | +# Strictly speaking, it is possible to activate() a non-pytz timezone, |
| 40 | +# in which case BaseTzInfo is incorrect. However, this is unlikely, |
| 41 | +# so we use it anyway, to keep things ergonomic for most users. |
| 42 | +def get_current_timezone() -> BaseTzInfo: ... |
37 | 43 | def get_current_timezone_name() -> str: ...
|
38 | 44 | def activate(timezone: Union[tzinfo, str]) -> None: ...
|
39 | 45 | def deactivate() -> None: ...
|
|
0 commit comments