Skip to content

Make several fields read-only for type, staticmethod and classmethod #7423

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

Merged
merged 4 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 26 additions & 13 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ class object:
def __init_subclass__(cls) -> None: ...

class staticmethod(Generic[_R_co]):
__func__: Callable[..., _R_co]
__isabstractmethod__: bool
@property
def __func__(self) -> Callable[..., _R_co]: ...
@property
def __isabstractmethod__(self) -> bool: ...
def __init__(self: staticmethod[_R_co], __f: Callable[..., _R_co]) -> None: ...
def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R_co]: ...
if sys.version_info >= (3, 10):
Expand All @@ -126,8 +128,10 @@ class staticmethod(Generic[_R_co]):
def __call__(self, *args: Any, **kwargs: Any) -> _R_co: ...

class classmethod(Generic[_R_co]):
__func__: Callable[..., _R_co]
__isabstractmethod__: bool
@property
def __func__(self) -> Callable[..., _R_co]: ...
@property
def __isabstractmethod__(self) -> bool: ...
def __init__(self: classmethod[_R_co], __f: Callable[..., _R_co]) -> None: ...
def __get__(self, __obj: _T, __type: type[_T] | None = ...) -> Callable[..., _R_co]: ...
if sys.version_info >= (3, 10):
Expand All @@ -136,19 +140,28 @@ class classmethod(Generic[_R_co]):
__wrapped__: Callable[..., _R_co]

class type:
__base__: type
@property
def __base__(self) -> type: ...
__bases__: tuple[type, ...]
__basicsize__: int
__dict__: dict[str, Any]
__dictoffset__: int
__flags__: int
__itemsize__: int
@property
def __basicsize__(self) -> int: ...
@property
def __dict__(self) -> types.MappingProxyType[str, Any]: ... # type: ignore[override]
@property
def __dictoffset__(self) -> int: ...
@property
def __flags__(self) -> int: ...
@property
def __itemsize__(self) -> int: ...
__module__: str
__mro__: tuple[type, ...]
@property
def __mro__(self) -> tuple[type, ...]: ...
__name__: str
__qualname__: str
__text_signature__: str | None
__weakrefoffset__: int
@property
def __text_signature__(self) -> str | None: ...
@property
def __weakrefoffset__(self) -> int: ...
@overload
def __init__(self, __o: object) -> None: ...
@overload
Expand Down
1 change: 1 addition & 0 deletions tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ sqlite3.Binary.__contains__ # C type that implements __getitem__
builtins.object.__init__ # default C signature is incorrect
builtins.property.__get__ # this function can accept no value for the type parameter.
builtins.staticmethod.__get__ # this function can accept no value for the type parameter.
builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute.
bz2.BZ2Decompressor.__init__ # function does not accept parameters but C signature is set
# The following CodecInfo properties are added in __new__
codecs.CodecInfo.decode
Expand Down