Skip to content

Commit 1088ab3

Browse files
authored
Improve stubs for classmethod and staticmethod (#10421)
1 parent 6191425 commit 1088ab3

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

stdlib/abc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
3131

3232
class abstractclassmethod(classmethod[_T, _P, _R_co]):
3333
__isabstractmethod__: Literal[True]
34-
def __init__(self, callable: Callable[Concatenate[_T, _P], _R_co]) -> None: ...
34+
def __init__(self, callable: Callable[Concatenate[type[_T], _P], _R_co]) -> None: ...
3535

3636
class abstractstaticmethod(staticmethod[_P, _R_co]):
3737
__isabstractmethod__: Literal[True]

stdlib/builtins.pyi

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class staticmethod(Generic[_P, _R_co]):
132132
@property
133133
def __isabstractmethod__(self) -> bool: ...
134134
def __init__(self, __f: Callable[_P, _R_co]) -> None: ...
135+
@overload
136+
def __get__(self, __instance: None, __owner: type) -> Callable[_P, _R_co]: ...
137+
@overload
135138
def __get__(self, __instance: _T, __owner: type[_T] | None = None) -> Callable[_P, _R_co]: ...
136139
if sys.version_info >= (3, 10):
137140
__name__: str
@@ -142,16 +145,19 @@ class staticmethod(Generic[_P, _R_co]):
142145

143146
class classmethod(Generic[_T, _P, _R_co]):
144147
@property
145-
def __func__(self) -> Callable[Concatenate[_T, _P], _R_co]: ...
148+
def __func__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ...
146149
@property
147150
def __isabstractmethod__(self) -> bool: ...
148-
def __init__(self, __f: Callable[Concatenate[_T, _P], _R_co]) -> None: ...
151+
def __init__(self, __f: Callable[Concatenate[type[_T], _P], _R_co]) -> None: ...
152+
@overload
149153
def __get__(self, __instance: _T, __owner: type[_T] | None = None) -> Callable[_P, _R_co]: ...
154+
@overload
155+
def __get__(self, __instance: None, __owner: type[_T]) -> Callable[_P, _R_co]: ...
150156
if sys.version_info >= (3, 10):
151157
__name__: str
152158
__qualname__: str
153159
@property
154-
def __wrapped__(self) -> Callable[Concatenate[_T, _P], _R_co]: ...
160+
def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ...
155161

156162
class type:
157163
@property

0 commit comments

Comments
 (0)