Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)

This commit is contained in:
Brian Schubert
2025-08-08 05:29:48 -04:00
committed by GitHub
parent a358dc24e8
commit 81c8fcb2e6
131 changed files with 334 additions and 147 deletions
@@ -9,10 +9,6 @@ __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
+5 -1
View File
@@ -1,6 +1,6 @@
import sys
from datetime import datetime, timedelta, tzinfo
from typing import ClassVar, Literal, Protocol, TypeVar
from typing import ClassVar, Literal, Protocol, TypeVar, type_check_only
from ..relativedelta import relativedelta
from ._common import _tzinfo, enfold as enfold, tzrangebase
@@ -68,6 +68,7 @@ class _ttinfo:
__hash__: ClassVar[None] # type: ignore[assignment]
def __ne__(self, other): ...
@type_check_only
class _TZFileReader(Protocol):
# optional attribute:
# name: str
@@ -106,6 +107,7 @@ class tzstr(tzrange):
@classmethod
def instance(cls, name, offset) -> tzoffset: ...
@type_check_only
class _ICalReader(Protocol):
# optional attribute:
# name: str
@@ -123,6 +125,8 @@ 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: ...
# Singleton type defined locally in a function. Calls itself "GettzFunc".
@type_check_only
class _GetTZ:
def __call__(self, name: str | None = ...) -> tzinfo | None: ...
def nocache(self, name: str | None) -> tzinfo | None: ...