|
1 | 1 | import datetime |
2 | 2 | from _operator import _SupportsComparison |
3 | 3 | from _typeshed import Incomplete, SupportsKeysAndGetItem |
4 | | -from collections.abc import Iterable |
5 | | -from typing import TypeVar |
| 4 | +from collections.abc import Callable, Iterable, Mapping |
| 5 | +from logging import Logger |
| 6 | +from typing import ClassVar, TypeVar, overload |
6 | 7 | from typing_extensions import Self |
7 | 8 |
|
8 | 9 | _RangeMapKT = TypeVar("_RangeMapKT", bound=_SupportsComparison) |
9 | 10 |
|
10 | 11 | _T = TypeVar("_T") |
11 | 12 | _VT = TypeVar("_VT") |
12 | 13 |
|
13 | | -log: Incomplete |
| 14 | +log: Logger |
14 | 15 |
|
15 | 16 | class _SimpleStruct: |
16 | 17 | def __init__(self, *args, **kw) -> None: ... |
17 | | - def field_names(self): ... |
18 | | - def __eq__(self, other): ... |
19 | | - def __ne__(self, other): ... |
| 18 | + def field_names(self) -> list[str]: ... |
| 19 | + def __eq__(self, other: object) -> bool: ... |
| 20 | + def __ne__(self, other: object) -> bool: ... |
20 | 21 |
|
21 | 22 | class SYSTEMTIME(_SimpleStruct): ... |
22 | 23 | class TIME_ZONE_INFORMATION(_SimpleStruct): ... |
23 | 24 | class DYNAMIC_TIME_ZONE_INFORMATION(_SimpleStruct): ... |
24 | 25 |
|
25 | 26 | class TimeZoneDefinition(DYNAMIC_TIME_ZONE_INFORMATION): |
26 | 27 | def __init__(self, *args, **kwargs) -> None: ... |
| 28 | + # TIME_ZONE_INFORMATION fields as obtained by __getattribute__ |
| 29 | + bias: datetime.timedelta |
| 30 | + standard_name: str |
| 31 | + standard_start: SYSTEMTIME |
| 32 | + standard_bias: datetime.timedelta |
| 33 | + daylight_name: str |
| 34 | + daylight_start: SYSTEMTIME |
| 35 | + daylight_bias: datetime.timedelta |
27 | 36 | def __getattribute__(self, attr: str): ... |
28 | 37 | @classmethod |
29 | | - def current(cls): ... |
| 38 | + def current(cls) -> tuple[int, Self]: ... |
30 | 39 | def set(self) -> None: ... |
31 | | - def copy(self): ... |
32 | | - def locate_daylight_start(self, year): ... |
33 | | - def locate_standard_start(self, year): ... |
| 40 | + def copy(self) -> Self: ... |
| 41 | + def locate_daylight_start(self, year) -> datetime.datetime: ... |
| 42 | + def locate_standard_start(self, year) -> datetime.datetime: ... |
34 | 43 |
|
35 | 44 | class TimeZoneInfo(datetime.tzinfo): |
36 | | - tzRegKey: str |
37 | | - timeZoneName: Incomplete |
38 | | - fixedStandardTime: Incomplete |
| 45 | + tzRegKey: ClassVar[str] |
| 46 | + timeZoneName: str |
| 47 | + fixedStandardTime: bool |
39 | 48 | def __init__(self, param: str | TimeZoneDefinition, fix_standard_time: bool = False) -> None: ... |
40 | | - def tzname(self, dt): ... |
41 | | - def getWinInfo(self, targetYear): ... |
42 | | - def utcoffset(self, dt): ... |
43 | | - def dst(self, dt): ... |
44 | | - def GetDSTStartTime(self, year): ... |
45 | | - def GetDSTEndTime(self, year): ... |
46 | | - def __le__(self, other) -> bool: ... |
47 | | - def __eq__(self, other) -> bool: ... |
48 | | - def __ne__(self, other) -> bool: ... |
| 49 | + @overload # type: ignore[override] # Split definition into overrides |
| 50 | + def tzname(self, dt: datetime.datetime) -> str: ... |
| 51 | + @overload |
| 52 | + def tzname(self, dt: None) -> None: ... |
| 53 | + def getWinInfo(self, targetYear: int) -> TimeZoneDefinition: ... |
| 54 | + @overload # type: ignore[override] # False-positive, our overload covers all base types |
| 55 | + def utcoffset(self, dt: None) -> None: ... |
| 56 | + @overload |
| 57 | + def utcoffset(self, dt: datetime.datetime) -> datetime.timedelta: ... |
| 58 | + @overload # type: ignore[override] # False-positive, our overload covers all base types |
| 59 | + def dst(self, dt: None) -> None: ... |
| 60 | + @overload |
| 61 | + def dst(self, dt: datetime.datetime) -> datetime.timedelta: ... |
| 62 | + def GetDSTStartTime(self, year: int) -> datetime.datetime: ... |
| 63 | + def GetDSTEndTime(self, year: int) -> datetime.datetime: ... |
| 64 | + def __eq__(self, other: object) -> bool: ... |
| 65 | + def __ne__(self, other: object) -> bool: ... |
49 | 66 | @classmethod |
50 | | - def local(cls): ... |
| 67 | + def local(cls) -> Self: ... |
51 | 68 | @classmethod |
52 | | - def utc(cls): ... |
| 69 | + def utc(cls) -> Self: ... |
53 | 70 | @staticmethod |
54 | | - def get_sorted_time_zone_names(): ... |
| 71 | + def get_sorted_time_zone_names() -> list[str]: ... |
55 | 72 | @staticmethod |
56 | | - def get_all_time_zones(): ... |
| 73 | + def get_all_time_zones() -> list[TimeZoneInfo]: ... |
57 | 74 | @staticmethod |
58 | 75 | def get_sorted_time_zones(key: Incomplete | None = ...): ... |
59 | 76 |
|
60 | | -def utcnow(): ... |
61 | | -def now(): ... |
62 | | -def GetTZCapabilities(): ... |
| 77 | +def utcnow() -> datetime.datetime: ... |
| 78 | +def now() -> datetime.datetime: ... |
| 79 | +def GetTZCapabilities() -> dict[str, bool]: ... |
63 | 80 |
|
64 | 81 | class DLLHandleCache: |
65 | | - def __getitem__(self, filename): ... |
| 82 | + def __getitem__(self, filename: str) -> int: ... |
66 | 83 |
|
67 | | -DLLCache: Incomplete |
| 84 | +DLLCache: DLLHandleCache |
68 | 85 |
|
69 | | -def resolveMUITimeZone(spec): ... |
| 86 | +def resolveMUITimeZone(spec: str) -> str | None: ... |
70 | 87 |
|
71 | 88 | class RangeMap(dict[_RangeMapKT, _VT]): |
72 | | - sort_params: Incomplete |
73 | | - match: Incomplete |
74 | | - def __init__(self, source, sort_params=..., key_match_comparator=...) -> None: ... |
| 89 | + sort_params: Mapping[str, Incomplete] |
| 90 | + match: Callable[[_RangeMapKT, _RangeMapKT], bool] |
| 91 | + def __init__( |
| 92 | + self, |
| 93 | + source: SupportsKeysAndGetItem[_RangeMapKT, _VT] | Iterable[tuple[_RangeMapKT, _VT]], |
| 94 | + sort_params: Mapping[str, Incomplete] = {}, |
| 95 | + key_match_comparator: Callable[[_RangeMapKT, _RangeMapKT], bool] = ..., |
| 96 | + ) -> None: ... |
75 | 97 | @classmethod |
76 | 98 | def left(cls, source: SupportsKeysAndGetItem[_RangeMapKT, _VT] | Iterable[tuple[_RangeMapKT, _VT]]) -> Self: ... |
77 | | - def __getitem__(self, item): ... |
78 | | - def get(self, key, default: Incomplete | None = ...): ... |
79 | | - def bounds(self): ... |
80 | | - undefined_value: Incomplete |
| 99 | + def __getitem__(self, item: _RangeMapKT) -> _VT: ... |
| 100 | + @overload # type: ignore[override] # Signature simplified over dict and Mapping |
| 101 | + def get(self, key: _RangeMapKT, default: _T) -> _VT | _T: ... |
| 102 | + @overload |
| 103 | + def get(self, key: _RangeMapKT, default: None = None) -> _VT | None: ... |
| 104 | + def bounds(self) -> tuple[_RangeMapKT, _RangeMapKT]: ... |
| 105 | + undefined_value = type("RangeValueUndefined", (), {})() |
81 | 106 |
|
82 | 107 | class Item(int): ... |
83 | | - first_item: Incomplete |
84 | | - last_item: Incomplete |
| 108 | + first_item: Item |
| 109 | + last_item: Item |
0 commit comments