Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 138
Add typing_extensions.utils#45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
24a6581e4da1dcd09c0684f09778ffb590823c784ba9b06cf3c22f2aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # We just import the utils module to check for syntax or import problems. | ||
| import typing_extensions.utils # noqa F401 | ||
| def dummy(): | ||
| pass |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| """ | ||
| Protocols and type aliases that are not scheduled for inclusion in typing. | ||
| """ | ||
| from os import PathLike | ||
| from typing import AbstractSet, Awaitable, Iterable, Tuple, TypeVar, Union | ||
| from typing_extensions import Protocol, TypeAlias | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add | ||
| _T_co = TypeVar("_T_co", covariant=True) | ||
| _T_contra = TypeVar("_T_contra", contravariant=True) | ||
| _KT = TypeVar("_KT") | ||
| _KT_co = TypeVar("_KT_co", covariant=True) | ||
| _KT_contra = TypeVar("_KT_contra", contravariant=True) | ||
| _VT_co = TypeVar("_VT_co", covariant=True) | ||
| # | ||
| # Protocols for dunder methods | ||
| # | ||
| class SupportsAnext(Protocol[_T_co]): | ||
| def __anext__(self) -> Awaitable[_T_co]: | ||
| ... | ||
| class SupportsDivMod(Protocol[_T_contra, _T_co]): | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think we should drop the divmod protocols:
| ||
| def __divmod__(self, __other: _T_contra) -> _T_co: | ||
| ... | ||
| class SupportsGetItem(Protocol[_KT_contra, _VT_co]): | ||
| def __getitem__(self, __k: _KT_contra) -> _VT_co: | ||
| ... | ||
| class SupportsNext(Protocol[_T_co]): | ||
| def __next__(self) -> _T_co: | ||
| ... | ||
| class SupportsRDivMod(Protocol[_T_contra, _T_co]): | ||
| def __rdivmod__(self, __other: _T_contra) -> _T_co: | ||
| ... | ||
| class SupportsTrunc(Protocol): | ||
| def __trunc__(self) -> int: | ||
| ... | ||
| # | ||
| # Mapping-like protocols | ||
| # | ||
| class SupportsKeys(Protocol[_KT_co]): | ||
| def keys(self) -> Iterable[_KT_co]: | ||
| ... | ||
| class SupportsItems(Protocol[_KT_co, _VT_co]): | ||
| def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: | ||
| ... | ||
| class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]): | ||
| def keys(self) -> Iterable[_KT]: | ||
| ... | ||
| def __getitem__(self, __k: _KT) -> _VT_co: | ||
| ... | ||
| # | ||
| # I/O protocols | ||
| # | ||
| class SupportsRead(Protocol[_T_co]): | ||
| def read(self, __length: int = ...) -> _T_co: | ||
| ... | ||
| class SupportsReadline(Protocol[_T_co]): | ||
| def readline(self, __length: int = ...) -> _T_co: | ||
| ... | ||
| class SupportsWrite(Protocol[_T_contra]): | ||
| def write(self, __s: _T_contra) -> object: | ||
| ... | ||
| # | ||
| # Path aliases | ||
| # | ||
| StrPath: TypeAlias = Union[str, "PathLike[str]"] | ||
| BytesPath: TypeAlias = Union[bytes, "PathLike[bytes]"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment there, but we should also mention the
utilsmodule in the README around line 34.