add proxy for the first part and try to develop the second part
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing_extensions import Self
|
||||
|
||||
from ._common import tzrangebase
|
||||
from .tz import (
|
||||
datetime_ambiguous as datetime_ambiguous,
|
||||
datetime_exists as datetime_exists,
|
||||
enfold as enfold,
|
||||
gettz as gettz,
|
||||
resolve_imaginary as resolve_imaginary,
|
||||
tzfile as tzfile,
|
||||
tzical as tzical,
|
||||
tzlocal as tzlocal,
|
||||
tzoffset as tzoffset,
|
||||
tzrange as tzrange,
|
||||
tzstr as tzstr,
|
||||
tzutc as tzutc,
|
||||
)
|
||||
|
||||
# UTC, tzwin, tzwinlocal are defined in this class
|
||||
# otherwise pyright complains about unknown import symbol:
|
||||
if sys.platform == "win32":
|
||||
class tzwinbase(tzrangebase):
|
||||
hasdst: bool
|
||||
def __eq__(self, other: tzwinbase) -> bool: ... # type: ignore[override]
|
||||
@staticmethod
|
||||
def list() -> list[str]: ...
|
||||
def display(self) -> str | None: ...
|
||||
def transitions(self, year: int) -> tuple[datetime, datetime] | None: ...
|
||||
|
||||
class tzwin(tzwinbase):
|
||||
hasdst: bool
|
||||
def __init__(self, name: str) -> None: ...
|
||||
def __reduce__(self) -> tuple[type[Self], tuple[str, ...]]: ... # type: ignore[override]
|
||||
|
||||
class tzwinlocal(tzwinbase):
|
||||
hasdst: bool
|
||||
def __init__(self) -> None: ...
|
||||
def __reduce__(self) -> tuple[type[Self], tuple[str, ...]]: ... # type: ignore[override]
|
||||
|
||||
else:
|
||||
tzwin: None
|
||||
tzwinlocal: None
|
||||
|
||||
UTC: tzutc
|
||||
|
||||
__all__ = [
|
||||
"tzutc",
|
||||
"tzoffset",
|
||||
"tzlocal",
|
||||
"tzfile",
|
||||
"tzrange",
|
||||
"tzstr",
|
||||
"tzical",
|
||||
"tzwin",
|
||||
"tzwinlocal",
|
||||
"gettz",
|
||||
"enfold",
|
||||
"datetime_ambiguous",
|
||||
"datetime_exists",
|
||||
"resolve_imaginary",
|
||||
"UTC",
|
||||
"DeprecatedTzFormatWarning",
|
||||
]
|
||||
|
||||
class DeprecatedTzFormatWarning(Warning): ...
|
||||
@@ -0,0 +1,32 @@
|
||||
import abc
|
||||
from datetime import datetime, timedelta, tzinfo
|
||||
from typing import ClassVar
|
||||
|
||||
ZERO: timedelta
|
||||
|
||||
__all__ = ["tzname_in_python2", "enfold"]
|
||||
|
||||
def tzname_in_python2(namefunc): ...
|
||||
def enfold(dt: datetime, fold: int = 1): ...
|
||||
|
||||
class _DatetimeWithFold(datetime):
|
||||
@property
|
||||
def fold(self): ...
|
||||
|
||||
# Doesn't actually have ABCMeta as the metaclass at runtime,
|
||||
# but mypy complains if we don't have it in the stub.
|
||||
# See discussion in #8908
|
||||
class _tzinfo(tzinfo, metaclass=abc.ABCMeta):
|
||||
def is_ambiguous(self, dt: datetime) -> bool: ...
|
||||
def fromutc(self, dt: datetime) -> datetime: ...
|
||||
|
||||
class tzrangebase(_tzinfo):
|
||||
def __init__(self) -> None: ...
|
||||
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def dst(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def tzname(self, dt: datetime | None) -> str: ...
|
||||
def fromutc(self, dt: datetime) -> datetime: ...
|
||||
def is_ambiguous(self, dt: datetime) -> bool: ...
|
||||
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||
def __ne__(self, other): ...
|
||||
__reduce__ = object.__reduce__
|
||||
@@ -0,0 +1,130 @@
|
||||
import sys
|
||||
from datetime import datetime, timedelta, tzinfo
|
||||
from typing import ClassVar, Literal, Protocol, TypeVar
|
||||
|
||||
from ..relativedelta import relativedelta
|
||||
from ._common import _tzinfo, enfold as enfold, tzrangebase
|
||||
|
||||
if sys.platform == "win32":
|
||||
from .win import tzwin as tzwin, tzwinlocal as tzwinlocal
|
||||
else:
|
||||
tzwin: None
|
||||
tzwinlocal: None
|
||||
|
||||
_DT = TypeVar("_DT", bound=datetime)
|
||||
|
||||
ZERO: timedelta
|
||||
EPOCH: datetime
|
||||
EPOCHORDINAL: int
|
||||
|
||||
class tzutc(tzinfo):
|
||||
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def dst(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def tzname(self, dt: datetime | None) -> str: ...
|
||||
def is_ambiguous(self, dt: datetime | None) -> bool: ...
|
||||
def fromutc(self, dt: _DT) -> _DT: ...
|
||||
def __eq__(self, other): ...
|
||||
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||
def __ne__(self, other): ...
|
||||
__reduce__ = object.__reduce__
|
||||
|
||||
UTC: tzutc
|
||||
|
||||
class tzoffset(tzinfo):
|
||||
def __init__(self, name, offset) -> None: ...
|
||||
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def dst(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def is_ambiguous(self, dt: datetime | None) -> bool: ...
|
||||
def tzname(self, dt: datetime | None) -> str: ...
|
||||
def fromutc(self, dt: _DT) -> _DT: ...
|
||||
def __eq__(self, other): ...
|
||||
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||
def __ne__(self, other): ...
|
||||
__reduce__ = object.__reduce__
|
||||
@classmethod
|
||||
def instance(cls, name, offset) -> tzoffset: ...
|
||||
|
||||
class tzlocal(_tzinfo):
|
||||
def __init__(self) -> None: ...
|
||||
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def dst(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def tzname(self, dt: datetime | None) -> str: ...
|
||||
def is_ambiguous(self, dt: datetime | None) -> bool: ...
|
||||
def __eq__(self, other): ...
|
||||
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||
def __ne__(self, other): ...
|
||||
__reduce__ = object.__reduce__
|
||||
|
||||
class _ttinfo:
|
||||
offset: float
|
||||
delta: timedelta
|
||||
isdst: bool
|
||||
abbr: str
|
||||
isstd: bool
|
||||
isgmt: bool
|
||||
dstoffset: timedelta
|
||||
def __init__(self) -> None: ...
|
||||
def __eq__(self, other): ...
|
||||
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||
def __ne__(self, other): ...
|
||||
|
||||
class _TZFileReader(Protocol):
|
||||
# optional attribute:
|
||||
# name: str
|
||||
def read(self, size: int, /) -> bytes: ...
|
||||
def seek(self, target: int, whence: Literal[1], /) -> object: ...
|
||||
|
||||
class tzfile(_tzinfo):
|
||||
def __init__(self, fileobj: str | _TZFileReader, filename: str | None = None) -> None: ...
|
||||
def is_ambiguous(self, dt: datetime | None, idx: int | None = None) -> bool: ...
|
||||
def utcoffset(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def dst(self, dt: datetime | None) -> timedelta | None: ...
|
||||
def tzname(self, dt: datetime | None) -> str: ...
|
||||
def __eq__(self, other): ...
|
||||
__hash__: ClassVar[None] # type: ignore[assignment]
|
||||
def __ne__(self, other): ...
|
||||
def __reduce__(self): ...
|
||||
def __reduce_ex__(self, protocol): ...
|
||||
|
||||
class tzrange(tzrangebase):
|
||||
hasdst: bool
|
||||
def __init__(
|
||||
self,
|
||||
stdabbr: str,
|
||||
stdoffset: int | timedelta | None = None,
|
||||
dstabbr: str | None = None,
|
||||
dstoffset: int | timedelta | None = None,
|
||||
start: relativedelta | None = None,
|
||||
end: relativedelta | None = None,
|
||||
) -> None: ...
|
||||
def transitions(self, year: int) -> tuple[datetime, datetime]: ...
|
||||
def __eq__(self, other): ...
|
||||
|
||||
class tzstr(tzrange):
|
||||
hasdst: bool
|
||||
def __init__(self, s: str, posix_offset: bool = False) -> None: ...
|
||||
@classmethod
|
||||
def instance(cls, name, offset) -> tzoffset: ...
|
||||
|
||||
class _ICalReader(Protocol):
|
||||
# optional attribute:
|
||||
# name: str
|
||||
def read(self) -> str: ...
|
||||
|
||||
class tzical:
|
||||
def __init__(self, fileobj: str | _ICalReader) -> None: ...
|
||||
def keys(self): ...
|
||||
def get(self, tzid=None): ...
|
||||
|
||||
TZFILES: list[str]
|
||||
TZPATHS: list[str]
|
||||
|
||||
def datetime_exists(dt: datetime, tz: tzinfo | None = None) -> bool: ...
|
||||
def datetime_ambiguous(dt: datetime, tz: tzinfo | None = None) -> bool: ...
|
||||
def resolve_imaginary(dt: datetime) -> datetime: ...
|
||||
|
||||
class _GetTZ:
|
||||
def __call__(self, name: str | None = ...) -> tzinfo | None: ...
|
||||
def nocache(self, name: str | None) -> tzinfo | None: ...
|
||||
|
||||
gettz: _GetTZ
|
||||
@@ -0,0 +1,26 @@
|
||||
import sys
|
||||
from ctypes import _Pointer, c_wchar
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, ClassVar, Final
|
||||
|
||||
from dateutil.tz import tzwin as tzwin, tzwinlocal as tzwinlocal
|
||||
|
||||
if sys.platform == "win32":
|
||||
from winreg import _KeyType
|
||||
|
||||
__all__ = ["tzwin", "tzwinlocal", "tzres"]
|
||||
|
||||
ONEWEEK: timedelta
|
||||
TZKEYNAMENT: Final[str]
|
||||
TZKEYNAME9X: Final[str]
|
||||
TZLOCALKEYNAME: Final[str]
|
||||
TZKEYNAME: Final[str]
|
||||
|
||||
class tzres:
|
||||
p_wchar: ClassVar[type[_Pointer[c_wchar]]]
|
||||
def __init__(self, tzres_loc="tzres.dll"): ...
|
||||
def load_name(self, offset): ...
|
||||
def name_from_string(self, tzname_str: str): ...
|
||||
|
||||
def picknthweekday(year: int, month: int, dayofweek: int, hour: int, minute: int, whichweek: int) -> datetime: ...
|
||||
def valuestodict(key: _KeyType) -> dict[str, Any]: ... # keys and values in dict are results of winreg.EnumValue() function
|
||||
Reference in New Issue
Block a user