Miscellaneous type_check_only annotations (#13058)

This commit is contained in:
Stephen Morton
2024-11-21 00:41:38 -08:00
committed by GitHub
parent ae7f6ea59c
commit 0fb3a092c7
4 changed files with 12 additions and 4 deletions

View File

@@ -2,7 +2,7 @@ import sys
from _typeshed import StrOrBytesPath
from collections.abc import Iterator, MutableMapping
from types import TracebackType
from typing import Literal
from typing import Literal, type_check_only
from typing_extensions import Self, TypeAlias
__all__ = ["open", "whichdb", "error"]
@@ -89,6 +89,8 @@ class _Database(MutableMapping[_KeyType, bytes]):
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
# This class is not exposed. It calls itself dbm.error.
@type_check_only
class _error(Exception): ...
error: tuple[type[_error], type[OSError]]

View File

@@ -63,7 +63,7 @@ from sqlite3.dbapi2 import (
version_info as version_info,
)
from types import TracebackType
from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, final, overload
from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 12):
@@ -446,7 +446,9 @@ class Row(Sequence[Any]):
def __lt__(self, value: object, /) -> bool: ...
def __ne__(self, value: object, /) -> bool: ...
# This class is not exposed. It calls itself sqlite3.Statement.
@final
@type_check_only
class _Statement: ...
if sys.version_info >= (3, 11):

View File

@@ -27,7 +27,7 @@ from _ssl import (
)
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from collections.abc import Callable, Iterable
from typing import Any, Literal, NamedTuple, TypedDict, overload
from typing import Any, Literal, NamedTuple, TypedDict, overload, type_check_only
from typing_extensions import Never, Self, TypeAlias
if sys.version_info >= (3, 13):
@@ -309,6 +309,8 @@ ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE: AlertDescription
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION: AlertDescription
ALERT_DESCRIPTION_USER_CANCELLED: AlertDescription
# This class is not exposed. It calls itself ssl._ASN1Object.
@type_check_only
class _ASN1ObjectBase(NamedTuple):
nid: int
shortname: str

View File

@@ -4,7 +4,7 @@ from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from token import *
from token import EXACT_TOKEN_TYPES as EXACT_TOKEN_TYPES
from typing import Any, NamedTuple, TextIO
from typing import Any, NamedTuple, TextIO, type_check_only
from typing_extensions import TypeAlias
__all__ = [
@@ -98,6 +98,8 @@ blank_re: Pattern[bytes]
_Position: TypeAlias = tuple[int, int]
# This class is not exposed. It calls itself tokenize.TokenInfo.
@type_check_only
class _TokenInfo(NamedTuple):
type: int
string: str