From d39912fdecc67f33333753598e3b1562122f3369 Mon Sep 17 00:00:00 2001 From: Brian Schubert Date: Sun, 27 Jul 2025 19:47:19 -0400 Subject: [PATCH] Mark stub-only private symbols as @type_check_only in third-party stubs --- stubs/Authlib/authlib/oauth2/rfc6750/token.pyi | 3 ++- stubs/Flask-Cors/flask_cors/core.pyi | 3 ++- stubs/Flask-Migrate/flask_migrate/__init__.pyi | 3 ++- stubs/Flask-SocketIO/flask_socketio/__init__.pyi | 7 ++++++- stubs/Flask-SocketIO/flask_socketio/namespace.pyi | 3 ++- stubs/Flask-SocketIO/flask_socketio/test_client.pyi | 3 ++- stubs/JACK-Client/jack/__init__.pyi | 4 +++- stubs/Markdown/markdown/extensions/toc.pyi | 4 +++- stubs/Markdown/markdown/util.pyi | 3 ++- stubs/PyYAML/yaml/emitter.pyi | 3 ++- stubs/Pygments/pygments/style.pyi | 3 ++- stubs/WTForms/wtforms/fields/core.pyi | 4 +++- stubs/WTForms/wtforms/form.pyi | 3 ++- stubs/WTForms/wtforms/i18n.pyi | 3 ++- stubs/WTForms/wtforms/meta.pyi | 6 +++++- stubs/WebOb/webob/acceptparse.pyi | 3 ++- stubs/WebOb/webob/cookies.pyi | 3 ++- stubs/WebOb/webob/dec.pyi | 3 ++- stubs/WebOb/webob/exc.pyi | 3 ++- stubs/WebOb/webob/multidict.pyi | 3 ++- stubs/WebOb/webob/request.pyi | 4 +++- stubs/WebOb/webob/response.pyi | 4 +++- stubs/aiofiles/aiofiles/threadpool/binary.pyi | 2 ++ stubs/aiofiles/aiofiles/threadpool/text.pyi | 3 ++- stubs/bleach/bleach/callbacks.pyi | 3 ++- stubs/bleach/bleach/html5lib_shim.pyi | 3 ++- stubs/boltons/boltons/setutils.pyi | 3 ++- stubs/boltons/boltons/typeutils.pyi | 3 ++- stubs/braintree/braintree/util/graphql_client.pyi | 6 +++++- stubs/cffi/_cffi_backend.pyi | 3 ++- stubs/click-spinner/click_spinner/__init__.pyi | 3 ++- stubs/croniter/croniter/croniter.pyi | 3 ++- stubs/dateparser/dateparser/__init__.pyi | 3 ++- stubs/defusedxml/defusedxml/lxml.pyi | 3 ++- stubs/defusedxml/defusedxml/xmlrpc.pyi | 4 ++-- stubs/docker/docker/models/containers.pyi | 3 ++- stubs/docker/docker/utils/proxy.pyi | 4 +++- stubs/dockerfile-parse/dockerfile_parse/parser.pyi | 3 ++- stubs/docutils/docutils/nodes.pyi | 3 ++- stubs/fanstatic/fanstatic/injector.pyi | 5 ++++- stubs/fpdf2/fpdf/encryption.pyi | 3 ++- stubs/gdb/gdb/__init__.pyi | 4 ++++ stubs/gdb/gdb/types.pyi | 5 +++-- stubs/gdb/gdb/xmethod.pyi | 5 +++-- stubs/geopandas/geopandas/io/file.pyi | 4 ++-- stubs/geopandas/geopandas/io/sql.pyi | 6 +++++- stubs/gevent/gevent/_config.pyi | 3 ++- stubs/gevent/gevent/_ffi/loop.pyi | 3 ++- stubs/gevent/gevent/_hub_primitives.pyi | 3 ++- stubs/gevent/gevent/baseserver.pyi | 3 ++- stubs/gevent/gevent/event.pyi | 3 ++- stubs/gevent/gevent/events.pyi | 3 ++- stubs/gevent/gevent/hub.pyi | 3 ++- stubs/gevent/gevent/pywsgi.pyi | 3 ++- stubs/gevent/gevent/resolver/ares.pyi | 3 ++- stubs/gevent/gevent/server.pyi | 3 ++- stubs/gevent/gevent/timeout.pyi | 3 ++- stubs/greenlet/greenlet/_greenlet.pyi | 3 ++- stubs/html5lib/html5lib/_inputstream.pyi | 3 ++- stubs/hvac/hvac/adapters.pyi | 3 ++- stubs/hvac/hvac/utils.pyi | 3 ++- stubs/icalendar/icalendar/prop.pyi | 3 ++- stubs/jmespath/jmespath/ast.pyi | 3 ++- stubs/jmespath/jmespath/functions.pyi | 3 ++- stubs/jmespath/jmespath/lexer.pyi | 3 ++- stubs/jmespath/jmespath/visitor.pyi | 3 ++- stubs/jsonschema/jsonschema/validators.pyi | 3 ++- stubs/mock/mock/mock.pyi | 3 ++- .../oauthlib/oauth2/rfc6749/request_validator.pyi | 4 +++- stubs/openpyxl/openpyxl/__init__.pyi | 3 ++- stubs/openpyxl/openpyxl/descriptors/sequence.pyi | 5 ++++- stubs/openpyxl/openpyxl/descriptors/serialisable.pyi | 5 ++++- stubs/openpyxl/openpyxl/worksheet/_writer.pyi | 3 ++- stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi | 3 ++- stubs/paramiko/paramiko/agent.pyi | 3 ++- stubs/paramiko/paramiko/client.pyi | 3 ++- stubs/paramiko/paramiko/hostkeys.pyi | 4 +++- stubs/paramiko/paramiko/message.pyi | 3 ++- stubs/paramiko/paramiko/pipe.pyi | 4 +++- stubs/paramiko/paramiko/transport.pyi | 3 ++- stubs/pexpect/pexpect/spawnbase.pyi | 3 ++- stubs/pika/pika/credentials.pyi | 3 ++- .../protobuf/google/protobuf/internal/containers.pyi | 3 ++- .../google/protobuf/internal/enum_type_wrapper.pyi | 3 ++- .../google/protobuf/internal/extension_dict.pyi | 3 ++- .../google/protobuf/internal/well_known_types.pyi | 9 --------- stubs/psycopg2/psycopg2/_psycopg.pyi | 2 ++ stubs/pycocotools/pycocotools/__init__.pyi | 3 ++- stubs/pycocotools/pycocotools/coco.pyi | 8 +++++++- stubs/pycocotools/pycocotools/cocoeval.pyi | 4 +++- stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi | 3 ++- stubs/pynput/pynput/_util.pyi | 3 ++- stubs/pyserial/serial/urlhandler/protocol_spy.pyi | 4 ++-- stubs/python-dateutil/dateutil/tz/_common.pyi | 4 ---- stubs/python-dateutil/dateutil/tz/tz.pyi | 6 +++++- stubs/python-nmap/nmap/nmap.pyi | 10 +++++++++- stubs/python-xlib/Xlib/display.pyi | 3 ++- stubs/python-xlib/Xlib/rdb.pyi | 3 ++- stubs/pytz/pytz/__init__.pyi | 3 ++- stubs/reportlab/reportlab/graphics/barcode/qr.pyi | 3 +++ stubs/reportlab/reportlab/graphics/shapes.pyi | 12 +++++++++++- stubs/reportlab/reportlab/lib/colors.pyi | 5 +++-- stubs/reportlab/reportlab/lib/rparsexml.pyi | 2 ++ stubs/reportlab/reportlab/lib/utils.pyi | 3 ++- stubs/reportlab/reportlab/platypus/doctemplate.pyi | 3 ++- stubs/reportlab/reportlab/platypus/flowables.pyi | 3 ++- stubs/reportlab/reportlab/platypus/para.pyi | 5 ++++- .../reportlab/reportlab/platypus/tableofcontents.pyi | 4 +++- .../requests_oauthlib/oauth1_session.pyi | 3 ++- .../requests_oauthlib/oauth2_session.pyi | 6 +++++- stubs/requests/requests/adapters.pyi | 4 +++- stubs/requests/requests/help.pyi | 8 +++++++- stubs/requests/requests/sessions.pyi | 3 ++- stubs/seaborn/seaborn/distributions.pyi | 3 ++- stubs/seaborn/seaborn/external/kde.pyi | 3 ++- .../setuptools/setuptools/command/editable_wheel.pyi | 1 - stubs/setuptools/setuptools/config/pyprojecttoml.pyi | 4 ---- stubs/singledispatch/singledispatch.pyi | 3 ++- stubs/toposort/toposort.pyi | 3 ++- stubs/tqdm/tqdm/dask.pyi | 3 ++- stubs/tqdm/tqdm/rich.pyi | 3 ++- stubs/tqdm/tqdm/utils.pyi | 3 ++- .../translationstring/translationstring/__init__.pyi | 8 +++++++- stubs/uWSGI/uwsgi.pyi | 3 ++- stubs/watchpoints/watchpoints/watch.pyi | 3 ++- stubs/wurlitzer/wurlitzer.pyi | 3 ++- stubs/zxcvbn/zxcvbn/__init__.pyi | 3 ++- stubs/zxcvbn/zxcvbn/feedback.pyi | 3 ++- stubs/zxcvbn/zxcvbn/matching.pyi | 6 ++++-- stubs/zxcvbn/zxcvbn/scoring.pyi | 3 ++- stubs/zxcvbn/zxcvbn/time_estimates.pyi | 5 ++++- 131 files changed, 334 insertions(+), 147 deletions(-) diff --git a/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi b/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi index 63a388bdb65d..bd521552611f 100644 --- a/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi +++ b/stubs/Authlib/authlib/oauth2/rfc6750/token.pyi @@ -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: ... diff --git a/stubs/Flask-Cors/flask_cors/core.pyi b/stubs/Flask-Cors/flask_cors/core.pyi index 176e8905eab1..f2ae68861d68 100644 --- a/stubs/Flask-Cors/flask_cors/core.pyi +++ b/stubs/Flask-Cors/flask_cors/core.pyi @@ -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 diff --git a/stubs/Flask-Migrate/flask_migrate/__init__.pyi b/stubs/Flask-Migrate/flask_migrate/__init__.pyi index 4d7664402c46..41c0f76741fd 100644 --- a/stubs/Flask-Migrate/flask_migrate/__init__.pyi +++ b/stubs/Flask-Migrate/flask_migrate/__init__.pyi @@ -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 diff --git a/stubs/Flask-SocketIO/flask_socketio/__init__.pyi b/stubs/Flask-SocketIO/flask_socketio/__init__.pyi index 1b20806fda6c..8fa0c25a66fc 100644 --- a/stubs/Flask-SocketIO/flask_socketio/__init__.pyi +++ b/stubs/Flask-SocketIO/flask_socketio/__init__.pyi @@ -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: diff --git a/stubs/Flask-SocketIO/flask_socketio/namespace.pyi b/stubs/Flask-SocketIO/flask_socketio/namespace.pyi index 50ef75dceba2..94ec7b716dd2 100644 --- a/stubs/Flask-SocketIO/flask_socketio/namespace.pyi +++ b/stubs/Flask-SocketIO/flask_socketio/namespace.pyi @@ -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): ... diff --git a/stubs/Flask-SocketIO/flask_socketio/test_client.pyi b/stubs/Flask-SocketIO/flask_socketio/test_client.pyi index 62f27781c868..15cf426959a0 100644 --- a/stubs/Flask-SocketIO/flask_socketio/test_client.pyi +++ b/stubs/Flask-SocketIO/flask_socketio/test_client.pyi @@ -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 diff --git a/stubs/JACK-Client/jack/__init__.pyi b/stubs/JACK-Client/jack/__init__.pyi index 0644f983e694..e72b328a44f5 100644 --- a/stubs/JACK-Client/jack/__init__.pyi +++ b/stubs/JACK-Client/jack/__init__.pyi @@ -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 # 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: ... diff --git a/stubs/Markdown/markdown/extensions/toc.pyi b/stubs/Markdown/markdown/extensions/toc.pyi index 65efb86bfa64..27fd77b833ff 100644 --- a/stubs/Markdown/markdown/extensions/toc.pyi +++ b/stubs/Markdown/markdown/extensions/toc.pyi @@ -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] diff --git a/stubs/Markdown/markdown/util.pyi b/stubs/Markdown/markdown/util.pyi index 672c31a2449c..f30f9e08432c 100644 --- a/stubs/Markdown/markdown/util.pyi +++ b/stubs/Markdown/markdown/util.pyi @@ -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] diff --git a/stubs/PyYAML/yaml/emitter.pyi b/stubs/PyYAML/yaml/emitter.pyi index 68808c751095..ca60ac35442c 100644 --- a/stubs/PyYAML/yaml/emitter.pyi +++ b/stubs/PyYAML/yaml/emitter.pyi @@ -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: diff --git a/stubs/Pygments/pygments/style.pyi b/stubs/Pygments/pygments/style.pyi index e18f2adaee85..154f822ac480 100644 --- a/stubs/Pygments/pygments/style.pyi +++ b/stubs/Pygments/pygments/style.pyi @@ -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 diff --git a/stubs/WTForms/wtforms/fields/core.pyi b/stubs/WTForms/wtforms/fields/core.pyi index c0972d0ca399..49966fe751cb 100644 --- a/stubs/WTForms/wtforms/fields/core.pyi +++ b/stubs/WTForms/wtforms/fields/core.pyi @@ -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: ... diff --git a/stubs/WTForms/wtforms/form.pyi b/stubs/WTForms/wtforms/form.pyi index c108954471e0..7c47bfe5644a 100644 --- a/stubs/WTForms/wtforms/form.pyi +++ b/stubs/WTForms/wtforms/form.pyi @@ -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: ... diff --git a/stubs/WTForms/wtforms/i18n.pyi b/stubs/WTForms/wtforms/i18n.pyi index a0f5e237e20e..4ebb609168fc 100644 --- a/stubs/WTForms/wtforms/i18n.pyi +++ b/stubs/WTForms/wtforms/i18n.pyi @@ -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: ... diff --git a/stubs/WTForms/wtforms/meta.pyi b/stubs/WTForms/wtforms/meta.pyi index 83181cab93f2..e90a6b4fc066 100644 --- a/stubs/WTForms/wtforms/meta.pyi +++ b/stubs/WTForms/wtforms/meta.pyi @@ -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]: ... diff --git a/stubs/WebOb/webob/acceptparse.pyi b/stubs/WebOb/webob/acceptparse.pyi index 5b3043e7b2ce..069564e86749 100644 --- a/stubs/WebOb/webob/acceptparse.pyi +++ b/stubs/WebOb/webob/acceptparse.pyi @@ -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 diff --git a/stubs/WebOb/webob/cookies.pyi b/stubs/WebOb/webob/cookies.pyi index 8a9632102775..ac39a569f270 100644 --- a/stubs/WebOb/webob/cookies.pyi +++ b/stubs/WebOb/webob/cookies.pyi @@ -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: ... diff --git a/stubs/WebOb/webob/dec.pyi b/stubs/WebOb/webob/dec.pyi index 41478ba2fb48..4b5198a46a72 100644 --- a/stubs/WebOb/webob/dec.pyi +++ b/stubs/WebOb/webob/dec.pyi @@ -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]: ... diff --git a/stubs/WebOb/webob/exc.pyi b/stubs/WebOb/webob/exc.pyi index da9ee25cf563..d2cdb2f11ce4 100644 --- a/stubs/WebOb/webob/exc.pyi +++ b/stubs/WebOb/webob/exc.pyi @@ -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: ... diff --git a/stubs/WebOb/webob/multidict.pyi b/stubs/WebOb/webob/multidict.pyi index 6215d00792cd..84815c7cfb65 100644 --- a/stubs/WebOb/webob/multidict.pyi +++ b/stubs/WebOb/webob/multidict.pyi @@ -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]]: ... diff --git a/stubs/WebOb/webob/request.pyi b/stubs/WebOb/webob/request.pyi index c562838f7b7b..310c2101ce98 100644 --- a/stubs/WebOb/webob/request.pyi +++ b/stubs/WebOb/webob/request.pyi @@ -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 diff --git a/stubs/WebOb/webob/response.pyi b/stubs/WebOb/webob/response.pyi index 4a22b3530adc..27d1e90dff04 100644 --- a/stubs/WebOb/webob/response.pyi +++ b/stubs/WebOb/webob/response.pyi @@ -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 diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index d10f98f2a242..2a02d55752ec 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -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: ... diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index 6003a0852c31..6c6bf20a408c 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -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: ... diff --git a/stubs/bleach/bleach/callbacks.pyi b/stubs/bleach/bleach/callbacks.pyi index 5e497cc70328..2e92a8645cfb 100644 --- a/stubs/bleach/bleach/callbacks.pyi +++ b/stubs/bleach/bleach/callbacks.pyi @@ -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: ... diff --git a/stubs/bleach/bleach/html5lib_shim.pyi b/stubs/bleach/bleach/html5lib_shim.pyi index 792de6da4418..d24c2d825f33 100644 --- a/stubs/bleach/bleach/html5lib_shim.pyi +++ b/stubs/bleach/bleach/html5lib_shim.pyi @@ -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 diff --git a/stubs/boltons/boltons/setutils.pyi b/stubs/boltons/boltons/setutils.pyi index 576687a763a7..47a9cfe4f43b 100644 --- a/stubs/boltons/boltons/setutils.pyi +++ b/stubs/boltons/boltons/setutils.pyi @@ -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]: ... diff --git a/stubs/boltons/boltons/typeutils.pyi b/stubs/boltons/boltons/typeutils.pyi index 8eee8e4dcf06..c2ae45147c94 100644 --- a/stubs/boltons/boltons/typeutils.pyi +++ b/stubs/boltons/boltons/typeutils.pyi @@ -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: ... diff --git a/stubs/braintree/braintree/util/graphql_client.pyi b/stubs/braintree/braintree/util/graphql_client.pyi index 35c5d3def76c..60792398addd 100644 --- a/stubs/braintree/braintree/util/graphql_client.pyi +++ b/stubs/braintree/braintree/util/graphql_client.pyi @@ -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 diff --git a/stubs/cffi/_cffi_backend.pyi b/stubs/cffi/_cffi_backend.pyi index b063e9bc8378..4a3810b4d9a2 100644 --- a/stubs/cffi/_cffi_backend.pyi +++ b/stubs/cffi/_cffi_backend.pyi @@ -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: ... diff --git a/stubs/click-spinner/click_spinner/__init__.pyi b/stubs/click-spinner/click_spinner/__init__.pyi index 6093bb0f4c01..9bde16cff242 100644 --- a/stubs/click-spinner/click_spinner/__init__.pyi +++ b/stubs/click-spinner/click_spinner/__init__.pyi @@ -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: ... diff --git a/stubs/croniter/croniter/croniter.pyi b/stubs/croniter/croniter/croniter.pyi index 3b5319c195f8..7dd721ddbb2a 100644 --- a/stubs/croniter/croniter/croniter.pyi +++ b/stubs/croniter/croniter/croniter.pyi @@ -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__( diff --git a/stubs/dateparser/dateparser/__init__.pyi b/stubs/dateparser/dateparser/__init__.pyi index 4d259de3ae65..d12a9b7281e5 100644 --- a/stubs/dateparser/dateparser/__init__.pyi +++ b/stubs/dateparser/dateparser/__init__.pyi @@ -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 diff --git a/stubs/defusedxml/defusedxml/lxml.pyi b/stubs/defusedxml/defusedxml/lxml.pyi index 1bf8c8fd41fd..77f1de2d4b97 100644 --- a/stubs/defusedxml/defusedxml/lxml.pyi +++ b/stubs/defusedxml/defusedxml/lxml.pyi @@ -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): diff --git a/stubs/defusedxml/defusedxml/xmlrpc.pyi b/stubs/defusedxml/defusedxml/xmlrpc.pyi index b2154123b70a..da38c6870004 100644 --- a/stubs/defusedxml/defusedxml/xmlrpc.pyi +++ b/stubs/defusedxml/defusedxml/xmlrpc.pyi @@ -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: ... diff --git a/stubs/docker/docker/models/containers.pyi b/stubs/docker/docker/models/containers.pyi index 4d167e419762..706ffc609fe9 100644 --- a/stubs/docker/docker/models/containers.pyi +++ b/stubs/docker/docker/models/containers.pyi @@ -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"]] diff --git a/stubs/docker/docker/utils/proxy.pyi b/stubs/docker/docker/utils/proxy.pyi index f1563618d14b..a8e84d1a6ba1 100644 --- a/stubs/docker/docker/utils/proxy.pyi +++ b/stubs/docker/docker/utils/proxy.pyi @@ -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] diff --git a/stubs/dockerfile-parse/dockerfile_parse/parser.pyi b/stubs/dockerfile-parse/dockerfile_parse/parser.pyi index a5e74082f522..fbaa98096332 100644 --- a/stubs/dockerfile-parse/dockerfile_parse/parser.pyi +++ b/stubs/dockerfile-parse/dockerfile_parse/parser.pyi @@ -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 diff --git a/stubs/docutils/docutils/nodes.pyi b/stubs/docutils/docutils/nodes.pyi index fb9fcf0eb9b6..1089057deecf 100644 --- a/stubs/docutils/docutils/nodes.pyi +++ b/stubs/docutils/docutils/nodes.pyi @@ -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] diff --git a/stubs/fanstatic/fanstatic/injector.pyi b/stubs/fanstatic/fanstatic/injector.pyi index aed0ad9b4c8f..5d387b99d65a 100644 --- a/stubs/fanstatic/fanstatic/injector.pyi +++ b/stubs/fanstatic/fanstatic/injector.pyi @@ -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 diff --git a/stubs/fpdf2/fpdf/encryption.pyi b/stubs/fpdf2/fpdf/encryption.pyi index 55c72a1d1d52..3c3edabd53f4 100644 --- a/stubs/fpdf2/fpdf/encryption.pyi +++ b/stubs/fpdf2/fpdf/encryption.pyi @@ -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: ... diff --git a/stubs/gdb/gdb/__init__.pyi b/stubs/gdb/gdb/__init__.pyi index 45980500debc..ac614b88a036 100644 --- a/stubs/gdb/gdb/__init__.pyi +++ b/stubs/gdb/gdb/__init__.pyi @@ -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): diff --git a/stubs/gdb/gdb/types.pyi b/stubs/gdb/gdb/types.pyi index d87eeb3bec99..e74472a5d10a 100644 --- a/stubs/gdb/gdb/types.pyi +++ b/stubs/gdb/gdb/types.pyi @@ -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: ... diff --git a/stubs/gdb/gdb/xmethod.pyi b/stubs/gdb/gdb/xmethod.pyi index f61708ae62cf..9c0a2f34d0d7 100644 --- a/stubs/gdb/gdb/xmethod.pyi +++ b/stubs/gdb/gdb/xmethod.pyi @@ -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: ... diff --git a/stubs/geopandas/geopandas/io/file.pyi b/stubs/geopandas/geopandas/io/file.pyi index 1ba0af5bf8f3..75efae95093a 100644 --- a/stubs/geopandas/geopandas/io/file.pyi +++ b/stubs/geopandas/geopandas/io/file.pyi @@ -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] diff --git a/stubs/geopandas/geopandas/io/sql.pyi b/stubs/geopandas/geopandas/io/sql.pyi index 743439f873b8..d498da5064c9 100644 --- a/stubs/geopandas/geopandas/io/sql.pyi +++ b/stubs/geopandas/geopandas/io/sql.pyi @@ -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 diff --git a/stubs/gevent/gevent/_config.pyi b/stubs/gevent/gevent/_config.pyi index a7824ba9714e..af42269bffbe 100644 --- a/stubs/gevent/gevent/_config.pyi +++ b/stubs/gevent/gevent/_config.pyi @@ -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: ... diff --git a/stubs/gevent/gevent/_ffi/loop.pyi b/stubs/gevent/gevent/_ffi/loop.pyi index 7bd152d277e0..76ee24f08fe3 100644 --- a/stubs/gevent/gevent/_ffi/loop.pyi +++ b/stubs/gevent/gevent/_ffi/loop.pyi @@ -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 diff --git a/stubs/gevent/gevent/_hub_primitives.pyi b/stubs/gevent/gevent/_hub_primitives.pyi index f0cfe8a6836b..e308682edc42 100644 --- a/stubs/gevent/gevent/_hub_primitives.pyi +++ b/stubs/gevent/gevent/_hub_primitives.pyi @@ -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: ... diff --git a/stubs/gevent/gevent/baseserver.pyi b/stubs/gevent/gevent/baseserver.pyi index aa5308ec0b92..dcdb4737bcd2 100644 --- a/stubs/gevent/gevent/baseserver.pyi +++ b/stubs/gevent/gevent/baseserver.pyi @@ -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: ... diff --git a/stubs/gevent/gevent/event.pyi b/stubs/gevent/gevent/event.pyi index b6b827da36b9..6a3211b49fec 100644 --- a/stubs/gevent/gevent/event.pyi +++ b/stubs/gevent/gevent/event.pyi @@ -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 diff --git a/stubs/gevent/gevent/events.pyi b/stubs/gevent/gevent/events.pyi index de1913d501eb..ffc491711f26 100644 --- a/stubs/gevent/gevent/events.pyi +++ b/stubs/gevent/gevent/events.pyi @@ -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: ... diff --git a/stubs/gevent/gevent/hub.pyi b/stubs/gevent/gevent/hub.pyi index 4e4d409b59b4..84ec26d9a933 100644 --- a/stubs/gevent/gevent/hub.pyi +++ b/stubs/gevent/gevent/hub.pyi @@ -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: ... diff --git a/stubs/gevent/gevent/pywsgi.pyi b/stubs/gevent/gevent/pywsgi.pyi index 91400018eabd..2d014a042a99 100644 --- a/stubs/gevent/gevent/pywsgi.pyi +++ b/stubs/gevent/gevent/pywsgi.pyi @@ -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: ... diff --git a/stubs/gevent/gevent/resolver/ares.pyi b/stubs/gevent/gevent/resolver/ares.pyi index 29c5ea0cb843..ca16b3cf1dc1 100644 --- a/stubs/gevent/gevent/resolver/ares.pyi +++ b/stubs/gevent/gevent/resolver/ares.pyi @@ -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 diff --git a/stubs/gevent/gevent/server.pyi b/stubs/gevent/gevent/server.pyi index 712754d4ee2a..09cf8c64f37a 100644 --- a/stubs/gevent/gevent/server.pyi +++ b/stubs/gevent/gevent/server.pyi @@ -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 diff --git a/stubs/gevent/gevent/timeout.pyi b/stubs/gevent/gevent/timeout.pyi index 3fff1e511c8a..bb276524c49d 100644 --- a/stubs/gevent/gevent/timeout.pyi +++ b/stubs/gevent/gevent/timeout.pyi @@ -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: ... diff --git a/stubs/greenlet/greenlet/_greenlet.pyi b/stubs/greenlet/greenlet/_greenlet.pyi index ed2dac474595..aafc728fa4e3 100644 --- a/stubs/greenlet/greenlet/_greenlet.pyi +++ b/stubs/greenlet/greenlet/_greenlet.pyi @@ -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: ... diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi index cfd1b2f015c9..9f10e4dbf98e 100644 --- a/stubs/html5lib/html5lib/_inputstream.pyi +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -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 diff --git a/stubs/hvac/hvac/adapters.pyi b/stubs/hvac/hvac/adapters.pyi index 5cc6e1ebf7b7..3bd1b3e0d981 100644 --- a/stubs/hvac/hvac/adapters.pyi +++ b/stubs/hvac/hvac/adapters.pyi @@ -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( diff --git a/stubs/hvac/hvac/utils.pyi b/stubs/hvac/hvac/utils.pyi index 5eaf5803bc3e..0afd5dc74e86 100644 --- a/stubs/hvac/hvac/utils.pyi +++ b/stubs/hvac/hvac/utils.pyi @@ -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 diff --git a/stubs/icalendar/icalendar/prop.pyi b/stubs/icalendar/icalendar/prop.pyi index 7ac00bcd7c51..a3e0c389f32d 100644 --- a/stubs/icalendar/icalendar/prop.pyi +++ b/stubs/icalendar/icalendar/prop.pyi @@ -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: ... diff --git a/stubs/jmespath/jmespath/ast.pyi b/stubs/jmespath/jmespath/ast.pyi index a9ee32a7c6b4..d8c75d0abdde 100644 --- a/stubs/jmespath/jmespath/ast.pyi +++ b/stubs/jmespath/jmespath/ast.pyi @@ -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] diff --git a/stubs/jmespath/jmespath/functions.pyi b/stubs/jmespath/jmespath/functions.pyi index f9c212e4823e..4d657f4c49ea 100644 --- a/stubs/jmespath/jmespath/functions.pyi +++ b/stubs/jmespath/jmespath/functions.pyi @@ -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] diff --git a/stubs/jmespath/jmespath/lexer.pyi b/stubs/jmespath/jmespath/lexer.pyi index ac89d2e1e667..0e26ebc18888 100644 --- a/stubs/jmespath/jmespath/lexer.pyi +++ b/stubs/jmespath/jmespath/lexer.pyi @@ -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 diff --git a/stubs/jmespath/jmespath/visitor.pyi b/stubs/jmespath/jmespath/visitor.pyi index fb8c3f63dd9a..5789b39b018e 100644 --- a/stubs/jmespath/jmespath/visitor.pyi +++ b/stubs/jmespath/jmespath/visitor.pyi @@ -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 diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index 41b56e2d0e64..192aa125cdf8 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -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]] diff --git a/stubs/mock/mock/mock.pyi b/stubs/mock/mock/mock.pyi index a4ad35e575cb..bd241cf01988 100644 --- a/stubs/mock/mock/mock.pyi +++ b/stubs/mock/mock/mock.pyi @@ -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] diff --git a/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi b/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi index 136463863251..4c60b62ec170 100644 --- a/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi +++ b/stubs/oauthlib/oauthlib/oauth2/rfc6749/request_validator.pyi @@ -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] diff --git a/stubs/openpyxl/openpyxl/__init__.pyi b/stubs/openpyxl/openpyxl/__init__.pyi index de5224812ce7..627a7afc5720 100644 --- a/stubs/openpyxl/openpyxl/__init__.pyi +++ b/stubs/openpyxl/openpyxl/__init__.pyi @@ -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: ... diff --git a/stubs/openpyxl/openpyxl/descriptors/sequence.pyi b/stubs/openpyxl/openpyxl/descriptors/sequence.pyi index 246ab1164f19..ba5cb0640f08 100644 --- a/stubs/openpyxl/openpyxl/descriptors/sequence.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/sequence.pyi @@ -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`. diff --git a/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi b/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi index eee7d3bce7ea..b9e62a294ef3 100644 --- a/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/serialisable.pyi @@ -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]] diff --git a/stubs/openpyxl/openpyxl/worksheet/_writer.pyi b/stubs/openpyxl/openpyxl/worksheet/_writer.pyi index 6261170ee21d..92ca8dc7b9a6 100644 --- a/stubs/openpyxl/openpyxl/worksheet/_writer.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/_writer.pyi @@ -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: ... diff --git a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi index d26a47dc59f8..d1f955ab2ad9 100644 --- a/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi +++ b/stubs/openpyxl/openpyxl/worksheet/datavalidation.pyi @@ -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 diff --git a/stubs/paramiko/paramiko/agent.pyi b/stubs/paramiko/paramiko/agent.pyi index 9c5c10c79890..16621e9fa5d2 100644 --- a/stubs/paramiko/paramiko/agent.pyi +++ b/stubs/paramiko/paramiko/agent.pyi @@ -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: ... diff --git a/stubs/paramiko/paramiko/client.pyi b/stubs/paramiko/paramiko/client.pyi index 6462fcd8cffd..805347da6c9f 100644 --- a/stubs/paramiko/paramiko/client.pyi +++ b/stubs/paramiko/paramiko/client.pyi @@ -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, diff --git a/stubs/paramiko/paramiko/hostkeys.pyi b/stubs/paramiko/paramiko/hostkeys.pyi index 5c9031b7da33..c9d93b374af9 100644 --- a/stubs/paramiko/paramiko/hostkeys.pyi +++ b/stubs/paramiko/paramiko/hostkeys.pyi @@ -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: ... diff --git a/stubs/paramiko/paramiko/message.pyi b/stubs/paramiko/paramiko/message.pyi index ac6a9decd1f4..ef87f97b4eb2 100644 --- a/stubs/paramiko/paramiko/message.pyi +++ b/stubs/paramiko/paramiko/message.pyi @@ -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: ... diff --git a/stubs/paramiko/paramiko/pipe.pyi b/stubs/paramiko/paramiko/pipe.pyi index e9b1635ec2bc..4cc8e54b09b4 100644 --- a/stubs/paramiko/paramiko/pipe.pyi +++ b/stubs/paramiko/paramiko/pipe.pyi @@ -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: ... diff --git a/stubs/paramiko/paramiko/transport.pyi b/stubs/paramiko/paramiko/transport.pyi index e34987c9be52..e5deb762e5c7 100644 --- a/stubs/paramiko/paramiko/transport.pyi +++ b/stubs/paramiko/paramiko/transport.pyi @@ -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: ... diff --git a/stubs/pexpect/pexpect/spawnbase.pyi b/stubs/pexpect/pexpect/spawnbase.pyi index 384606784601..b236faeb7053 100644 --- a/stubs/pexpect/pexpect/spawnbase.pyi +++ b/stubs/pexpect/pexpect/spawnbase.pyi @@ -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: ... diff --git a/stubs/pika/pika/credentials.pyi b/stubs/pika/pika/credentials.pyi index 5fba83c452a3..9e6288b7b5f4 100644 --- a/stubs/pika/pika/credentials.pyi +++ b/stubs/pika/pika/credentials.pyi @@ -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 diff --git a/stubs/protobuf/google/protobuf/internal/containers.pyi b/stubs/protobuf/google/protobuf/internal/containers.pyi index 1431c3b1379d..99c6efa160d8 100644 --- a/stubs/protobuf/google/protobuf/internal/containers.pyi +++ b/stubs/protobuf/google/protobuf/internal/containers.pyi @@ -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: ... diff --git a/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi b/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi index 95b5b4bb2566..ca207f214950 100644 --- a/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi +++ b/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi @@ -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: ... diff --git a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi index ecf56a360d20..3071e4aa2ade 100644 --- a/stubs/protobuf/google/protobuf/internal/extension_dict.pyi +++ b/stubs/protobuf/google/protobuf/internal/extension_dict.pyi @@ -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]): diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index 4ed2f895c762..8e9e19618881 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -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] diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index abb744901c03..0b790fda51df 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -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: diff --git a/stubs/pycocotools/pycocotools/__init__.pyi b/stubs/pycocotools/pycocotools/__init__.pyi index 04adef9dad84..129b5a07c312 100644 --- a/stubs/pycocotools/pycocotools/__init__.pyi +++ b/stubs/pycocotools/pycocotools/__init__.pyi @@ -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 diff --git a/stubs/pycocotools/pycocotools/coco.pyi b/stubs/pycocotools/pycocotools/coco.pyi index dfb4b3ca4c7c..2dc2f2e35ca4 100644 --- a/stubs/pycocotools/pycocotools/coco.pyi +++ b/stubs/pycocotools/pycocotools/coco.pyi @@ -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] diff --git a/stubs/pycocotools/pycocotools/cocoeval.pyi b/stubs/pycocotools/pycocotools/cocoeval.pyi index 262b9dc3f8dd..e402feaf4214 100644 --- a/stubs/pycocotools/pycocotools/cocoeval.pyi +++ b/stubs/pycocotools/pycocotools/cocoeval.pyi @@ -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] diff --git a/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi index 26878976bdaa..0fc169607cc0 100644 --- a/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi +++ b/stubs/pyinstaller/PyInstaller/utils/hooks/conda.pyi @@ -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 diff --git a/stubs/pynput/pynput/_util.pyi b/stubs/pynput/pynput/_util.pyi index c561e504bca2..a0e8904770d3 100644 --- a/stubs/pynput/pynput/_util.pyi +++ b/stubs/pynput/pynput/_util.pyi @@ -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 diff --git a/stubs/pyserial/serial/urlhandler/protocol_spy.pyi b/stubs/pyserial/serial/urlhandler/protocol_spy.pyi index b5c6d243ef40..e1454586fabe 100644 --- a/stubs/pyserial/serial/urlhandler/protocol_spy.pyi +++ b/stubs/pyserial/serial/urlhandler/protocol_spy.pyi @@ -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: ... diff --git a/stubs/python-dateutil/dateutil/tz/_common.pyi b/stubs/python-dateutil/dateutil/tz/_common.pyi index 327cbc8f9359..7e9b8957c34b 100644 --- a/stubs/python-dateutil/dateutil/tz/_common.pyi +++ b/stubs/python-dateutil/dateutil/tz/_common.pyi @@ -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 diff --git a/stubs/python-dateutil/dateutil/tz/tz.pyi b/stubs/python-dateutil/dateutil/tz/tz.pyi index 45703de89761..242f8d11bbd0 100644 --- a/stubs/python-dateutil/dateutil/tz/tz.pyi +++ b/stubs/python-dateutil/dateutil/tz/tz.pyi @@ -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: ... diff --git a/stubs/python-nmap/nmap/nmap.pyi b/stubs/python-nmap/nmap/nmap.pyi index 9e4eb4d04692..884a9b363743 100644 --- a/stubs/python-nmap/nmap/nmap.pyi +++ b/stubs/python-nmap/nmap/nmap.pyi @@ -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 diff --git a/stubs/python-xlib/Xlib/display.pyi b/stubs/python-xlib/Xlib/display.pyi index 263f6e869476..535e3e2e0139 100644 --- a/stubs/python-xlib/Xlib/display.pyi +++ b/stubs/python-xlib/Xlib/display.pyi @@ -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] diff --git a/stubs/python-xlib/Xlib/rdb.pyi b/stubs/python-xlib/Xlib/rdb.pyi index a31cbff9c88f..e330353a01ec 100644 --- a/stubs/python-xlib/Xlib/rdb.pyi +++ b/stubs/python-xlib/Xlib/rdb.pyi @@ -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]] diff --git a/stubs/pytz/pytz/__init__.pyi b/stubs/pytz/pytz/__init__.pyi index 78b0a8c4e506..2f243cbb3bf4 100644 --- a/stubs/pytz/pytz/__init__.pyi +++ b/stubs/pytz/pytz/__init__.pyi @@ -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: ... diff --git a/stubs/reportlab/reportlab/graphics/barcode/qr.pyi b/stubs/reportlab/reportlab/graphics/barcode/qr.pyi index d680aa8b304d..817ba00d72e0 100644 --- a/stubs/reportlab/reportlab/graphics/barcode/qr.pyi +++ b/stubs/reportlab/reportlab/graphics/barcode/qr.pyi @@ -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): ... diff --git a/stubs/reportlab/reportlab/graphics/shapes.pyi b/stubs/reportlab/reportlab/graphics/shapes.pyi index e2fd9b268bd3..f9d290b79a2c 100644 --- a/stubs/reportlab/reportlab/graphics/shapes.pyi +++ b/stubs/reportlab/reportlab/graphics/shapes.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsItems from abc import abstractmethod from collections.abc import Iterable, Sequence -from typing import Any, Final, Literal, NoReturn, TypedDict +from typing import Any, Final, Literal, NoReturn, TypedDict, type_check_only from typing_extensions import Self, TypeAlias, Unpack from reportlab.lib.colors import Color @@ -25,6 +25,7 @@ _PathOp: TypeAlias = ( # NOTE: These are derived from _attrMap and can optionally be # verified at runtime +@type_check_only class _GroupKwArgs(TypedDict, total=False): transform: tuple[float, float, float, float, float, float] | list[float] | list[int] # NOTE: This should be used with care, since it will replace elements @@ -35,6 +36,7 @@ class _GroupKwArgs(TypedDict, total=False): fillOverprint: _BoolLike overprintMask: _BoolLike +@type_check_only class _DrawingKwArgs(_GroupKwArgs, total=False): # TODO: Restrict to supported formats? formats: list[str] | tuple[str, ...] @@ -50,6 +52,7 @@ class _DrawingKwArgs(_GroupKwArgs, total=False): initialFontName: str | None initialFontSize: float | None +@type_check_only class _LineShapeKwArgs(TypedDict, total=False): strokeColor: Color | None strokeWidth: float @@ -61,11 +64,13 @@ class _LineShapeKwArgs(TypedDict, total=False): strokeOverprint: _BoolLike overprintMask: _BoolLike +@type_check_only class _PathKwArgs(_LineShapeKwArgs, total=False): fillColor: Color | None fillOpacity: float fillOverprint: _BoolLike +@type_check_only class _AllPathKwArgs(_PathKwArgs, total=False): points: list[float] | None operators: list[float] | None @@ -73,17 +78,21 @@ class _AllPathKwArgs(_PathKwArgs, total=False): autoclose: Literal["svg", "pdf"] | None fillMode: Literal[0, 1] +@type_check_only class _SolidShapeKwArgs(_PathKwArgs, total=False): fillMode: Literal[0, 1] +@type_check_only class _DefinePathKwArgs(_SolidShapeKwArgs, total=False): autoclose: Literal["svg", "pdf"] | None bbox: tuple[float, float, float, float] | None +@type_check_only class _WedgeKwArgs(_SolidShapeKwArgs, total=False): radius1: float | None yradius1: float | None +@type_check_only class _StringKwArgs(TypedDict, total=False): fontName: str fontSize: float @@ -161,6 +170,7 @@ class Drawing(Group, Flowable): class _DrawingEditorMixin: ... +@type_check_only class _isStrokeDashArray(Validator): def test(self, x): ... diff --git a/stubs/reportlab/reportlab/lib/colors.pyi b/stubs/reportlab/reportlab/lib/colors.pyi index ed615bae2e1c..362233967f88 100644 --- a/stubs/reportlab/reportlab/lib/colors.pyi +++ b/stubs/reportlab/reportlab/lib/colors.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator -from typing import Final, Literal, TypeVar, overload +from typing import Final, Literal, TypeVar, overload, type_check_only from typing_extensions import Self, TypeAlias _ColorT = TypeVar("_ColorT", bound=Color) @@ -288,7 +288,7 @@ def describe(aColor: Color, mode: Literal[1]) -> str: ... def describe(aColor: Color, mode: Literal[2]) -> tuple[str, float]: ... def hue2rgb(m1: float, m2: float, h: float) -> float: ... def hsl2rgb(h: float, s: float, l: float) -> tuple[float, float, float]: ... - +@type_check_only class _cssParse: def pcVal(self, v: str) -> float: ... def rgbPcVal(self, v: str) -> float: ... @@ -300,6 +300,7 @@ class _cssParse: cssParse: _cssParse +@type_check_only class _toColor: extraColorsNS: dict[str, Color] def __init__(self) -> None: ... diff --git a/stubs/reportlab/reportlab/lib/rparsexml.pyi b/stubs/reportlab/reportlab/lib/rparsexml.pyi index 4bff57d0bd6a..62816ccd098f 100644 --- a/stubs/reportlab/reportlab/lib/rparsexml.pyi +++ b/stubs/reportlab/reportlab/lib/rparsexml.pyi @@ -1,8 +1,10 @@ from _typeshed import Incomplete +from typing import type_check_only RequirePyRXP: int simpleparse: int +@type_check_only class _smartDecode: @staticmethod def __call__(s): ... diff --git a/stubs/reportlab/reportlab/lib/utils.pyi b/stubs/reportlab/reportlab/lib/utils.pyi index bb22eef1f3f7..8aafa063ccf3 100644 --- a/stubs/reportlab/reportlab/lib/utils.pyi +++ b/stubs/reportlab/reportlab/lib/utils.pyi @@ -4,7 +4,7 @@ from _typeshed import Incomplete, SupportsItems from collections.abc import Generator, Iterable from os import PathLike from types import TracebackType -from typing import AnyStr, Final, Literal, TypeVar, overload +from typing import AnyStr, Final, Literal, TypeVar, overload, type_check_only from reportlab.lib.rltempfile import get_rl_tempdir as get_rl_tempdir, get_rl_tempfile as get_rl_tempfile @@ -19,6 +19,7 @@ _VT = TypeVar("_VT") __version__: Final[str] +@type_check_only class _UNSET_: @staticmethod def __bool__() -> Literal[False]: ... diff --git a/stubs/reportlab/reportlab/platypus/doctemplate.pyi b/stubs/reportlab/reportlab/platypus/doctemplate.pyi index 5dc5ca0c6d7e..57b083ff1f2f 100644 --- a/stubs/reportlab/reportlab/platypus/doctemplate.pyi +++ b/stubs/reportlab/reportlab/platypus/doctemplate.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from abc import abstractmethod from collections.abc import Callable -from typing import IO, Any, Literal, Protocol +from typing import IO, Any, Literal, Protocol, type_check_only from typing_extensions import Self, TypeAlias from reportlab.pdfgen.canvas import Canvas @@ -33,6 +33,7 @@ __all__ = ( # type vars didn't seem to work for this one _PageCallback: TypeAlias = Callable[[Canvas, Any], object] +@type_check_only class _CanvasMaker(Protocol): # NOTE: This matches a subset of Canvas.__init__ def __call__( diff --git a/stubs/reportlab/reportlab/platypus/flowables.pyi b/stubs/reportlab/reportlab/platypus/flowables.pyi index b51aa216c3da..76dc086703ff 100644 --- a/stubs/reportlab/reportlab/platypus/flowables.pyi +++ b/stubs/reportlab/reportlab/platypus/flowables.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete, SupportsRead, Unused from collections.abc import Callable, Iterable, Sequence -from typing import Any, Literal, NoReturn, Protocol +from typing import Any, Literal, NoReturn, Protocol, type_check_only from typing_extensions import Self, TypeAlias from reportlab.lib.colors import Color @@ -64,6 +64,7 @@ _FlowableSublist: TypeAlias = Flowable | list[Flowable] | tuple[Flowable, ...] # NOTE: Technically can only be list or tuple, but would be annoying for variance _NestedFlowable: TypeAlias = Flowable | Sequence[_NestedFlowable] +@type_check_only class _StyledFlowableFactory(Protocol): # NOTE: We leave style at Any so people can specify a specifc property set def __call__(self, value: str, /, *, style: Any) -> Flowable: ... diff --git a/stubs/reportlab/reportlab/platypus/para.pyi b/stubs/reportlab/reportlab/platypus/para.pyi index 5ed3412baad3..a83dce246445 100644 --- a/stubs/reportlab/reportlab/platypus/para.pyi +++ b/stubs/reportlab/reportlab/platypus/para.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete, Unused from collections.abc import Callable, Mapping -from typing import Any, Final, Literal, Protocol, TypedDict, TypeVar, overload +from typing import Any, Final, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only from typing_extensions import TypeAlias, Unpack from reportlab.lib.colors import Color @@ -15,14 +15,17 @@ _Op: TypeAlias = _SupportsWidthAndExecute | str | float | tuple[str, Unpack[tupl # NOTE: Output from pyRXP xml parser _ParsedText: TypeAlias = tuple[str, dict[str, Any], list[_ParsedText], Any] | list[_ParsedText] | str +@type_check_only class _LineOpHandler(Protocol): def start_at(self, x: float, y: float, para: paragraphEngine, canvas: Canvas, textobject: PDFTextObject) -> None: ... def end_at(self, x: float, y: float, para: paragraphEngine, canvas: Canvas, textobject: PDFTextObject) -> None: ... +@type_check_only class _SupportsWidthAndExecute(Protocol): def width(self, engine) -> float: ... def execute(self, engine, textobject: PDFTextObject, canvas: Canvas) -> object: ... +@type_check_only class _SimpleStyleKwargs(TypedDict, total=False): fontName: str fontSize: float diff --git a/stubs/reportlab/reportlab/platypus/tableofcontents.pyi b/stubs/reportlab/reportlab/platypus/tableofcontents.pyi index c947ec8ad109..8159bde6ae53 100644 --- a/stubs/reportlab/reportlab/platypus/tableofcontents.pyi +++ b/stubs/reportlab/reportlab/platypus/tableofcontents.pyi @@ -1,6 +1,6 @@ from _typeshed import Unused from collections.abc import Callable, Iterable, Sequence -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, Unpack from reportlab.lib.styles import ParagraphStyle, PropertySet @@ -12,6 +12,7 @@ _T = TypeVar("_T") _Entry: TypeAlias = tuple[int, str, int] | tuple[int, str, int, str | None] | Sequence[int | str | None] _SequencerFormat: TypeAlias = Literal["I", "i", "123", "ABC", "abc"] +@type_check_only class _TableOfContentsKwargs(TypedDict, total=False): rightColumnWidth: float levelStyles: list[PropertySet] # should be ParagraphStyle @@ -19,6 +20,7 @@ class _TableOfContentsKwargs(TypedDict, total=False): dotsMinLevel: int formatter: Callable[[int], str] | None +@type_check_only class _SimpleIndexKwargs(TypedDict, total=False): style: Iterable[PropertySet] | PropertySet | None # should be ParagraphStyle dot: str | None diff --git a/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi b/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi index e97a83ba0a5f..a6e089ec90d7 100644 --- a/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi +++ b/stubs/requests-oauthlib/requests_oauthlib/oauth1_session.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from logging import Logger -from typing import TypedDict +from typing import TypedDict, type_check_only from typing_extensions import TypeAlias import requests @@ -11,6 +11,7 @@ from . import OAuth1 # should be dict[str, str] but could look different _ParsedToken: TypeAlias = dict[str, Incomplete] +@type_check_only class _TokenDict(TypedDict, total=False): oauth_token: Incomplete # oauthlib.oauth1.Client.resource_owner_key oauth_token_secret: Incomplete # oauthlib.oauth1.Client.resource_token_secret diff --git a/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi b/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi index 300230fd1ce3..1ad322a9f42c 100644 --- a/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi +++ b/stubs/requests-oauthlib/requests_oauthlib/oauth2_session.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from logging import Logger -from typing import Any, Literal, Protocol, TypedDict, overload +from typing import Any, Literal, Protocol, TypedDict, overload, type_check_only from typing_extensions import TypeAlias import requests @@ -9,15 +9,19 @@ from requests.cookies import RequestsCookieJar _Token: TypeAlias = dict[str, Incomplete] # oauthlib.oauth2.Client.token +@type_check_only class _AccessTokenResponseHook(Protocol): def __call__(self, response: requests.Response, /) -> requests.Response: ... +@type_check_only class _RefreshTokenResponseHook(Protocol): def __call__(self, response: requests.Response, /) -> requests.Response: ... +@type_check_only class _ProtectedRequestHook(Protocol): def __call__(self, url, headers, data, /) -> tuple[Incomplete, Incomplete, Incomplete]: ... +@type_check_only class _ComplianceHooks(TypedDict): access_token_response: set[_AccessTokenResponseHook] refresh_token_response: set[_RefreshTokenResponseHook] diff --git a/stubs/requests/requests/adapters.pyi b/stubs/requests/requests/adapters.pyi index 2f8e4d75cd97..208c7264d694 100644 --- a/stubs/requests/requests/adapters.pyi +++ b/stubs/requests/requests/adapters.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Mapping from ssl import SSLContext -from typing import Literal, TypedDict +from typing import Literal, TypedDict, type_check_only from typing_extensions import NotRequired, deprecated import urllib3 @@ -38,11 +38,13 @@ from .utils import ( ) # Arguments to urllib3 connection_from_host() functions (except pool_kwargs). +@type_check_only class _HostParams(TypedDict): host: str scheme: str port: int +@type_check_only class _PoolKwargs(TypedDict): ssl_context: NotRequired[SSLContext] ca_certs: NotRequired[str] diff --git a/stubs/requests/requests/help.pyi b/stubs/requests/requests/help.pyi index f36d62ff20dd..697afb1be11f 100644 --- a/stubs/requests/requests/help.pyi +++ b/stubs/requests/requests/help.pyi @@ -1,21 +1,27 @@ -from typing import TypedDict +from typing import TypedDict, type_check_only +@type_check_only class _VersionDict(TypedDict): version: str +@type_check_only class _OptionalVersionDict(TypedDict): version: str | None +@type_check_only class _PlatformDict(TypedDict): system: str release: str +@type_check_only class _ImplementationDict(_VersionDict): name: str +@type_check_only class _PyOpenSSLDict(_OptionalVersionDict): openssl_version: str +@type_check_only class _InfoDict(TypedDict): platform: _PlatformDict implementation: _ImplementationDict diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index ec2211c6bc4e..eaeffb94c7cd 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsItems, SupportsRead, Unused from collections.abc import Callable, Iterable, Mapping, MutableMapping -from typing import Any, TypedDict +from typing import Any, TypedDict, type_check_only from typing_extensions import Self, TypeAlias from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, models, status_codes, utils @@ -105,6 +105,7 @@ _HeadersUpdateMapping: TypeAlias = Mapping[str, str | bytes | None] _Timeout: TypeAlias = float | tuple[float, float] | tuple[float, None] _Verify: TypeAlias = bool | str +@type_check_only class _Settings(TypedDict): verify: _Verify | None proxies: _TextMapping diff --git a/stubs/seaborn/seaborn/distributions.pyi b/stubs/seaborn/seaborn/distributions.pyi index 0f426084bf8f..06ecfb7197e0 100644 --- a/stubs/seaborn/seaborn/distributions.pyi +++ b/stubs/seaborn/seaborn/distributions.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable -from typing import Any, Literal, Protocol, TypeVar +from typing import Any, Literal, Protocol, TypeVar, type_check_only from typing_extensions import TypeAlias, deprecated from matplotlib.axes import Axes @@ -17,6 +17,7 @@ __all__ = ["displot", "histplot", "kdeplot", "ecdfplot", "rugplot", "distplot"] _T = TypeVar("_T") _OneOrPair: TypeAlias = _T | tuple[_T, _T] +@type_check_only class _Fit(Protocol): def fit(self, a: ArrayLike) -> tuple[ArrayLike, ...]: ... def pdf(self, x: ArrayLike, *params: ArrayLike) -> ArrayLike: ... diff --git a/stubs/seaborn/seaborn/external/kde.pyi b/stubs/seaborn/seaborn/external/kde.pyi index 96b36651eb33..e886570721d1 100644 --- a/stubs/seaborn/seaborn/external/kde.pyi +++ b/stubs/seaborn/seaborn/external/kde.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Any, Literal, Protocol +from typing import Any, Literal, Protocol, type_check_only from typing_extensions import TypeAlias import numpy as np @@ -9,6 +9,7 @@ __all__ = ["gaussian_kde"] # define a "Gaussian KDE" protocol so that we can also pass `scipy.stats.gaussian_kde` to # functions that expect it without adding a dependency on scipy +@type_check_only class _GaussianKDELike(Protocol): dataset: NDArray[np.float64] def __init__(self, dataset: ArrayLike, bw_method: Any | None = ..., weights: ArrayLike | None = ...) -> None: ... diff --git a/stubs/setuptools/setuptools/command/editable_wheel.pyi b/stubs/setuptools/setuptools/command/editable_wheel.pyi index 3080f4d690a1..989289829a49 100644 --- a/stubs/setuptools/setuptools/command/editable_wheel.pyi +++ b/stubs/setuptools/setuptools/command/editable_wheel.pyi @@ -77,4 +77,3 @@ class _NamespaceInstaller(namespaces.Installer): class InformationOnly(SetuptoolsWarning): ... class LinksNotSupported(errors.FileError): ... -class _DebuggingTips(SetuptoolsWarning): ... diff --git a/stubs/setuptools/setuptools/config/pyprojecttoml.pyi b/stubs/setuptools/setuptools/config/pyprojecttoml.pyi index f44ffcdb95d4..45febbdafb2d 100644 --- a/stubs/setuptools/setuptools/config/pyprojecttoml.pyi +++ b/stubs/setuptools/setuptools/config/pyprojecttoml.pyi @@ -4,7 +4,6 @@ from typing import Any from typing_extensions import Self from ..dist import Distribution -from ..warnings import SetuptoolsWarning from . import expand def load_file(filepath: StrPath) -> dict[Incomplete, Incomplete]: ... @@ -45,6 +44,3 @@ class _EnsurePackagesDiscovered(expand.EnsurePackagesDiscovered): def __exit__( self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> None: ... - -class _BetaConfiguration(SetuptoolsWarning): ... -class _InvalidFile(SetuptoolsWarning): ... diff --git a/stubs/singledispatch/singledispatch.pyi b/stubs/singledispatch/singledispatch.pyi index 8a04562c1ac6..feafcc251c88 100644 --- a/stubs/singledispatch/singledispatch.pyi +++ b/stubs/singledispatch/singledispatch.pyi @@ -1,9 +1,10 @@ from collections.abc import Callable, Mapping -from typing import Any, Generic, TypeVar, overload +from typing import Any, Generic, TypeVar, overload, type_check_only _T = TypeVar("_T") _S = TypeVar("_S") +@type_check_only class _SingleDispatchCallable(Generic[_T]): registry: Mapping[Any, Callable[..., _T]] def dispatch(self, cls: Any) -> Callable[..., _T]: ... diff --git a/stubs/toposort/toposort.pyi b/stubs/toposort/toposort.pyi index 35ad36b6f955..964dfe28f629 100644 --- a/stubs/toposort/toposort.pyi +++ b/stubs/toposort/toposort.pyi @@ -1,11 +1,12 @@ from _typeshed import SupportsItems from collections.abc import Iterable, Iterator -from typing import Any, Protocol, TypeVar +from typing import Any, Protocol, TypeVar, type_check_only _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) _T = TypeVar("_T") +@type_check_only class _SupportsItemsAndLen(SupportsItems[_KT_co, _VT_co], Protocol[_KT_co, _VT_co]): def __len__(self) -> int: ... diff --git a/stubs/tqdm/tqdm/dask.pyi b/stubs/tqdm/tqdm/dask.pyi index 28dd1195ca80..4ee807b781ef 100644 --- a/stubs/tqdm/tqdm/dask.pyi +++ b/stubs/tqdm/tqdm/dask.pyi @@ -1,11 +1,12 @@ from _typeshed import Incomplete from collections.abc import Callable -from typing import ClassVar +from typing import ClassVar, type_check_only from typing_extensions import Self __all__ = ["TqdmCallback"] # dask.callbacks.Callback +@type_check_only class _Callback: active: ClassVar[set[tuple[Callable[..., Incomplete] | None, ...]]] def __init__( diff --git a/stubs/tqdm/tqdm/rich.pyi b/stubs/tqdm/tqdm/rich.pyi index 394fd1c5cb47..9af999b21a49 100644 --- a/stubs/tqdm/tqdm/rich.pyi +++ b/stubs/tqdm/tqdm/rich.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete, SupportsWrite from abc import ABC, abstractmethod from collections.abc import Iterable, Mapping -from typing import NoReturn, TypeVar, overload +from typing import NoReturn, TypeVar, overload, type_check_only from .std import tqdm as std_tqdm @@ -10,6 +10,7 @@ __all__ = ["tqdm_rich", "trrange", "tqdm", "trange"] _T = TypeVar("_T") # Actually rich.progress.ProgressColumn +@type_check_only class _ProgressColumn(ABC): max_refresh: float | None def __init__(self, table_column: Incomplete | None = ...) -> None: ... diff --git a/stubs/tqdm/tqdm/utils.pyi b/stubs/tqdm/tqdm/utils.pyi index f18408e606dd..7633d2b2df45 100644 --- a/stubs/tqdm/tqdm/utils.pyi +++ b/stubs/tqdm/tqdm/utils.pyi @@ -1,7 +1,7 @@ from _typeshed import Incomplete from collections.abc import Callable, Mapping from re import Pattern -from typing import Protocol, TypeVar +from typing import Protocol, TypeVar, type_check_only from typing_extensions import ParamSpec CUR_OS: str @@ -15,6 +15,7 @@ class FormatReplace: def __init__(self, replace: str = "") -> None: ... def __format__(self, _) -> str: ... +@type_check_only class _Has__Comparable(Protocol): _comparable: Incomplete diff --git a/stubs/translationstring/translationstring/__init__.pyi b/stubs/translationstring/translationstring/__init__.pyi index 5b2f11cae811..eb7af77fec62 100644 --- a/stubs/translationstring/translationstring/__init__.pyi +++ b/stubs/translationstring/translationstring/__init__.pyi @@ -1,8 +1,9 @@ from collections.abc import Callable from gettext import NullTranslations -from typing import Any, Protocol +from typing import Any, Protocol, type_check_only from typing_extensions import Self +@type_check_only class _TranslationStringFactory(Protocol): def __call__( self, @@ -12,6 +13,7 @@ class _TranslationStringFactory(Protocol): context: str | None = ..., ) -> TranslationString: ... +@type_check_only class _ChameleonTranslate(Protocol): def __call__( self, @@ -22,9 +24,11 @@ class _ChameleonTranslate(Protocol): default: str | None = ..., ) -> TranslationString: ... +@type_check_only class _TranslatorPolicy(Protocol): def __call__(self, translations: NullTranslations, tstring: str, domain: str | None, context: str | None) -> str: ... +@type_check_only class _Translator(Protocol): def __call__( self, @@ -34,11 +38,13 @@ class _Translator(Protocol): context: str | None = None, ) -> str: ... +@type_check_only class _PluralizerPolicy(Protocol): def __call__( self, translations: NullTranslations, singular: str, plural: str, n: int, domain: str | None, context: str | None ) -> str: ... +@type_check_only class _Pluralizer(Protocol): def __call__( self, diff --git a/stubs/uWSGI/uwsgi.pyi b/stubs/uWSGI/uwsgi.pyi index d42c32b30074..8d37a83ecf6b 100644 --- a/stubs/uWSGI/uwsgi.pyi +++ b/stubs/uWSGI/uwsgi.pyi @@ -2,13 +2,14 @@ from _typeshed import HasFileno, OptExcInfo, ReadOnlyBuffer from _typeshed.wsgi import WSGIApplication from collections.abc import Callable from types import ModuleType -from typing import Any, Literal, Protocol, final, overload +from typing import Any, Literal, Protocol, final, overload, type_check_only from typing_extensions import Self, TypeAlias import uwsgidecorators _TrueOrNone: TypeAlias = Literal[True] | None +@type_check_only class _RPCCallable(Protocol): def __call__(self, *args: bytes) -> bytes | None: ... diff --git a/stubs/watchpoints/watchpoints/watch.pyi b/stubs/watchpoints/watchpoints/watch.pyi index 320bc4afdbac..8e127fd57463 100644 --- a/stubs/watchpoints/watchpoints/watch.pyi +++ b/stubs/watchpoints/watchpoints/watch.pyi @@ -3,7 +3,7 @@ from _typeshed import SupportsWrite, TraceFunction from collections.abc import Callable from pdb import Pdb from types import FrameType -from typing import Any, Literal, Protocol, TypeVar +from typing import Any, Literal, Protocol, TypeVar, type_check_only from typing_extensions import TypeAlias from .watch_element import WatchElement @@ -64,5 +64,6 @@ class Watch: def uninstall(self, func: _Identifier = "watch") -> None: ... def unwatch(self, *args: object) -> None: ... +@type_check_only class _TraceFunc(Protocol): def __call__(self, frame: FrameType, event: str, arg: object) -> _TraceFunc: ... diff --git a/stubs/wurlitzer/wurlitzer.pyi b/stubs/wurlitzer/wurlitzer.pyi index 948f6e58985b..848c6383f04c 100644 --- a/stubs/wurlitzer/wurlitzer.pyi +++ b/stubs/wurlitzer/wurlitzer.pyi @@ -7,7 +7,7 @@ from _typeshed import SupportsWrite from contextlib import _GeneratorContextManager from threading import Thread from types import TracebackType -from typing import Any, Final, Literal, Protocol, TextIO, TypeVar, overload +from typing import Any, Final, Literal, Protocol, TextIO, TypeVar, overload, type_check_only from typing_extensions import Self, TypeAlias STDOUT: Final = 2 @@ -18,6 +18,7 @@ _T_contra = TypeVar("_T_contra", contravariant=True) _StreamOutT = TypeVar("_StreamOutT", bound=_Stream[str] | _Stream[bytes]) _StreamErrT = TypeVar("_StreamErrT", bound=_Stream[str] | _Stream[bytes]) +@type_check_only class _Stream(SupportsWrite[_T_contra], Protocol): def seek(self, offset: int, whence: int = ..., /) -> int: ... diff --git a/stubs/zxcvbn/zxcvbn/__init__.pyi b/stubs/zxcvbn/zxcvbn/__init__.pyi index e327270125ce..668d12a9b250 100644 --- a/stubs/zxcvbn/zxcvbn/__init__.pyi +++ b/stubs/zxcvbn/zxcvbn/__init__.pyi @@ -1,12 +1,13 @@ import datetime from collections.abc import Iterable from decimal import Decimal -from typing import TypedDict +from typing import TypedDict, type_check_only from .feedback import _Feedback from .matching import _Match from .time_estimates import _TimeEstimate +@type_check_only class _Result(_TimeEstimate, TypedDict): password: str guesses: Decimal diff --git a/stubs/zxcvbn/zxcvbn/feedback.pyi b/stubs/zxcvbn/zxcvbn/feedback.pyi index 1258af31330c..17b348a0bd7d 100644 --- a/stubs/zxcvbn/zxcvbn/feedback.pyi +++ b/stubs/zxcvbn/zxcvbn/feedback.pyi @@ -1,8 +1,9 @@ from collections.abc import Sequence -from typing import Literal, TypedDict +from typing import Literal, TypedDict, type_check_only from .matching import _Match +@type_check_only class _Feedback(TypedDict): warning: str suggestions: list[str] diff --git a/stubs/zxcvbn/zxcvbn/matching.pyi b/stubs/zxcvbn/zxcvbn/matching.pyi index 7aba63bad5d5..7f8bfb28af20 100644 --- a/stubs/zxcvbn/zxcvbn/matching.pyi +++ b/stubs/zxcvbn/zxcvbn/matching.pyi @@ -1,11 +1,12 @@ from collections.abc import Iterable, Mapping from decimal import Decimal from re import Pattern -from typing import Any, Literal, TypedDict +from typing import Any, Literal, TypedDict, type_check_only from typing_extensions import NotRequired from .adjacency_graphs import _Graph +@type_check_only class _Match(TypedDict): pattern: Literal["dictionary", "spatial", "repeat", "sequence", "regex", "date"] token: str @@ -80,11 +81,12 @@ def regex_match( password: str, _regexen: dict[str, Pattern[str]] = ..., _ranked_dictionaries: dict[str, dict[str, int]] = ... ) -> list[_Match]: ... def date_match(password: str, _ranked_dictionaries: dict[str, dict[str, int]] = ...) -> list[_Match]: ... - +@type_check_only class _DM(TypedDict): month: int day: int +@type_check_only class _DMY(TypedDict): year: int month: int diff --git a/stubs/zxcvbn/zxcvbn/scoring.pyi b/stubs/zxcvbn/zxcvbn/scoring.pyi index 9aafe968a3b1..a553977c42e2 100644 --- a/stubs/zxcvbn/zxcvbn/scoring.pyi +++ b/stubs/zxcvbn/zxcvbn/scoring.pyi @@ -1,7 +1,7 @@ from collections.abc import Iterable from decimal import Decimal from re import Pattern -from typing import TypedDict +from typing import TypedDict, type_check_only from .adjacency_graphs import _Graph from .matching import _Match @@ -15,6 +15,7 @@ MIN_SUBMATCH_GUESSES_MULTI_CHAR: int MIN_YEAR_SPACE: int REFERENCE_YEAR: int +@type_check_only class _GuessesResult(TypedDict): password: str guesses: int diff --git a/stubs/zxcvbn/zxcvbn/time_estimates.pyi b/stubs/zxcvbn/zxcvbn/time_estimates.pyi index 71e2b3671850..f18ec53268c7 100644 --- a/stubs/zxcvbn/zxcvbn/time_estimates.pyi +++ b/stubs/zxcvbn/zxcvbn/time_estimates.pyi @@ -1,17 +1,20 @@ from decimal import Decimal -from typing import Literal, TypedDict +from typing import Literal, TypedDict, type_check_only +@type_check_only class _TimeEstimate(TypedDict): crack_times_seconds: _CrackTimeSeconds crack_times_display: _CrackTimesDisplay score: Literal[0, 1, 2, 3, 4] +@type_check_only class _CrackTimeSeconds(TypedDict): online_throttling_100_per_hour: Decimal online_no_throttling_10_per_second: Decimal offline_slow_hashing_1e4_per_second: Decimal offline_fast_hashing_1e10_per_second: Decimal +@type_check_only class _CrackTimesDisplay(TypedDict): online_throttling_100_per_hour: str online_no_throttling_10_per_second: str