Skip to content
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

Improve abc module and builtin function decorators (without ParamSpec) #5703

Merged
merged 25 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dd83c67
Improve abc module and builtin function decorators
srittau Jun 28, 2021
f99fc5f
Fix `__get__`
srittau Jun 28, 2021
f6bfdc9
Merge branch 'master' into abcmeta2
srittau Oct 4, 2021
e049258
Remove unused import
srittau Oct 4, 2021
91ae24d
Fix duplicate import
srittau Oct 4, 2021
c1d7c9c
Try copying __get__ to abstract{class,static}method
srittau Oct 4, 2021
060212b
Add __isabstractmethod__
srittau Oct 4, 2021
fe282c8
Add abstract*.__get__ to stubtest allowlist
srittau Oct 4, 2021
f82f04a
Remove abstract*.__get__ again
srittau Oct 4, 2021
8c59623
Merge branch 'master' into abcmeta2
srittau Dec 22, 2021
6f449b3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 22, 2021
7bb6c28
Remove unused allowlist entries
srittau Dec 22, 2021
a0e344e
Remove unused type var
srittau Dec 22, 2021
a12c70e
Make abstractstaticmethod generic match staticmethod
srittau Dec 22, 2021
96bcd1e
Merge branch 'master' into abcmeta2
srittau Dec 23, 2021
1f54a2b
Merge branch 'master' into abcmeta2
srittau Jan 2, 2022
3c66c98
Merge branch 'master' into abcmeta2
srittau Jan 8, 2022
399dbd4
Update pytest
srittau Jan 8, 2022
b1eb4e3
Merge remote-tracking branch 'upstream/master' into abcmeta2
srittau Jan 8, 2022
7ac6c63
Merge branch 'master' into abcmeta2
JelleZijlstra Jan 9, 2022
0e60382
Update stdlib/abc.pyi
JelleZijlstra Jan 9, 2022
a3475b5
lowercase type
JelleZijlstra Jan 9, 2022
c28ea74
Merge branch 'master' into abcmeta2
srittau Feb 2, 2022
7c901cf
Fix merge errors
srittau Feb 2, 2022
2f8f6cd
Remove wrong comments
srittau Feb 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions stdlib/abc.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
from _typeshed import SupportsWrite
from typing import Any, Callable, Dict, Tuple, Type, TypeVar
from typing import Any, Callable, Generic, Tuple, Type, TypeVar

_T = TypeVar("_T")
_R_co = TypeVar("_R_co", covariant=True)
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])

# These definitions have special processing in mypy
class ABCMeta(type):
__abstractmethods__: frozenset[str]
def __init__(self, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> None: ...
def __init__(self, name: str, bases: Tuple[type, ...], namespace: dict[str, Any]) -> None: ...
def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ...
def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...
def _dump_registry(cls: ABCMeta, file: SupportsWrite[str] | None = ...) -> None: ...
def register(cls: ABCMeta, subclass: Type[_T]) -> Type[_T]: ...

def abstractmethod(funcobj: _FuncT) -> _FuncT: ...

class abstractproperty(property): ...
class abstractclassmethod(classmethod[_R_co], Generic[_R_co]):
def __init__(self: abstractclassmethod[_R_co], callable: Callable[..., _R_co]) -> None: ...

# These two are deprecated and not supported by mypy
def abstractstaticmethod(callable: _FuncT) -> _FuncT: ...
def abstractclassmethod(callable: _FuncT) -> _FuncT: ...
class abstractstaticmethod(staticmethod[_FuncT], Generic[_FuncT]):
def __init__(self, callable: _FuncT) -> None: ...

class abstractproperty(property): ...
class ABC(metaclass=ABCMeta): ...

def get_cache_token() -> object: ...
20 changes: 11 additions & 9 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ from _typeshed import (
SupportsWrite,
)
from ast import AST, mod
from collections.abc import Callable
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from types import CodeType, TracebackType
from typing import (
Expand All @@ -26,7 +27,6 @@ from typing import (
AsyncIterator,
BinaryIO,
ByteString,
Callable,
Dict,
FrozenSet,
Generic,
Expand Down Expand Up @@ -70,6 +70,7 @@ class _SupportsTrunc(Protocol):
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
_R_co = TypeVar("_R_co", covariant=True)
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
_S = TypeVar("_S")
Expand All @@ -80,6 +81,7 @@ _T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_TT = TypeVar("_TT", bound="type")
_TBE = TypeVar("_TBE", bound="BaseException")
_FuncT = TypeVar("_FuncT", bound=Callable[..., Any])
srittau marked this conversation as resolved.
Show resolved Hide resolved

class object:
__doc__: Optional[str]
Expand Down Expand Up @@ -109,19 +111,19 @@ class object:
def __dir__(self) -> Iterable[str]: ...
def __init_subclass__(cls) -> None: ...

class staticmethod(object): # Special, only valid as a decorator.
__func__: Callable[..., Any]
class staticmethod(Generic[_FuncT]): # Special, only valid as a decorator.
__func__: _FuncT
__isabstractmethod__: bool
def __init__(self, f: Callable[..., Any]) -> None: ...
def __init__(self, __f: _FuncT) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ...
def __get__(self, obj: _T, type: Type[_T] | None = ...) -> _FuncT: ...
srittau marked this conversation as resolved.
Show resolved Hide resolved

class classmethod(object): # Special, only valid as a decorator.
__func__: Callable[..., Any]
class classmethod(Generic[_R_co]): # Special, only valid as a decorator.
srittau marked this conversation as resolved.
Show resolved Hide resolved
__func__: Callable[..., _R_co]
__isabstractmethod__: bool
def __init__(self, f: Callable[..., Any]) -> None: ...
def __init__(self: classmethod[_R_co], __f: Callable[..., _R_co]) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ...
def __get__(self, obj: _T | None, type: Type[_T] | None = ...) -> Callable[..., _R_co]: ...

class type(object):
__base__: type
Expand Down