mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-11 19:00:52 +08:00
Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from typing import Any, Generic, overload
|
||||
from typing import Any, Generic, overload, type_check_only
|
||||
from typing_extensions import Concatenate, Never, ParamSpec, Self, TypeAlias, TypeVar
|
||||
|
||||
from webob.request import BaseRequest, Request
|
||||
@@ -145,6 +145,7 @@ class wsgify(Generic[_P, _RequestT_contra]):
|
||||
cls, middle_func: _MiddlewareMethod[_RequestT, _AppT, _P2], app: _AppT, *_: _P2.args, **kw: _P2.kwargs
|
||||
) -> type[wsgify[Concatenate[_AppT, _P2], _RequestT]]: ...
|
||||
|
||||
@type_check_only
|
||||
class _unbound_wsgify(wsgify[_P, _RequestT_contra], Generic[_P, _S, _RequestT_contra]):
|
||||
@overload # type: ignore[override]
|
||||
def __call__(self, __self: _S, env: WSGIEnvironment, /, start_response: StartResponse) -> Iterable[bytes]: ...
|
||||
|
||||
@@ -2,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: ...
|
||||
|
||||
|
||||
@@ -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]]: ...
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user