Skip to content

Commit 81c8fcb

Browse files
Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)
1 parent a358dc2 commit 81c8fcb

File tree

131 files changed

+334
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+334
-147
lines changed

stubs/Authlib/authlib/oauth2/rfc6750/token.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from collections.abc import Callable
2-
from typing import Protocol
2+
from typing import Protocol, type_check_only
33

44
from authlib.oauth2.rfc6749 import ClientMixin
55

6+
@type_check_only
67
class _TokenGenerator(Protocol):
78
def __call__(self, *, client: ClientMixin, grant_type: str, user, scope: str) -> str: ...
89

stubs/Flask-Cors/flask_cors/core.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from collections.abc import Iterable
22
from datetime import timedelta
33
from logging import Logger
44
from re import Match, Pattern
5-
from typing import Any, Final, Literal, TypedDict, TypeVar, overload
5+
from typing import Any, Final, Literal, TypedDict, TypeVar, overload, type_check_only
66
from typing_extensions import TypeAlias
77

88
import flask
@@ -11,6 +11,7 @@ _IterableT = TypeVar("_IterableT", bound=Iterable[Any])
1111
_T = TypeVar("_T")
1212
_MultiDict: TypeAlias = Any # werkzeug is not part of typeshed
1313

14+
@type_check_only
1415
class _Options(TypedDict, total=False):
1516
resources: dict[str, dict[str, Any]] | list[str] | str | None
1617
origins: str | list[str] | None

stubs/Flask-Migrate/flask_migrate/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from _typeshed import StrPath, SupportsFlush, SupportsKeysAndGetItem, SupportsWr
55
from argparse import Namespace
66
from collections.abc import Callable, Iterable, Sequence
77
from logging import Logger
8-
from typing import Any, Protocol, TypeVar
8+
from typing import Any, Protocol, TypeVar, type_check_only
99
from typing_extensions import ParamSpec, TypeAlias
1010

1111
import flask
@@ -20,6 +20,7 @@ _AlembicConfigValue: TypeAlias = Any
2020
alembic_version: tuple[int, int, int]
2121
log: Logger
2222

23+
@type_check_only
2324
class _SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol): ...
2425

2526
class Config: # should inherit from alembic.config.Config which is not possible yet

stubs/Flask-SocketIO/flask_socketio/__init__.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from _typeshed import Incomplete
22
from collections.abc import Callable
33
from logging import Logger
44
from threading import Thread
5-
from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload
5+
from typing import Any, Literal, Protocol, TypedDict, TypeVar, overload, type_check_only
66
from typing_extensions import ParamSpec, TypeAlias, Unpack
77

88
from flask import Flask
@@ -16,19 +16,23 @@ _R_co = TypeVar("_R_co", covariant=True)
1616
_ExceptionHandler: TypeAlias = Callable[[BaseException], _R_co]
1717
_Handler: TypeAlias = Callable[_P, _R_co]
1818

19+
@type_check_only
1920
class _HandlerDecorator(Protocol):
2021
def __call__(self, handler: _Handler[_P, _R_co]) -> _Handler[_P, _R_co]: ...
2122

23+
@type_check_only
2224
class _ExceptionHandlerDecorator(Protocol):
2325
def __call__(self, exception_handler: _ExceptionHandler[_R_co]) -> _ExceptionHandler[_R_co]: ...
2426

27+
@type_check_only
2528
class _SocketIOServerOptions(TypedDict, total=False):
2629
client_manager: Incomplete
2730
logger: Logger | bool
2831
json: Incomplete
2932
async_handlers: bool
3033
always_connect: bool
3134

35+
@type_check_only
3236
class _EngineIOServerConfig(TypedDict, total=False):
3337
async_mode: Literal["threading", "eventlet", "gevent", "gevent_uwsgi"]
3438
ping_interval: float | tuple[float, float] # seconds
@@ -43,6 +47,7 @@ class _EngineIOServerConfig(TypedDict, total=False):
4347
monitor_clients: bool
4448
engineio_logger: Logger | bool
4549

