mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-19 23:09:55 +08:00
Use PEP 570 syntax in third party stubs (#11554)
This commit is contained in:
@@ -17,7 +17,7 @@ _FieldT_contra = TypeVar("_FieldT_contra", bound=Field, contravariant=True)
|
||||
_Filter: TypeAlias = Callable[[Any], Any]
|
||||
|
||||
class _Validator(Protocol[_FormT_contra, _FieldT_contra]):
|
||||
def __call__(self, __form: _FormT_contra, __field: _FieldT_contra) -> object: ...
|
||||
def __call__(self, form: _FormT_contra, field: _FieldT_contra, /) -> object: ...
|
||||
|
||||
class _Widget(Protocol[_FieldT_contra]):
|
||||
def __call__(self, field: _FieldT_contra, **kwargs: Any) -> Markup: ...
|
||||
|
||||
@@ -13,9 +13,9 @@ _FormErrors: TypeAlias = dict[str | None, Sequence[str] | _FormErrors]
|
||||
# not instantianted after a new field had been added/removed
|
||||
class _UnboundFields(Protocol):
|
||||
@overload
|
||||
def __get__(self, __obj: None, __owner: type[object] | None = None) -> list[tuple[str, UnboundField[Any]]] | None: ...
|
||||
def __get__(self, obj: None, owner: type[object] | None = None, /) -> list[tuple[str, UnboundField[Any]]] | None: ...
|
||||
@overload
|
||||
def __get__(self, __obj: object, __owner: type[object] | None = None) -> list[tuple[str, UnboundField[Any]]]: ...
|
||||
def __get__(self, obj: object, owner: type[object] | None = None, /) -> list[tuple[str, UnboundField[Any]]]: ...
|
||||
|
||||
class BaseForm:
|
||||
meta: DefaultMeta
|
||||
|
||||
@@ -5,8 +5,8 @@ from typing import Protocol, TypeVar, overload
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class _SupportsUgettextAndUngettext(Protocol):
|
||||
def ugettext(self, __string: str) -> str: ...
|
||||
def ungettext(self, __singular: str, __plural: str, __n: int) -> str: ...
|
||||
def ugettext(self, string: str, /) -> str: ...
|
||||
def ungettext(self, singular: str, plural: str, n: int, /) -> str: ...
|
||||
|
||||
def messages_path() -> str: ...
|
||||
def get_builtin_gnu_translations(languages: Iterable[str] | None = None) -> GNUTranslations: ...
|
||||
|
||||
@@ -10,8 +10,8 @@ from wtforms.form import BaseForm
|
||||
_FieldT = TypeVar("_FieldT", bound=Field)
|
||||
|
||||
class _SupportsGettextAndNgettext(Protocol):
|
||||
def gettext(self, __string: str) -> str: ...
|
||||
def ngettext(self, __singular: str, __plural: str, __n: int) -> str: ...
|
||||
def gettext(self, string: str, /) -> str: ...
|
||||
def ngettext(self, singular: str, plural: str, n: int, /) -> str: ...
|
||||
|
||||
# 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
|
||||
@@ -19,16 +19,16 @@ class _SupportsGettextAndNgettext(Protocol):
|
||||
class _MultiDictLikeBase(Protocol):
|
||||
def __iter__(self) -> Iterator[str]: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __contains__(self, __key: Any) -> bool: ...
|
||||
def __contains__(self, key: Any, /) -> bool: ...
|
||||
|
||||
# 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
|
||||
class _MultiDictLikeWithGetlist(_MultiDictLikeBase, Protocol):
|
||||
def getlist(self, __key: str) -> list[Any]: ...
|
||||
def getlist(self, key: str, /) -> list[Any]: ...
|
||||
|
||||
class _MultiDictLikeWithGetall(_MultiDictLikeBase, Protocol):
|
||||
def getall(self, __key: str) -> list[Any]: ...
|
||||
def getall(self, key: str, /) -> list[Any]: ...
|
||||
|
||||
_MultiDictLike: TypeAlias = _MultiDictLikeWithGetall | _MultiDictLikeWithGetlist
|
||||
|
||||
|
||||
Reference in New Issue
Block a user