Skip to content

Commit 2839fd5

Browse files
Add @type_check_only to stub-only private classes in stdlib, round 2 (#15515)
1 parent eca2ee5 commit 2839fd5

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

stdlib/importlib/metadata/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ from importlib.abc import MetaPathFinder
1010
from os import PathLike
1111
from pathlib import Path
1212
from re import Pattern
13-
from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload
13+
from typing import Any, ClassVar, Generic, NamedTuple, TypeVar, overload, type_check_only
1414
from typing_extensions import Self, TypeAlias, deprecated, disjoint_base
1515

1616
_T = TypeVar("_T")
@@ -54,6 +54,7 @@ elif sys.version_info >= (3, 11):
5454

5555
_EntryPointBase = DeprecatedTuple
5656
else:
57+
@type_check_only
5758
class _EntryPointBase(NamedTuple):
5859
name: str
5960
value: str

stdlib/statistics.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from _typeshed import SupportsRichComparisonT
33
from collections.abc import Callable, Hashable, Iterable, Sequence, Sized
44
from decimal import Decimal
55
from fractions import Fraction
6-
from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeVar
6+
from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeVar, type_check_only
77
from typing_extensions import Self, TypeAlias
88

99
__all__ = [
@@ -44,7 +44,9 @@ _Seed: TypeAlias = int | float | str | bytes | bytearray # noqa: Y041
4444
# Used in linear_regression
4545
_T_co = TypeVar("_T_co", covariant=True)
4646

47+
@type_check_only
4748
class _SizedIterable(Iterable[_T_co], Sized, Protocol[_T_co]): ...
49+
4850
class StatisticsError(ValueError): ...
4951

5052
if sys.version_info >= (3, 11):

stdlib/tkinter/ttk.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ _VsapiStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], int]
5757
_P = ParamSpec("_P")
5858
_T = TypeVar("_T")
5959

60+
@type_check_only
6061
class _Layout(TypedDict, total=False):
6162
side: Literal["left", "right", "top", "bottom"]
6263
sticky: str # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty
@@ -68,6 +69,7 @@ class _Layout(TypedDict, total=False):
6869
_LayoutSpec: TypeAlias = list[tuple[str, _Layout | None]]
6970

7071
# Keep these in sync with the appropriate methods in Style
72+
@type_check_only
7173
class _ElementCreateImageKwargs(TypedDict, total=False):
7274
border: _Padding
7375
height: float | str
@@ -82,12 +84,15 @@ _ElementCreateArgsCrossPlatform: TypeAlias = (
8284
| tuple[Literal["from"], str] # (fromelement is optional)
8385
)
8486
if sys.platform == "win32" and sys.version_info >= (3, 13):
87+
@type_check_only
8588
class _ElementCreateVsapiKwargsPadding(TypedDict, total=False):
8689
padding: _Padding
8790

91+
@type_check_only
8892
class _ElementCreateVsapiKwargsMargin(TypedDict, total=False):
8993
padding: _Padding
9094

95+
@type_check_only
9196
class _ElementCreateVsapiKwargsSize(TypedDict):
9297
width: float | str
9398
height: float | str

0 commit comments

Comments
 (0)