50+
@type_check_only
4651
class _SocketIOKwargs(_SocketIOServerOptions, _EngineIOServerConfig): ...
4752

4853
class SocketIO:

stubs/Flask-SocketIO/flask_socketio/namespace.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from _typeshed import Incomplete
22
from collections.abc import Callable
3-
from typing import Any, Protocol, TypeVar
3+
from typing import Any, Protocol, TypeVar, type_check_only
44

55
_T = TypeVar("_T")
66

77
# at runtime, socketio.namespace.BaseNamespace, but socketio isn't py.typed
8+
@type_check_only
89
class _BaseNamespace(Protocol):
910
def is_asyncio_based(self) -> bool: ...
1011
def trigger_event(self, event: str, *args): ...

stubs/Flask-SocketIO/flask_socketio/test_client.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from _typeshed import Incomplete
2-
from typing import Any, TypedDict
2+
from typing import Any, TypedDict, type_check_only
33

44
from flask import Flask
55
from flask.testing import FlaskClient
66

7+
@type_check_only
78
class _Packet(TypedDict):
89
name: str
910
args: Any

stubs/JACK-Client/jack/__init__.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import Unused
22
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
3-
from typing import Any, Final, Literal, NoReturn, overload
3+
from typing import Any, Final, Literal, NoReturn, overload, type_check_only
44
from typing_extensions import Self
55

66
import numpy
@@ -11,6 +11,7 @@ from numpy.typing import NDArray
1111
# Actual type: _cffi_backend.__CDataOwn <cdata 'struct _jack_position *'>
1212
# This is not a real subclassing. Just ensuring type-checkers sees this type as compatible with _CDataBase
1313
# pyright has no error code for subclassing final
14+
@type_check_only
1415
class _JackPositionT(_CDataBase): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
1516
audio_frames_per_video_frame: float
1617
bar: int
@@ -33,6 +34,7 @@ class _JackPositionT(_CDataBase): # type: ignore[misc] # pyright: ignore[repor
3334
valid: int
3435
video_offset: int
3536

37+
@type_check_only
3638
class _CBufferType:
3739
@overload
3840
def __getitem__(self, key: int) -> str: ...

stubs/Markdown/markdown/extensions/toc.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections.abc import Iterator, MutableSet
22
from re import Pattern
3-
from typing import Any, TypedDict
3+
from typing import Any, TypedDict, type_check_only
44
from typing_extensions import deprecated
55
from xml.etree.ElementTree import Element
66

@@ -10,11 +10,13 @@ from markdown.treeprocessors import Treeprocessor
1010

1111
IDCOUNT_RE: Pattern[str]
1212

13+
@type_check_only
1314
class _FlatTocToken(TypedDict):
1415
level: int
1516
id: str
1617
name: str
1718

19+
@type_check_only
1820
class _TocToken(_FlatTocToken):
1921
children: list[_TocToken]
2022

stubs/Markdown/markdown/util.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from collections.abc import Iterator
33
from re import Pattern
4-
from typing import Final, Generic, TypedDict, TypeVar, overload
4+
from typing import Final, Generic, TypedDict, TypeVar, overload, type_check_only
55

66
from markdown.core import Markdown
77

@@ -40,6 +40,7 @@ class Processor:
4040
md: Markdown
4141
def __init__(self, md: Markdown | None = None) -> None: ...
4242

43+
@type_check_only
4344
class _TagData(TypedDict):
4445
tag: str
4546
attrs: dict[str, str]

stubs/PyYAML/yaml/emitter.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from collections.abc import Callable
2-
from typing import Any, NoReturn, Protocol, TypeVar
2+
from typing import Any, NoReturn, Protocol, TypeVar, type_check_only
33

44
from yaml.error import YAMLError
55

66
from .events import Event
77

88
_T_contra = TypeVar("_T_contra", str, bytes, contravariant=True)
99

10+
@type_check_only
1011
class _WriteStream(Protocol[_T_contra]):
1112
def write(self, data: _T_contra, /) -> object: ...
1213
# Optional fields:

0 commit comments

Comments
 (0)