Skip to content

Commit acc8e7b

Browse files
committed
Address some version/platform specific cases
1 parent 435bdcb commit acc8e7b

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

stdlib/_msi.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import sys
2+
from typing import type_check_only
23

34
if sys.platform == "win32":
45
class MSIError(Exception): ...
56
# Actual typename View, not exposed by the implementation
7+
@type_check_only
68
class _View:
79
def Execute(self, params: _Record | None = ...) -> None: ...
810
def GetColumnInfo(self, kind: int) -> _Record: ...
@@ -14,6 +16,7 @@ if sys.platform == "win32":
1416
__init__: None # type: ignore[assignment]
1517

1618
# Actual typename SummaryInformation, not exposed by the implementation
19+
@type_check_only
1720
class _SummaryInformation:
1821
def GetProperty(self, field: int) -> int | bytes | None: ...
1922
def GetPropertyCount(self) -> int: ...
@@ -24,6 +27,7 @@ if sys.platform == "win32":
2427
__init__: None # type: ignore[assignment]
2528

2629
# Actual typename Database, not exposed by the implementation
30+
@type_check_only
2731
class _Database:
2832
def OpenView(self, sql: str) -> _View: ...
2933
def Commit(self) -> None: ...
@@ -34,6 +38,7 @@ if sys.platform == "win32":
3438
__init__: None # type: ignore[assignment]
3539

3640
# Actual typename Record, not exposed by the implementation
41+
@type_check_only
3742
class _Record:
3843
def GetFieldCount(self) -> int: ...
3944
def GetInteger(self, field: int) -> int: ...

stdlib/ast.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,14 @@ if sys.version_info >= (3, 12):
16991699
self, *, name: str = ..., default_value: expr | None = ..., **kwargs: Unpack[_Attributes[int]]
17001700
) -> Self: ...
17011701

1702-
class _ABC(type):
1703-
def __init__(cls, *args: Unused) -> None: ...
1702+
if sys.version_info >= (3, 14):
1703+
@type_check_only
1704+
class _ABC(type):
1705+
def __init__(cls, *args: Unused) -> None: ...
1706+
1707+
else:
1708+
class _ABC(type):
1709+
def __init__(cls, *args: Unused) -> None: ...
17041710

17051711
if sys.version_info < (3, 14):
17061712
@deprecated("Replaced by ast.Constant; removed in Python 3.14")

stdlib/imp.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ from _imp import (
1313
from _typeshed import StrPath
1414
from os import PathLike
1515
from types import TracebackType
16-
from typing import IO, Any, Protocol
16+
from typing import IO, Any, Protocol, type_check_only
1717

1818
SEARCH_ERROR: int
1919
PY_SOURCE: int
@@ -39,6 +39,7 @@ class NullImporter:
3939

4040
# Technically, a text file has to support a slightly different set of operations than a binary file,
4141
# but we ignore that here.
42+
@type_check_only
4243
class _FileLike(Protocol):
4344
closed: bool
4445
mode: str

stdlib/sys/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ def settrace(function: TraceFunction | None, /) -> None: ...
378378
if sys.platform == "win32":
379379
# A tuple of length 5, even though it has more than 5 attributes.
380380
@final
381+
@type_check_only
381382
class _WinVersion(_UninstantiableStructseq, tuple[int, int, int, int, str]):
382383
@property
383384
def major(self) -> int: ...

0 commit comments

Comments
 (0)