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
@@ -1,8 +1,9 @@
from collections.abc import Callable
from typing import Protocol
from typing import Protocol, type_check_only
from authlib.oauth2.rfc6749 import ClientMixin
@type_check_only
class _TokenGenerator(Protocol):
def __call__(self, *, client: ClientMixin, grant_type: str, user, scope: str) -> str: ...
+2 -1
View File
@@ -2,7 +2,7 @@ from collections.abc import Iterable
from datetime import timedelta
from logging import Logger
from re import Match, Pattern
from typing import Any, Final, Literal, TypedDict, TypeVar, overload
from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
import flask
@@ -11,6 +11,7 @@ _IterableT = TypeVar("_IterableT", bound=Iterable[Any])
_T = TypeVar("_T")
_MultiDict: TypeAlias = Any # werkzeug is not part of typeshed
@type_check_only
class _Options(TypedDict, total=False):
resources: dict[str, dict[str, Any]] | list[str] | str | None
origins: str | list[str] | None
@@ -5,7 +5,7 @@ from _typeshed import StrPath, SupportsFlush, SupportsKeysAndGetItem, SupportsWr
from argparse import Namespace
from collections.abc import Callable, Iterable, Sequence
from logging import Logger
from typing import Any, Protocol, TypeVar
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import ParamSpec, TypeAlias
import flask
@@ -20,6 +20,7 @@ _AlembicConfigValue: TypeAlias = Any
alembic_version: tuple[int, int, int]
log: Logger
@type_check_only
class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol): ...
class Config: # should inherit from alembic.config.Config which is not possible yet
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from collections.abc import Callable
from logging import Logger
from threading import Thread
from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload
from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, TypeAlias, Unpack
from flask import Flask
@@ -16,12 +16,15 @@ _R_co = TypeVar("_R_co", covariant=True)
_ExceptionHandler: TypeAlias = Callable[[BaseException], _R_co]
_Handler: TypeAlias = Callable[_P, _R_co]
@type_check_only
class _HandlerDecorator(Protocol):
def __call__(self, handler: _Handler[_P, _R_co]) -> _Handler[_P, _R_co]: ...
@type_check_only
class _ExceptionHandlerDecorator(Protocol):
def __call__(self, exception_handler: _ExceptionHandler[_R_co]) -> _ExceptionHandler[_R_co]: ...
@type_check_only
class _SocketIOServerOptions(TypedDict, total=False):
client_manager: Incomplete
logger: Logger | bool
@@ -29,6 +32,7 @@ class _SocketIOServerOptions(TypedDict, total=False):
async_handlers: bool
always_connect: bool
@type_check_only
class _EngineIOServerConfig(TypedDict, total=False):
async_mode: Literal["threading", "eventlet", "gevent", "gevent_uwsgi"]
ping_interval: float | tuple[float, float] # seconds
@@ -43,6 +47,7 @@ class _EngineIOServerConfig(TypedDict, total=False):
monitor_clients: bool
engineio_logger: Logger | bool
@type_check_only
class _SocketIOKwargs(_SocketIOServerOptions, _EngineIOServerConfig): ...
class SocketIO:
@@ -1,10 +1,11 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Any, Protocol, TypeVar
from typing import Any, Protocol, TypeVar, type_check_only
_T = TypeVar("_T")
# at runtime, socketio.namespace.BaseNamespace, but socketio isn't py.typed
@type_check_only
class _BaseNamespace(Protocol):
def is_asyncio_based(self) -> bool: ...
def trigger_event(self, event: str, *args): ...
@@ -1,9 +1,10 @@
from _typeshed import Incomplete
from typing import Any, TypedDict
from typing import Any, TypedDict, type_check_only
from flask import Flask
from flask.testing import FlaskClient
@type_check_only
class _Packet(TypedDict):
name: str
args: Any
+3 -1
View File
@@ -1,6 +1,6 @@
from _typeshed import Unused
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from typing import Any, Final, Literal, NoReturn, overload
from typing import Any, Final, Literal, NoReturn, overload, type_check_only
from typing_extensions import Self
import numpy
@@ -11,6 +11,7 @@ from numpy.typing import NDArray
# Actual type: _cffi_backend.__CDataOwn <cdata 'struct _jack_position *'>
# This is not a real subclassing. Just ensuring type-checkers sees this type as compatible with _CDataBase
# pyright has no error code for subclassing final
@type_check_only
class _JackPositionT(_CDataBase): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
audio_frames_per_video_frame: float
bar: int
@@ -33,6 +34,7 @@ class _JackPositionT(_CDataBase): # type: ignore[misc] # pyright: ignore[repor
valid: int
video_offset: int
@type_check_only
class _CBufferType:
@overload
def __getitem__(self, key: int) -> str: ...
+3 -1
View File
@@ -1,6 +1,6 @@
from collections.abc import Iterator, MutableSet
from re import Pattern
from typing import Any, TypedDict
from typing import Any, TypedDict, type_check_only
from typing_extensions import deprecated
from xml.etree.ElementTree import Element
@@ -10,11 +10,13 @@ from markdown.treeprocessors import Treeprocessor
IDCOUNT_RE: Pattern[str]
@type_check_only
class _FlatTocToken(TypedDict):
level: int
id: str
name: str
@type_check_only
class _TocToken(_FlatTocToken):
children: list[_TocToken]
+2 -1
View File
@@ -1,7 +1,7 @@
import sys
from collections.abc import Iterator
from re import Pattern
from typing import Final, Generic, TypedDict, TypeVar, overload
from typing import Final, Generic, TypedDict, TypeVar, overload, type_check_only
from markdown.core import Markdown
@@ -40,6 +40,7 @@ class Processor:
md: Markdown
def __init__(self, md: Markdown | None = None) -> None: ...
@type_check_only
class _TagData(TypedDict):
tag: str
attrs: dict[str, str]
+2 -1
View File
@@ -1,5 +1,5 @@
from collections.abc import Callable
from typing import Any, NoReturn, Protocol, TypeVar
from typing import Any, NoReturn, Protocol, TypeVar, type_check_only
from yaml.error import YAMLError
@@ -7,6 +7,7 @@ from .events import Event
_T_contra = TypeVar("_T_contra", str, bytes, contravariant=True)
@type_check_only
class _WriteStream(Protocol[_T_contra]):
def write(self, data: _T_contra, /) -> object: ...
# Optional fields:
+2 -1
View File
@@ -1,10 +1,11 @@
from collections.abc import Iterator, Mapping, Set as AbstractSet
from typing import TypedDict
from typing import TypedDict, type_check_only
from pygments.token import _TokenType
ansicolors: AbstractSet[str] # not intended to be mutable
@type_check_only
class _StyleDict(TypedDict):
color: str | None
bold: bool
+3 -1
View File
@@ -1,6 +1,6 @@
from builtins import type as _type # type is being shadowed in Field
from collections.abc import Callable, Iterable, Sequence
from typing import Any, Generic, Protocol, TypeVar, overload
from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from markupsafe import Markup
@@ -16,9 +16,11 @@ _FieldT_contra = TypeVar("_FieldT_contra", bound=Field, contravariant=True)
# trust, that people won't use it to change the type of data in a field...
_Filter: TypeAlias = Callable[[Any], Any]
@type_check_only
class _Validator(Protocol[_FormT_contra, _FieldT_contra]):
def __call__(self, form: _FormT_contra, field: _FieldT_contra, /) -> object: ...
@type_check_only
class _Widget(Protocol[_FieldT_contra]):
def __call__(self, field: _FieldT_contra, **kwargs: Any) -> Markup: ...
+2 -1
View File
@@ -1,6 +1,6 @@
from _typeshed import SupportsItems
from collections.abc import Iterable, Iterator, Mapping, Sequence
from typing import Any, ClassVar, Protocol, TypeVar, overload
from typing import Any, ClassVar, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from wtforms.fields.core import Field, UnboundField
@@ -12,6 +12,7 @@ _FormErrors: TypeAlias = dict[str, Sequence[str] | _FormErrors]
# _unbound_fields will always be a list on an instance, but on a
# class it might be None, if it never has been instantiated, or
# not instantianted after a new field had been added/removed
@type_check_only
class _UnboundFields(Protocol):
@overload
def __get__(self, obj: None, owner: type[object] | None = None, /) -> list[tuple[str, UnboundField[Any]]] | None: ...
+2 -1
View File
@@ -1,9 +1,10 @@
from collections.abc import Callable, Iterable
from gettext import GNUTranslations
from typing import Protocol, TypeVar, overload
from typing import Protocol, TypeVar, overload, type_check_only
_T = TypeVar("_T")
@type_check_only
class _SupportsUgettextAndUngettext(Protocol):
def ugettext(self, string: str, /) -> str: ...
def ungettext(self, singular: str, plural: str, n: int, /) -> str: ...
+5 -1
View File
@@ -1,6 +1,6 @@
from _typeshed import SupportsItems
from collections.abc import Collection, Iterator, MutableMapping
from typing import Any, Literal, Protocol, TypeVar, overload
from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from markupsafe import Markup
@@ -9,6 +9,7 @@ from wtforms.form import BaseForm
_FieldT = TypeVar("_FieldT", bound=Field)
@type_check_only
class _SupportsGettextAndNgettext(Protocol):
def gettext(self, string: str, /) -> str: ...
def ngettext(self, singular: str, plural: str, n: int, /) -> str: ...
@@ -16,6 +17,7 @@ class _SupportsGettextAndNgettext(Protocol):
# these are the methods WTForms depends on, the dict can either provide
# a getlist or getall, if it only provides getall, it will wrapped, to
# provide getlist instead
@type_check_only
class _MultiDictLikeBase(Protocol):
def __iter__(self) -> Iterator[str]: ...
def __len__(self) -> int: ...
@@ -24,9 +26,11 @@ class _MultiDictLikeBase(Protocol):
# since how file uploads are represented in formdata is implementation-specific
# we have to be generous in what we accept in the return of getlist/getall
# we can make this generic if we ever want to be more specific
@type_check_only
class _MultiDictLikeWithGetlist(_MultiDictLikeBase, Protocol):
def getlist(self, key: str, /) -> list[Any]: ...
@type_check_only
class _MultiDictLikeWithGetall(_MultiDictLikeBase, Protocol):
def getall(self, key: str, /) -> list[Any]: ...
+2 -1
View File
@@ -1,6 +1,6 @@
from _typeshed import SupportsItems
from collections.abc import Callable, Iterable, Iterator, Sequence
from typing import Any, Literal, NamedTuple, Protocol, TypeVar, overload
from typing import Any, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from webob._types import AsymmetricPropertyWithDelete
@@ -9,6 +9,7 @@ _T = TypeVar("_T")
_ListOrTuple: TypeAlias = list[_T] | tuple[_T, ...]
_ParsedAccept: TypeAlias = tuple[str, float, list[tuple[str, str]], list[str | tuple[str, str]]]
@type_check_only
class _SupportsStr(Protocol):
def __str__(self) -> str: ... # noqa: Y029
+2 -1
View File
@@ -3,7 +3,7 @@ from _typeshed.wsgi import WSGIEnvironment
from collections.abc import Collection, ItemsView, Iterator, KeysView, MutableMapping, ValuesView
from datetime import date, datetime, timedelta
from time import _TimeTuple, struct_time
from typing import Any, Literal, Protocol, TypeVar, overload
from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from webob._types import AsymmetricProperty
@@ -26,6 +26,7 @@ _T = TypeVar("_T")
# valid spellings, but it seems more natural to support these two spellings
_SameSitePolicy: TypeAlias = Literal["Strict", "Lax", "None", "strict", "lax", "none"]
@type_check_only
class _Serializer(Protocol):
def dumps(self, appstruct: Any, /) -> bytes: ...
def loads(self, bstruct: bytes, /) -> Any: ...
+2 -1
View File
@@ -1,6 +1,6 @@
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from collections.abc import Callable, Iterable, Mapping
from typing import Any, Generic, overload
from typing import Any, Generic, overload, type_check_only
from typing_extensions import Concatenate, Never, ParamSpec, Self, TypeAlias, TypeVar
from webob.request import BaseRequest, Request
@@ -145,6 +145,7 @@ class wsgify(Generic[_P, _RequestT_contra]):
cls, middle_func: _MiddlewareMethod[_RequestT, _AppT, _P2], app: _AppT, *_: _P2.args, **kw: _P2.kwargs
) -> type[wsgify[Concatenate[_AppT, _P2], _RequestT]]: ...
@type_check_only
class _unbound_wsgify(wsgify[_P, _RequestT_contra], Generic[_P, _S, _RequestT_contra]):
@overload # type: ignore[override]
def __call__(self, __self: _S, env: WSGIEnvironment, /, start_response: StartResponse) -> Iterable[bytes]: ...
+2 -1
View File
@@ -2,7 +2,7 @@ from _typeshed import SupportsItems, SupportsKeysAndGetItem
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from collections.abc import Iterable
from string import Template
from typing import Any, Literal, Protocol
from typing import Any, Literal, Protocol, type_check_only
from typing_extensions import Self, TypeAlias
from webob.response import Response
@@ -68,6 +68,7 @@ __all__ = [
_Headers: TypeAlias = SupportsItems[str, str] | SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]]
@type_check_only
class _JSONFormatter(Protocol):
def __call__(self, *, body: str, status: str, title: str, environ: WSGIEnvironment) -> Any: ...
+2 -1
View File
@@ -1,7 +1,7 @@
from _typeshed import SupportsKeysAndGetItem
from _typeshed.wsgi import WSGIEnvironment
from collections.abc import Collection, Iterable, Iterator, MutableMapping
from typing import Literal, Protocol, TypeVar, overload
from typing import Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self
from webob.compat import cgi_FieldStorage, cgi_FieldStorage as _FieldStorageWithFile
@@ -14,6 +14,7 @@ _VT = TypeVar("_VT")
_KT_co = TypeVar("_KT_co", covariant=True)
_VT_co = TypeVar("_VT_co", covariant=True)
@type_check_only
class _SupportsItemsWithIterableResult(Protocol[_KT_co, _VT_co]):
def items(self) -> Iterable[tuple[_KT_co, _VT_co]]: ...
+3 -1
View File
@@ -4,7 +4,7 @@ from _typeshed import OptExcInfo, SupportsKeysAndGetItem, SupportsNoArgReadline,
from _typeshed.wsgi import WSGIApplication, WSGIEnvironment
from collections.abc import Iterable, Mapping
from re import Pattern
from typing import IO, Any, ClassVar, Literal, Protocol, TypedDict, TypeVar, overload
from typing import IO, Any, ClassVar, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete
@@ -27,8 +27,10 @@ _HTTPMethod: TypeAlias = Literal["GET", "HEAD", "POST", "PUT", "DELETE", "CONNEC
_ListOrTuple: TypeAlias = list[_T] | tuple[_T, ...]
_RequestCacheControl: TypeAlias = CacheControl[Literal["request"]]
@type_check_only
class _SupportsReadAndNoArgReadline(SupportsRead[str | bytes], SupportsNoArgReadline[str | bytes], Protocol): ...
@type_check_only
class _RequestCacheControlDict(TypedDict, total=False):
max_stale: int
min_stale: int
+3 -1
View File
@@ -2,7 +2,7 @@ from _typeshed import SupportsItems, SupportsRead
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from collections.abc import Iterable, Iterator, Sequence
from datetime import timedelta
from typing import IO, Any, Literal, Protocol, TypedDict, TypeVar, overload
from typing import IO, Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from webob._types import AsymmetricProperty, AsymmetricPropertyWithDelete, SymmetricProperty, SymmetricPropertyWithDelete
@@ -18,6 +18,7 @@ __all__ = ["Response"]
_ResponseT = TypeVar("_ResponseT", bound=Response)
_ResponseCacheControl: TypeAlias = CacheControl[Literal["response"]]
@type_check_only
class _ResponseCacheExpires(Protocol):
def __call__(
self,
@@ -37,6 +38,7 @@ class _ResponseCacheExpires(Protocol):
stale_if_error: int = ...,
) -> None: ...
@type_check_only
class _ResponseCacheControlDict(TypedDict, total=False):
public: bool
private: Literal[True] | str
@@ -1,11 +1,13 @@
from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer
from collections.abc import Iterable
from io import FileIO
from typing import type_check_only
from ..base import AsyncBase, AsyncIndirectBase
# This class does not exist at runtime and instead these methods are
# all dynamically patched in.
@type_check_only
class _UnknownAsyncBinaryIO(AsyncBase[bytes]):
async def close(self) -> None: ...
async def flush(self) -> None: ...
+2 -1
View File
@@ -1,9 +1,10 @@
from _typeshed import FileDescriptorOrPath
from collections.abc import Iterable
from typing import BinaryIO
from typing import BinaryIO, type_check_only
from ..base import AsyncBase, AsyncIndirectBase
@type_check_only
class _UnknownAsyncTextIO(AsyncBase[str]):
async def close(self) -> None: ...
async def flush(self) -> None: ...
+2 -1
View File
@@ -1,11 +1,12 @@
from collections.abc import MutableMapping
from typing import Protocol
from typing import Protocol, type_check_only
from typing_extensions import TypeAlias
from bleach import _HTMLAttrKey
_HTMLAttrs: TypeAlias = MutableMapping[_HTMLAttrKey, str]
@type_check_only
class _Callback(Protocol): # noqa: Y046
def __call__(self, attrs: _HTMLAttrs, new: bool = ..., /) -> _HTMLAttrs: ...
+2 -1
View File
@@ -1,7 +1,7 @@
import re
from codecs import CodecInfo
from collections.abc import Generator, Iterable, Iterator
from typing import Any, Final, Protocol
from typing import Any, Final, Protocol, type_check_only
# We don't re-export any `html5lib` types / values here, because they are not
# really public and may change at any time. This is just a helper module,
@@ -14,6 +14,7 @@ from html5lib.serializer import HTMLSerializer
from html5lib.treewalkers.base import TreeWalker
# Is actually webencodings.Encoding
@type_check_only
class _Encoding(Protocol):
name: str
codec_info: CodecInfo
+2 -1
View File
@@ -1,10 +1,11 @@
from collections.abc import Collection, Container, Generator, Iterable, Iterator, MutableSet
from itertools import islice
from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, overload
from typing import Any, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import Self
_T_co = TypeVar("_T_co", covariant=True)
@type_check_only
class _RSub(Iterable[_T_co], Protocol):
def __new__(cls: type[_RSub[_T_co]], param: list[_T_co], /) -> _RSub[_T_co]: ...
+2 -1
View File
@@ -1,6 +1,7 @@
from typing import Any, Literal, Protocol
from typing import Any, Literal, Protocol, type_check_only
from typing_extensions import Self
@type_check_only
class _Sentinel(Protocol):
def __bool__(self) -> Literal[False]: ...
def __copy__(self) -> Self: ...
@@ -1,24 +1,28 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from typing import TypedDict
from typing import TypedDict, type_check_only
from braintree.configuration import Configuration
from braintree.environment import Environment
from braintree.util.http import Http
@type_check_only
class _Extension(TypedDict):
errorClass: Incomplete
legacyCode: int | None
@type_check_only
class _Error(TypedDict):
attribute: str | None
code: int | None
message: str | None
extensions: _Extension | None
@type_check_only
class _ValidationErrors(TypedDict):
errors: Iterable[_Error]
@type_check_only
class _Response(TypedDict):
errors: Iterable[_Error] | None
+2 -1
View File
@@ -2,11 +2,12 @@ import sys
import types
from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer
from collections.abc import Callable, Hashable
from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, final, overload
from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import TypeAlias
_T = TypeVar("_T")
@type_check_only
class _Allocator(Protocol):
def __call__(self, cdecl: str | CType, init: Any = ...) -> _CDataBase: ...
@@ -1,11 +1,12 @@
import threading
from collections.abc import Iterator
from types import TracebackType
from typing import Literal, Protocol
from typing import Literal, Protocol, type_check_only
from typing_extensions import Self
__version__: str
@type_check_only
class _Stream(Protocol):
def isatty(self) -> bool: ...
def flush(self) -> None: ...
+2 -1
View File
@@ -3,13 +3,14 @@ from _typeshed import Unused
from collections import OrderedDict
from collections.abc import Generator
from re import Match, Pattern
from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload
from typing import Any, Final, Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Never, Self, TypeAlias
_R_co = TypeVar("_R_co", float, datetime.datetime, default=float, covariant=True)
_R2_co = TypeVar("_R2_co", float, datetime.datetime, covariant=True)
_Expressions: TypeAlias = list[str] # fixed-length list of 5 or 6 strings
@type_check_only
class _AllIter(Protocol[_R_co]):
@overload
def __call__(
+2 -1
View File
@@ -1,5 +1,5 @@
import datetime
from typing import Literal, TypedDict
from typing import Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias
from .date import DateDataParser, _DetectLanguagesFunction
@@ -11,6 +11,7 @@ _default_parser: DateDataParser
_Part: TypeAlias = Literal["day", "month", "year"]
_ParserKind: TypeAlias = Literal["timestamp", "relative-time", "custom-formats", "absolute-time", "no-spaces-time"]
@type_check_only
class _Settings(TypedDict, total=False):
DATE_ORDER: str
PREFER_LOCALE_DATE_ORDER: bool
+2 -1
View File
@@ -1,6 +1,6 @@
import threading
from _typeshed import Incomplete
from typing import Final, Literal
from typing import Final, Literal, type_check_only
# Not bothering with types here as lxml support is supposed to be dropped in a future version of defusedxml
@@ -24,6 +24,7 @@ def tostring(
): ...
# Should be imported from lxml.etree.ElementBase, but lxml lacks types
@type_check_only
class _ElementBase: ...
class RestrictedElement(_ElementBase):
+2 -2
View File
@@ -1,9 +1,9 @@
import gzip
from _typeshed import ReadableBuffer
from typing import Final, Protocol, runtime_checkable
from typing import Final, Protocol, type_check_only
from xmlrpc.client import ExpatParser, Unmarshaller
@runtime_checkable
@type_check_only
class _Readable(Protocol):
def read(self, size: int | None = -1) -> bytes: ...
+2 -1
View File
@@ -1,7 +1,7 @@
import datetime
from _typeshed import Incomplete
from collections.abc import Iterable, Mapping
from typing import Literal, NamedTuple, TypedDict, overload
from typing import Literal, NamedTuple, TypedDict, overload, type_check_only
from typing_extensions import NotRequired
from docker._types import ContainerWeightDevice, WaitContainerResponse
@@ -13,6 +13,7 @@ from docker.types.services import Mount
from .images import Image
from .resource import Collection, Model
@type_check_only
class _RestartPolicy(TypedDict):
MaximumRetryCount: NotRequired[int]
Name: NotRequired[Literal["always", "on-failure"]]
+3 -1
View File
@@ -1,13 +1,15 @@
from collections.abc import Sequence
from typing import TypedDict
from typing import TypedDict, type_check_only
from typing_extensions import NotRequired
@type_check_only
class _ProxyConfigDict(TypedDict):
http: NotRequired[str]
https: NotRequired[str]
ftpProxy: NotRequired[str]
noProxy: NotRequired[str]
@type_check_only
class _Environment(TypedDict):
http_proxy: NotRequired[str]
HTTP_PROXY: NotRequired[str]
@@ -1,6 +1,6 @@
import logging
from collections.abc import Mapping, Sequence
from typing import IO, ClassVar, TypedDict
from typing import IO, ClassVar, TypedDict, type_check_only
from .util import Context
@@ -19,6 +19,7 @@ class Labels(KeyValues): ...
class Envs(KeyValues): ...
class Args(KeyValues): ...
@type_check_only
class _InstructionDict(TypedDict):
instruction: str
startline: int
+2 -1
View File
@@ -3,7 +3,7 @@ import xml.dom.minidom
from abc import abstractmethod
from collections import Counter
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping, Sequence
from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeVar, overload
from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeAlias
from docutils.frontend import Values
@@ -12,6 +12,7 @@ from docutils.utils import Reporter
_N = TypeVar("_N", bound=Node)
@type_check_only
class _DomModule(Protocol):
Document: type[xml.dom.minidom.Document]
+4 -1
View File
@@ -1,13 +1,14 @@
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from abc import abstractmethod
from collections.abc import Iterable
from typing import Any, Literal, TypedDict
from typing import Any, Literal, TypedDict, type_check_only
from typing_extensions import Unpack
from fanstatic.core import Dependable, NeededResources, Resource
from fanstatic.inclusion import Inclusion
from webob import Request, Response
@type_check_only
class _NeededResourcesConfig(TypedDict, total=False):
versioning: bool
versioning_use_md5: bool
@@ -17,6 +18,7 @@ class _NeededResourcesConfig(TypedDict, total=False):
publisher_signature: str
resources: Iterable[Dependable] | None
@type_check_only
class _InjectorPluginOptions(TypedDict, total=False):
compile: bool
bundle: bool
@@ -24,6 +26,7 @@ class _InjectorPluginOptions(TypedDict, total=False):
debug: bool
minified: bool
@type_check_only
class _TopBottomInjectorPluginOptions(_InjectorPluginOptions, total=False):
bottom: bool
force_bottom: bool
+2 -1
View File
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, SupportsLenAndGetItem
from collections.abc import Generator, Iterable
from logging import Logger
from typing import ClassVar, Protocol, TypeVar, overload
from typing import ClassVar, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from .enums import AccessPermission, EncryptionMethod
@@ -15,6 +15,7 @@ LOGGER: Logger
import_error: ImportError | None
@type_check_only
class _SupportsGetItem(Protocol[_T_co]):
def __getitem__(self, k: int, /) -> _T_co: ...
+4
View File
@@ -238,6 +238,7 @@ SEARCH_FUNCTION_DOMAIN: Final[int]
# Pretty Printing
@type_check_only
class _PrettyPrinter(Protocol):
# TODO: The "children" and "display_hint" methods are optional for
# pretty-printers. Unfortunately, there is no such thing as an optional
@@ -258,6 +259,7 @@ type_printers: list[gdb.types._TypePrinter]
# Filtering Frames
@type_check_only
class _FrameFilter(Protocol):
name: str
enabled: bool
@@ -920,6 +922,7 @@ class TuiWindow:
def erase(self) -> None: ...
def write(self, string: str, full_window: bool = ..., /) -> None: ...
@type_check_only
class _Window(Protocol):
def close(self) -> None: ...
def render(self) -> None: ...
@@ -962,6 +965,7 @@ class FreeProgspaceEvent(Event): ...
class SignalEvent(StopEvent):
stop_signal: str
@type_check_only
class _InferiorCallEvent(Event): ...
class InferiorCallPreEvent(_InferiorCallEvent):
+3 -2
View File
@@ -1,5 +1,5 @@
from collections.abc import Iterator
from typing import Protocol
from typing import Protocol, type_check_only
import gdb
@@ -10,13 +10,14 @@ def deep_items(type_: gdb.Type) -> Iterator[tuple[str, gdb.Field]]: ...
def get_type_recognizers() -> list[_TypeRecognizer]: ...
def apply_type_recognizers(recognizers: list[_TypeRecognizer], type_obj: gdb.Type) -> str | None: ...
def register_type_printer(locus: gdb.Objfile | gdb.Progspace | None, printer: _TypePrinter) -> None: ...
@type_check_only
class _TypePrinter(Protocol):
enabled: bool
name: str
def instantiate(self) -> _TypeRecognizer | None: ...
@type_check_only
class _TypeRecognizer(Protocol):
def recognize(self, type: gdb.Type, /) -> str | None: ...
+3 -2
View File
@@ -1,13 +1,13 @@
from collections.abc import Sequence
from re import Pattern
from typing import Protocol
from typing import Protocol, type_check_only
import gdb
def register_xmethod_matcher(
locus: gdb.Objfile | gdb.Progspace | None, matcher: XMethodMatcher, replace: bool = False
) -> None: ...
@type_check_only
class _XMethod(Protocol):
name: str
enabled: bool
@@ -31,6 +31,7 @@ class XMethodMatcher:
def __init__(self, name: str) -> None: ...
def match(self, class_type: gdb.Type, method_name: str) -> XMethodWorker | Sequence[XMethodWorker]: ...
@type_check_only
class _SimpleWorkerMethod(Protocol):
def __call__(self, *args: gdb.Value) -> object: ...
+2 -2
View File
@@ -1,7 +1,7 @@
import os
from _typeshed import Incomplete, SupportsRead
from collections import OrderedDict
from typing import Literal, TypedDict, overload
from typing import Literal, TypedDict, overload, type_check_only
import pandas as pd
from pandas._typing import Axes
@@ -38,7 +38,7 @@ def _read_file(
encoding: str | None = None,
**kwargs, # depend on engine
) -> pd.DataFrame: ...
@type_check_only
class _Schema(TypedDict):
geometry: str | list[str]
properties: OrderedDict[str, str]
+5 -1
View File
@@ -2,7 +2,7 @@ import sqlite3
from _typeshed import Incomplete, SupportsLenAndGetItem
from collections.abc import Container, Iterator, Mapping
from contextlib import AbstractContextManager
from typing import Any, Protocol, overload
from typing import Any, Protocol, overload, type_check_only
from typing_extensions import TypeAlias
from pandas._typing import Scalar
@@ -16,6 +16,7 @@ from ..geodataframe import GeoDataFrame
# isinstance checks. However to avoid a dependency on SQLAlchemy, we use "good-enough"
# protocols that match as much as possible the SQLAlchemy implementation. This makes it
# very hard for someone to pass in the wrong object.
@type_check_only
class _SqlalchemyTransactionLike(Protocol):
# is_active: bool
# connection: _SqlalchemyConnectionLike
@@ -27,9 +28,11 @@ class _SqlalchemyTransactionLike(Protocol):
def commit(self) -> None: ...
# `Any` is used in places where it would require to copy a lot of types from sqlalchemy
@type_check_only
class _SqlAlchemyEventTarget(Protocol):
dispatch: Any
@type_check_only
class _SqlalchemyConnectionLike(_SqlAlchemyEventTarget, Protocol):
engine: Any
@property
@@ -52,6 +55,7 @@ class _SqlalchemyConnectionLike(_SqlAlchemyEventTarget, Protocol):
def in_nested_transaction(self) -> bool: ...
def close(self) -> None: ...
@type_check_only
class _SqlalchemyEngineLike(_SqlAlchemyEventTarget, Protocol):
dialect: Any
pool: Any
+2 -1
View File
@@ -1,5 +1,5 @@
from collections.abc import Callable, Sequence
from typing import Any, Generic, NoReturn, Protocol, TypeVar, overload
from typing import Any, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
from gevent._types import _Loop, _Resolver
from gevent.fileobject import _FileObjectType
@@ -9,6 +9,7 @@ __all__ = ["config"]
_T = TypeVar("_T")
@type_check_only
class _SettingDescriptor(Protocol[_T]):
@overload
def __get__(self, obj: None, owner: type[Config]) -> property: ...
+2 -1
View File
@@ -2,7 +2,7 @@ import sys
from _typeshed import FileDescriptor
from collections.abc import Callable, Sequence
from types import TracebackType
from typing import Protocol
from typing import Protocol, type_check_only
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
from gevent._types import _AsyncWatcher, _Callback, _ChildWatcher, _IoWatcher, _StatWatcher, _TimerWatcher, _Watcher
@@ -12,6 +12,7 @@ _ErrorHandlerFunc: TypeAlias = Callable[
[object | None, type[BaseException] | None, BaseException | None, TracebackType | None], object
]
@type_check_only
class _SupportsHandleError(Protocol):
handle_error: _ErrorHandlerFunc
+2 -1
View File
@@ -1,7 +1,7 @@
from _typeshed import FileDescriptor
from collections.abc import Callable, Collection, Iterable
from types import TracebackType
from typing import Any, Generic, Protocol, TypeVar, overload
from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self, TypeVarTuple, Unpack
from gevent._greenlet_primitives import SwitchOutGreenletWithLoop
@@ -15,6 +15,7 @@ _T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts")
_WaitableT = TypeVar("_WaitableT", bound=_Waitable)
@type_check_only
class _Waitable(Protocol):
def rawlink(self, callback: Callable[[Any], object], /) -> object: ...
def unlink(self, callback: Callable[[Any], object], /) -> object: ...
+2 -1
View File
@@ -1,6 +1,6 @@
from collections.abc import Callable, Container
from types import TracebackType
from typing import Any, Generic, Literal, Protocol
from typing import Any, Generic, Literal, Protocol, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias
from gevent._types import _Loop
@@ -10,6 +10,7 @@ from greenlet import greenlet
_P = ParamSpec("_P")
@type_check_only
class _SpawnFunc(Protocol):
def __call__(self, func: Callable[_P, object], /, *args: _P.args, **kwargs: _P.kwargs) -> greenlet: ...
+2 -1
View File
@@ -1,5 +1,5 @@
from types import TracebackType
from typing import Generic, Literal, Protocol, TypeVar, overload
from typing import Generic, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from gevent._abstract_linkable import AbstractLinkable
@@ -11,6 +11,7 @@ _T_co = TypeVar("_T_co", covariant=True)
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType | None]
_OptExcInfo: TypeAlias = _ExcInfo | tuple[None, None, None]
@type_check_only
class _ValueSource(Protocol[_T_co]):
def successful(self) -> bool: ...
@property
+2 -1
View File
@@ -1,7 +1,7 @@
import sys
from collections.abc import Callable, Mapping, Sequence
from types import ModuleType
from typing import Any, Protocol, TypeVar
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias
from gevent.hub import Hub
@@ -30,6 +30,7 @@ else:
subscribers: list[Callable[[Any], object]]
@type_check_only
class _PeriodicMonitorThread(Protocol):
def add_monitoring_function(self, function: Callable[[Hub], object], period: float | None) -> object: ...
+2 -1
View File
@@ -1,6 +1,6 @@
from collections.abc import Callable
from types import TracebackType
from typing import Any, Generic, Protocol, TextIO, TypeVar, overload
from typing import Any, Generic, Protocol, TextIO, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec
import gevent._hub_local
@@ -23,6 +23,7 @@ getcurrent = greenlet.getcurrent
get_hub = gevent._hub_local.get_hub
Waiter = gevent._waiter.Waiter
@type_check_only
class _DefaultReturnProperty(Protocol[_T]):
@overload
def __get__(self, obj: None, owner: type[object] | None = None) -> property: ...
+2 -1
View File
@@ -5,7 +5,7 @@ from http.client import HTTPMessage
from io import BufferedIOBase, BufferedReader
from logging import Logger
from types import TracebackType
from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload
from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import Self
from gevent.baseserver import _Spawner
@@ -17,6 +17,7 @@ __all__ = ["WSGIServer", "WSGIHandler", "LoggingLogAdapter", "Environ", "SecureE
_T = TypeVar("_T")
@type_check_only
class _LogOutputStream(SupportsWrite[str], Protocol):
def writelines(self, lines: Iterable[str], /) -> None: ...
def flush(self) -> None: ...
+2 -1
View File
@@ -1,11 +1,12 @@
from collections.abc import Sequence
from typing import TypedDict
from typing import TypedDict, type_check_only
from gevent._types import _Watcher
from gevent.hub import Hub
from gevent.resolver import AbstractResolver
from gevent.resolver.cares import channel
@type_check_only
class _ChannelArgs(TypedDict):
flags: str | int | None
timeout: str | float | None
+2 -1
View File
@@ -1,7 +1,7 @@
from _socket import _Address as _StrictAddress
from _typeshed import ReadableBuffer, StrOrBytesPath
from collections.abc import Callable
from typing import Any, ClassVar, TypedDict, overload
from typing import Any, ClassVar, TypedDict, overload, type_check_only
from typing_extensions import TypeAlias
from gevent.baseserver import BaseServer, _Spawner
@@ -12,6 +12,7 @@ from gevent.ssl import SSLContext, wrap_socket as ssl_wrap_socket
# from the stdlib _socket.pyi. But that would exclude some potentially valid handlers.
_Address: TypeAlias = Any
@type_check_only
class _SSLArguments(TypedDict, total=False):
keyfile: StrOrBytesPath
certfile: StrOrBytesPath
+2 -1
View File
@@ -1,6 +1,6 @@
from collections.abc import Callable
from types import TracebackType
from typing import Any, Literal, Protocol, TypeVar, overload
from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, Self
from gevent._types import _TimerWatcher
@@ -11,6 +11,7 @@ _T2 = TypeVar("_T2")
_TimeoutT = TypeVar("_TimeoutT", bound=Timeout)
_P = ParamSpec("_P")
@type_check_only
class _HasSeconds(Protocol):
@property
def seconds(self) -> float | int: ...
+2 -1
View File
@@ -2,7 +2,7 @@ import sys
from collections.abc import Callable
from contextvars import Context
from types import FrameType, TracebackType
from typing import Any, Literal, Protocol, overload
from typing import Any, Literal, Protocol, overload, type_check_only
from typing_extensions import TypeAlias
_TraceEvent: TypeAlias = Literal["switch", "throw"]
@@ -19,6 +19,7 @@ GREENLET_USE_TRACING: bool
# to pass this around, can still pass it around without having to ignore type errors...
_C_API: object
@type_check_only
class _ParentDescriptor(Protocol):
def __get__(self, obj: greenlet, owner: type[greenlet] | None = None) -> greenlet | None: ...
def __set__(self, obj: greenlet, value: greenlet) -> None: ...
+2 -1
View File
@@ -1,9 +1,10 @@
from _typeshed import Incomplete, SupportsRead
from codecs import CodecInfo
from typing import Protocol, overload
from typing import Protocol, overload, type_check_only
from typing_extensions import TypeAlias
# Is actually webencodings.Encoding
@type_check_only
class _Encoding(Protocol):
name: str
codec_info: CodecInfo
+2 -1
View File
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
from typing import Any, Generic, TypeVar
from typing import Any, Generic, TypeVar, type_check_only
from typing_extensions import Self
from requests import Response, Session
@@ -50,6 +50,7 @@ class Adapter(Generic[_R], metaclass=ABCMeta):
self, method, url: str, headers: Mapping[str, str] | None = None, raise_exception: bool = True, **kwargs: Any
) -> _R: ...
@type_check_only
class _GenericRawAdapter(Adapter[_R]):
def get_login_token(self, response: _R) -> str: ...
def request(
+2 -1
View File
@@ -1,7 +1,8 @@
from collections.abc import Callable, Iterable, Mapping
from typing import Any, NoReturn, TypedDict, TypeVar
from typing import Any, NoReturn, TypedDict, TypeVar, type_check_only
from typing_extensions import NotRequired
@type_check_only
class _DeprecateProperty(TypedDict):
to_be_removed_in_version: str
client_property: str
+2 -1
View File
@@ -3,7 +3,7 @@ from _typeshed import ConvertibleToFloat, ConvertibleToInt, SupportsKeysAndGetIt
from collections.abc import Iterable, Iterator
from enum import Enum
from re import Pattern
from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, overload
from typing import Any, ClassVar, Final, Literal, Protocol, SupportsIndex, overload, type_check_only
from typing_extensions import Self, TypeAlias
from .caselessdict import CaselessDict
@@ -47,6 +47,7 @@ _PropType: TypeAlias = type[Any] # any of the v* classes in this file
_PeriodTuple: TypeAlias = tuple[datetime.datetime, datetime.datetime | datetime.timedelta]
_AnyTimeType: TypeAlias = datetime.datetime | datetime.date | datetime.timedelta | datetime.time | _PeriodTuple
@type_check_only
class _vType(Protocol):
def to_ical(self) -> bytes | str: ...
+2 -1
View File
@@ -1,4 +1,4 @@
from typing import Literal, TypedDict
from typing import Literal, TypedDict, type_check_only
from typing_extensions import NotRequired, TypeAlias
_NodeType: TypeAlias = Literal[
@@ -26,6 +26,7 @@ _NodeType: TypeAlias = Literal[
"value_projection",
]
@type_check_only
class _ASTNode(TypedDict):
type: _NodeType
children: list[_ASTNode]
+2 -1
View File
@@ -1,10 +1,11 @@
from collections.abc import Callable, Iterable
from typing import Any, TypedDict, TypeVar
from typing import Any, TypedDict, TypeVar, type_check_only
from typing_extensions import NotRequired
TYPES_MAP: dict[str, str]
REVERSE_TYPES_MAP: dict[str, tuple[str, ...]]
@type_check_only
class _Signature(TypedDict):
types: list[str]
variadic: NotRequired[bool]
+2 -1
View File
@@ -1,8 +1,9 @@
from collections.abc import Iterator
from typing import ClassVar, TypedDict
from typing import ClassVar, TypedDict, type_check_only
from jmespath.exceptions import EmptyExpressionError as EmptyExpressionError, LexerError as LexerError
@type_check_only
class _LexerTokenizeResult(TypedDict):
type: str
value: str
+2 -1
View File
@@ -1,6 +1,6 @@
from _typeshed import Unused
from collections.abc import Callable, MutableMapping
from typing import Any, ClassVar, NoReturn, TypedDict, TypeVar
from typing import Any, ClassVar, NoReturn, TypedDict, TypeVar, type_check_only
from jmespath.functions import Functions
@@ -27,6 +27,7 @@ class Visitor:
def visit(self, node: _TreeNode, *args: Any, **kwargs: Any) -> Any: ...
def default_visit(self, node: _TreeNode, *args: Unused, **kwargs: Unused) -> NoReturn: ...
@type_check_only
class _TreeNode(TypedDict):
type: str
value: Any
+2 -1
View File
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, SupportsKeysAndGetItem
from collections.abc import Callable, Generator, Iterable, Iterator, Mapping
from contextlib import contextmanager
from typing import Any, ClassVar, overload
from typing import Any, ClassVar, overload, type_check_only
from typing_extensions import TypeAlias, deprecated
from referencing.jsonschema import Schema, SchemaRegistry
@@ -20,6 +20,7 @@ _ValidatorCallback: TypeAlias = Callable[[Any, Any, _JsonValue, _JsonObject], It
# This class does not exist at runtime. Compatible classes are created at
# runtime by create().
@type_check_only
class _Validator:
VALIDATORS: ClassVar[dict[Incomplete, Incomplete]]
META_SCHEMA: ClassVar[dict[Incomplete, Incomplete]]
+2 -1
View File
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from collections.abc import Callable, Coroutine, Iterable, Mapping, Sequence
from contextlib import AbstractContextManager
from types import TracebackType
from typing import Any, ClassVar, Generic, Literal, TypeVar, overload
from typing import Any, ClassVar, Generic, Literal, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, Self
_F = TypeVar("_F", bound=Callable[..., Any])
@@ -211,6 +211,7 @@ class _patch_dict:
start: Any
stop: Any
@type_check_only
class _patcher:
TEST_PREFIX: str
dict: type[_patch_dict]
@@ -1,11 +1,12 @@
from collections.abc import Mapping
from logging import Logger
from typing import Literal, TypedDict
from typing import Literal, TypedDict, type_check_only
from typing_extensions import NotRequired
from oauthlib.common import Request
from oauthlib.oauth2.rfc6749.clients import Client
@type_check_only
class _BearerToken(TypedDict):
token_type: Literal["Bearer"]
access_token: str
@@ -14,6 +15,7 @@ class _BearerToken(TypedDict):
refresh_token: NotRequired[str]
state: NotRequired[str]
@type_check_only
class _AuthorizationCode(TypedDict):
code: str
state: NotRequired[str]
+2 -1
View File
@@ -1,5 +1,5 @@
from _typeshed import StrPath, SupportsRead, SupportsWrite
from typing import IO, Literal, Protocol
from typing import IO, Literal, Protocol, type_check_only
from typing_extensions import TypeAlias
from openpyxl.compat.numbers import NUMPY as NUMPY
@@ -27,5 +27,6 @@ _VisibilityType: TypeAlias = Literal["visible", "hidden", "veryHidden"] # noqa:
_ZipFileFileProtocol: TypeAlias = StrPath | IO[bytes] | SupportsRead[bytes] # noqa: Y047
_ZipFileFileWriteProtocol: TypeAlias = StrPath | IO[bytes] | SupportsWrite[bytes] # noqa: Y047
@type_check_only
class _Decodable(Protocol): # noqa: Y046
def decode(self, encoding: str, /) -> str: ...
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, Unused
from collections.abc import Generator, Iterable, Sized
from typing import Any, Protocol, TypeVar
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import Self
from openpyxl.descriptors import Strict
@@ -13,10 +13,12 @@ from .base import Alias, Descriptor
_T = TypeVar("_T")
_ContainerT = TypeVar("_ContainerT")
@type_check_only
class _SupportsFromTree(Protocol):
@classmethod
def from_tree(cls, node: _SerialisableTreeElement) -> Any: ...
@type_check_only
class _SupportsToTree(Protocol):
def to_tree(self) -> Element: ...
@@ -47,6 +49,7 @@ class ValueSequence(Sequence[_ContainerT]):
) -> Generator[Element, None, None]: ...
def from_tree(self, node: _HasGet[_T]) -> _T: ...
@type_check_only
class _NestedSequenceToTreeObj(Sized, Iterable[_SupportsToTree], Protocol): ...
# See `Sequence` for the meaning of `_ContainerT`.
@@ -1,6 +1,6 @@
from _typeshed import ConvertibleToInt, Incomplete, SupportsIter
from collections.abc import Iterator
from typing import Any, ClassVar, Final, Protocol
from typing import Any, ClassVar, Final, Protocol, type_check_only
from typing_extensions import Self
from openpyxl.descriptors import MetaSerialisable
@@ -9,7 +9,10 @@ from openpyxl.xml.functions import Element
from ..xml._functions_overloads import _HasAttrib, _HasGet, _HasTagAndGet, _HasText, _SupportsFindChartLines
# For any override directly re-using Serialisable.from_tree
@type_check_only
class _ChildSerialisableTreeElement(_HasAttrib, _HasText, SupportsIter[Incomplete], Protocol): ...
@type_check_only
class _SerialisableTreeElement(_HasGet[object], _SupportsFindChartLines, _ChildSerialisableTreeElement, Protocol): ...
KEYWORDS: Final[frozenset[str]]
@@ -1,6 +1,6 @@
from _typeshed import Incomplete, ReadableBuffer, StrPath, Unused
from collections.abc import Generator, Iterable
from typing import Protocol
from typing import Protocol, type_check_only
from typing_extensions import TypeAlias
from openpyxl.cell import _CellOrMergedCell
@@ -8,6 +8,7 @@ from openpyxl.worksheet._write_only import WriteOnlyWorksheet
from openpyxl.worksheet.worksheet import Worksheet
# WorksheetWriter.read has an explicit BytesIO branch. Let's make sure this protocol is viable for BytesIO too.
@type_check_only
class _SupportsCloseAndWrite(Protocol):
def write(self, buffer: ReadableBuffer, /) -> Unused: ...
def close(self) -> Unused: ...
@@ -1,5 +1,5 @@
from _typeshed import ConvertibleToInt, Incomplete
from typing import ClassVar, Literal, Protocol
from typing import ClassVar, Literal, Protocol, type_check_only
from typing_extensions import TypeAlias
from openpyxl.descriptors.base import (
@@ -36,6 +36,7 @@ _DataValidationOperator: TypeAlias = Literal[
"between", "notBetween", "equal", "notEqual", "lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual"
]
@type_check_only
class _HasCoordinate(Protocol):
coordinate: str | CellRange
+2 -1
View File
@@ -4,13 +4,14 @@ from collections.abc import Mapping
from logging import _ExcInfoType
from socket import _RetAddress, socket
from threading import Thread
from typing import Final, Protocol
from typing import Final, Protocol, type_check_only
from paramiko.channel import Channel
from paramiko.message import Message, _LikeBytes
from paramiko.pkey import PKey
from paramiko.transport import Transport
@type_check_only
class _AgentProxy(Protocol):
def connect(self) -> None: ...
def close(self) -> None: ...
+2 -1
View File
@@ -1,6 +1,6 @@
from _typeshed import FileDescriptorOrPath
from collections.abc import Iterable, Mapping
from typing import NoReturn, Protocol
from typing import NoReturn, Protocol, type_check_only
from paramiko.auth_strategy import AuthStrategy
from paramiko.channel import Channel, ChannelFile, ChannelStderrFile, ChannelStdinFile
@@ -10,6 +10,7 @@ from paramiko.sftp_client import SFTPClient
from paramiko.transport import Transport, _SocketLike
from paramiko.util import ClosingContextManager
@type_check_only
class _TransportFactory(Protocol):
def __call__(
self,
+3 -1
View File
@@ -1,11 +1,13 @@
from _typeshed import FileDescriptorOrPath
from collections.abc import Iterator, Mapping, MutableMapping
from typing import type_check_only
from typing_extensions import Self
from paramiko.pkey import PKey
# Internal to HostKeys.lookup(). Calls itself "SubDict".
@type_check_only
class _SubDict(MutableMapping[str, PKey]):
# Internal to HostKeys.lookup()
def __init__(self, hostname: str, entries: list[HostKeyEntry], hostkeys: HostKeys) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __len__(self) -> int: ...
+2 -1
View File
@@ -1,9 +1,10 @@
from _typeshed import ReadableBuffer
from collections.abc import Iterable
from io import BytesIO
from typing import Any, Protocol
from typing import Any, Protocol, type_check_only
from typing_extensions import TypeAlias
@type_check_only
class _SupportsAsBytes(Protocol):
def asbytes(self) -> bytes: ...
+3 -1
View File
@@ -1,9 +1,11 @@
from typing import Protocol
from typing import Protocol, type_check_only
@type_check_only
class _BasePipe(Protocol):
def clear(self) -> None: ...
def set(self) -> None: ...
@type_check_only
class _Pipe(_BasePipe, Protocol):
def close(self) -> None: ...
def fileno(self) -> int: ...
+2 -1
View File
@@ -4,7 +4,7 @@ from logging import Logger
from socket import socket
from threading import Condition, Event, Lock, Thread
from types import ModuleType
from typing import Any, Protocol
from typing import Any, Protocol, type_check_only
from typing_extensions import TypeAlias
from paramiko.auth_handler import AuthHandler, AuthOnlyHandler, _InteractiveCallback
@@ -21,6 +21,7 @@ from paramiko.util import ClosingContextManager
_Addr: TypeAlias = tuple[str, int]
_SocketLike: TypeAlias = str | _Addr | socket | Channel | ProxyCommand
@type_check_only
class _KexEngine(Protocol):
def start_kex(self) -> None: ...
def parse_next(self, ptype: int, m: Message) -> None: ...
+2 -1
View File
@@ -1,7 +1,7 @@
from asyncio import ReadTransport
from collections.abc import Awaitable, Callable, Iterable
from re import Match, Pattern
from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, overload
from typing import IO, AnyStr, Generic, Literal, Protocol, TextIO, overload, type_check_only
from typing_extensions import TypeAlias
from ._async import PatternWaiter
@@ -17,6 +17,7 @@ class _NullCoder:
@staticmethod
def decode(b: str, final: bool = False): ...
@type_check_only
class _Logfile(Protocol):
def write(self, s, /) -> object: ...
def flush(self) -> object: ...
+2 -1
View File
@@ -1,8 +1,9 @@
from logging import Logger
from typing import ClassVar, Protocol
from typing import ClassVar, Protocol, type_check_only
from .spec import Connection
@type_check_only
class _Credentials(Protocol):
TYPE: ClassVar[str]
erase_on_connect: bool
@@ -1,5 +1,5 @@
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
from typing import Any, Protocol, SupportsIndex, TypeVar, overload
from typing import Any, Protocol, SupportsIndex, TypeVar, overload, type_check_only
from typing_extensions import Self
from google.protobuf.descriptor import Descriptor
@@ -12,6 +12,7 @@ _K = TypeVar("_K", bound=bool | int | str)
_ScalarV = TypeVar("_ScalarV", bound=bool | int | float | str | bytes)
_MessageV = TypeVar("_MessageV", bound=Message)
@type_check_only
class _ValueChecker(Protocol[_T]):
def CheckValue(self, proposed_value: _T) -> _T: ...
def DefaultValue(self) -> _T: ...
@@ -1,4 +1,4 @@
from typing import Generic, TypeVar
from typing import Generic, TypeVar, type_check_only
from google.protobuf.descriptor import EnumDescriptor
@@ -9,6 +9,7 @@ _V = TypeVar("_V", bound=int)
# NOTE: this doesn't actually inherit from type,
# but mypy doesn't support metaclasses that don't inherit from type,
# so we pretend it does in the stubs...
@type_check_only
class _EnumTypeWrapper(type, Generic[_V]):
DESCRIPTOR: EnumDescriptor
def __init__(self, enum_type: EnumDescriptor) -> None: ...
@@ -1,5 +1,5 @@
from collections.abc import Iterator
from typing import Any, Generic, TypeVar
from typing import Any, Generic, TypeVar, type_check_only
from google.protobuf.descriptor import FieldDescriptor
from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer
@@ -11,6 +11,7 @@ _ExtenderMessageT = TypeVar(
bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | float | str | bytes,
)
@type_check_only
class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ...
class _ExtensionDict(Generic[_ContainerMessageT]):
@@ -59,15 +59,6 @@ class FieldMask:
self, source: tAny, destination: tAny, replace_message_field: bool = False, replace_repeated_field: bool = False
) -> None: ...
class _FieldMaskTree:
def __init__(self, field_mask: Incomplete | None = ...) -> None: ...
def MergeFromFieldMask(self, field_mask: tAny) -> None: ...
def AddPath(self, path: tAny): ...
def ToFieldMask(self, field_mask: tAny) -> None: ...
def IntersectPath(self, path: tAny, intersection: tAny): ...
def AddLeafNodes(self, prefix: tAny, node: tAny) -> None: ...
def MergeMessage(self, source: tAny, destination: tAny, replace_message: tAny, replace_repeated: tAny) -> None: ...
_StructValue: TypeAlias = struct_pb2.Struct | struct_pb2.ListValue | str | float | bool | None
_StructValueArg: TypeAlias = _StructValue | Mapping[str, _StructValueArg] | Sequence[_StructValueArg]
+2
View File
@@ -66,6 +66,7 @@ UNKNOWN: _type
REPLICATION_LOGICAL: int
REPLICATION_PHYSICAL: int
@type_check_only
class _ISQLQuoteProto(Protocol):
# Objects conforming this protocol should implement a getquoted() and optionally a prepare() method.
# The real ISQLQuote class is implemented below with more stuff.
@@ -85,6 +86,7 @@ __libpq_version__: int
_T_co = TypeVar("_T_co", covariant=True)
@type_check_only
class _SupportsReadAndReadline(SupportsRead[_T_co], SupportsReadline[_T_co], Protocol[_T_co]): ...
class cursor:
+2 -1
View File
@@ -1,6 +1,7 @@
from typing import TypedDict
from typing import TypedDict, type_check_only
# Unused in this module, but imported in multiple submodules.
@type_check_only
class _EncodedRLE(TypedDict): # noqa: Y049
size: list[int]
counts: str | bytes
+7 -1
View File
@@ -1,6 +1,6 @@
from collections.abc import Collection, Sequence
from pathlib import Path
from typing import Generic, Literal, TypedDict, TypeVar, overload
from typing import Generic, Literal, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -10,6 +10,7 @@ from . import _EncodedRLE
PYTHON_VERSION: int
@type_check_only
class _Image(TypedDict):
id: int
width: int
@@ -18,10 +19,12 @@ class _Image(TypedDict):
_TPolygonSegmentation: TypeAlias = list[list[float]]
@type_check_only
class _RLE(TypedDict):
size: list[int]
counts: list[int]
@type_check_only
class _Annotation(TypedDict):
id: int
image_id: int
@@ -33,6 +36,7 @@ class _Annotation(TypedDict):
_TSeg = TypeVar("_TSeg", _TPolygonSegmentation, _RLE, _EncodedRLE)
@type_check_only
class _AnnotationG(TypedDict, Generic[_TSeg]):
id: int
image_id: int
@@ -42,11 +46,13 @@ class _AnnotationG(TypedDict, Generic[_TSeg]):
bbox: list[float]
iscrowd: int
@type_check_only
class _Category(TypedDict):
id: int
name: str
supercategory: str
@type_check_only
class _Dataset(TypedDict):
images: list[_Image]
annotations: list[_Annotation]
+3 -1
View File
@@ -1,4 +1,4 @@
from typing import Literal, TypedDict
from typing import Literal, TypedDict, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -9,6 +9,7 @@ from .coco import COCO
_NDFloatArray: TypeAlias = npt.NDArray[np.float64]
_TIOU: TypeAlias = Literal["segm", "bbox", "keypoints"]
@type_check_only
class _ImageEvaluationResult(TypedDict):
image_id: int
category_id: int
@@ -22,6 +23,7 @@ class _ImageEvaluationResult(TypedDict):
gtIgnore: _NDFloatArray
dtIgnore: _NDFloatArray
@type_check_only
class _EvaluationResult(TypedDict):
params: Params
counts: list[int]
@@ -4,12 +4,13 @@ from _typeshed import StrOrBytesPath
from collections.abc import Iterable
from importlib.metadata import PackagePath as _PackagePath
from pathlib import Path
from typing import Final, TypedDict
from typing import Final, TypedDict, type_check_only
CONDA_ROOT: Final[Path]
CONDA_META_DIR: Final[Path]
PYTHONPATH_PREFIXES: Final[list[Path]]
@type_check_only
class _RawDict(TypedDict):
name: str
version: str
+2 -1
View File
@@ -3,13 +3,14 @@ from _typeshed import OptExcInfo
from collections.abc import Callable
from queue import Queue
from types import ModuleType, TracebackType
from typing import Any, ClassVar, Generic, TypedDict, TypeVar
from typing import Any, ClassVar, Generic, TypedDict, TypeVar, type_check_only
from typing_extensions import ParamSpec, Self
_T = TypeVar("_T")
_AbstractListenerT = TypeVar("_AbstractListenerT", bound=AbstractListener)
_P = ParamSpec("_P")
@type_check_only
class _RESOLUTIONS(TypedDict):
darwin: str
uinput: str
@@ -1,11 +1,11 @@
from collections.abc import Generator
from typing import TextIO
from typing import TextIO, type_check_only
import serial
def sixteen(data: bytes) -> Generator[tuple[str, str] | tuple[None, None], None, None]: ...
def hexdump(data: bytes) -> Generator[tuple[int, str], None, None]: ...
@type_check_only
class _Formatter:
def rx(self, data: bytes) -> None: ...
def tx(self, data: bytes) -> None: ...
@@ -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: ...
+9 -1
View File
@@ -1,28 +1,33 @@
from collections.abc import Callable, Iterable, Iterator
from typing import Any, TypedDict, TypeVar
from typing import Any, TypedDict, TypeVar, type_check_only
from typing_extensions import TypeAlias
_T = TypeVar("_T")
_Callback: TypeAlias = Callable[[str, _Result], object]
@type_check_only
class _Result(TypedDict):
nmap: _ResultNmap
scan: dict[str, PortScannerHostDict]
@type_check_only
class _ResultNmap(TypedDict):
command_line: str
scaninfo: _ResultNmapInfo
scanstats: _ResultNampStats
@type_check_only
class _ResultNmapInfo(TypedDict, total=False):
error: str
warning: str
protocol: _ResultNampInfoProtocol
@type_check_only
class _ResultNampInfoProtocol(TypedDict):
method: str
services: str
@type_check_only
class _ResultNampStats(TypedDict):
timestr: str
elapsed: str
@@ -30,14 +35,17 @@ class _ResultNampStats(TypedDict):
downhosts: str
totalhosts: str
@type_check_only
class _ResulHostUptime(TypedDict):
seconds: str
lastboot: str
@type_check_only
class _ResultHostNames(TypedDict):
type: str
name: str
@type_check_only
class _ResultHostPort(TypedDict):
conf: str
cpe: str
+2 -1
View File
@@ -1,7 +1,7 @@
from collections.abc import Callable, Iterable, Sequence
from re import Pattern
from types import FunctionType, MethodType
from typing import Any, Literal, TypedDict, overload
from typing import Any, Literal, TypedDict, overload, type_check_only
from typing_extensions import TypeAlias
from Xlib import error
@@ -22,6 +22,7 @@ _ResourceBaseClass: TypeAlias = (
)
# Is the type of the `_resource_baseclasses` variable, defined in this file at runtime
@type_check_only
class _ResourceBaseClassesType(TypedDict): # noqa: Y049
resource: type[resource.Resource]
drawable: type[drawable.Drawable]
+2 -1
View File
@@ -1,7 +1,7 @@
from _typeshed import SupportsDunderGT, SupportsDunderLT, SupportsRead
from collections.abc import Iterable, Mapping, Sequence
from re import Pattern
from typing import Any, Final, Protocol, TypeVar, overload
from typing import Any, Final, Protocol, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias
from Xlib.display import Display
@@ -15,6 +15,7 @@ _DB: TypeAlias = dict[str, tuple[_DB, ...]]
# so this is a slightly less precise version of the _DB alias for parameter annotations
_DB_Param: TypeAlias = dict[str, Any]
@type_check_only
class _SupportsComparisons(SupportsDunderLT[_T_contra], SupportsDunderGT[_T_contra], Protocol[_T_contra]): ...
comment_re: Final[Pattern[str]]
+2 -1
View File
@@ -1,7 +1,7 @@
import datetime
from _typeshed import Unused
from collections.abc import Mapping
from typing import ClassVar
from typing import ClassVar, type_check_only
from .exceptions import (
AmbiguousTimeError as AmbiguousTimeError,
@@ -12,6 +12,7 @@ from .exceptions import (
from .tzinfo import BaseTzInfo as BaseTzInfo, DstTzInfo, StaticTzInfo
# Actually named UTC and then masked with a singleton with the same name
@type_check_only
class _UTCclass(BaseTzInfo):
def localize(self, dt: datetime.datetime, is_dst: bool | None = False) -> datetime.datetime: ...
def normalize(self, dt: datetime.datetime, is_dst: bool | None = False) -> datetime.datetime: ...
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from typing import type_check_only
from reportlab.graphics.shapes import Rect
from reportlab.graphics.widgetbase import Widget
@@ -7,11 +8,13 @@ from reportlab.platypus.flowables import Flowable
__all__ = ["QrCodeWidget"]
@type_check_only
class _isLevel(Validator):
def test(self, x): ...
isLevel: _isLevel
@type_check_only
class _isUnicodeOrQRList(Validator):
def test(self, x): ...
def normalize(self, x): ...

Some files were not shown because too many files have changed in this diff Show More