Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 571d2c7

Browse files
KotlinIslandDetachHead
authored andcommitted
fix NoneType
1 parent c4d3582 commit 571d2c7

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

stdlib/_typeshed/__init__.pyi

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,10 @@ WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, ctyp
192192
ReadableBuffer = Union[ReadOnlyBuffer, WriteableBuffer] # stable
193193

194194
# stable
195-
if sys.version_info >= (3, 10):
196-
from types import NoneType as NoneType
197-
else:
198-
# Used by type checkers for checks involving None (does not exist at runtime)
199-
@final
200-
class NoneType:
201-
def __bool__(self) -> Literal[False]: ...
195+
# Used by type checkers for checks involving None (does not exist at runtime)
196+
@final
197+
class NoneType:
198+
def __bool__(self) -> Literal[False]: ...
202199

203200
# This is an internal CPython type that is like, but subtly different from, a NamedTuple
204201
# Subclasses of this type are found in multiple modules.

stdlib/types.pyi

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class _Cell:
4040

4141
# Make sure this class definition stays roughly in line with `builtins.function`
4242
@final
43-
class FunctionType:
43+
class FunctionType(Callable):
4444
__closure__: tuple[_Cell, ...] | None
4545
__code__: CodeType
4646
__defaults__: tuple[Any, ...] | None
@@ -279,7 +279,7 @@ class _StaticFunctionType:
279279
def __get__(self, obj: object | None, type: type | None) -> FunctionType: ...
280280

281281
@final
282-
class MethodType:
282+
class MethodType(Callable):
283283
__closure__: tuple[_Cell, ...] | None # inherited from the added function
284284
__defaults__: tuple[Any, ...] | None # inherited from the added function
285285
__func__: _StaticFunctionType
@@ -290,7 +290,7 @@ class MethodType:
290290
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
291291

292292
@final
293-
class BuiltinFunctionType:
293+
class BuiltinFunctionType(Callable):
294294
__self__: object | ModuleType
295295
__name__: str
296296
__qualname__: str
@@ -300,14 +300,14 @@ BuiltinMethodType = BuiltinFunctionType
300300

301301
if sys.version_info >= (3, 7):
302302
@final
303-
class WrapperDescriptorType:
303+
class WrapperDescriptorType(Callable):
304304
__name__: str
305305
__qualname__: str
306306
__objclass__: type
307307
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
308308
def __get__(self, obj: Any, type: type = ...) -> Any: ...
309309
@final
310-
class MethodWrapperType:
310+
class MethodWrapperType(Callable):
311311
__self__: object
312312
__name__: str
313313
__qualname__: str
@@ -316,14 +316,14 @@ if sys.version_info >= (3, 7):
316316
def __eq__(self, other: Any) -> bool: ...
317317
def __ne__(self, other: Any) -> bool: ...
318318
@final
319-
class MethodDescriptorType:
319+
class MethodDescriptorType(Callable):
320320
__name__: str
321321
__qualname__: str
322322
__objclass__: type
323323
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
324324
def __get__(self, obj: Any, type: type = ...) -> Any: ...
325325
@final
326-
class ClassMethodDescriptorType:
326+
class ClassMethodDescriptorType(Callable):
327327
__name__: str
328328
__qualname__: str
329329
__objclass__: type
@@ -424,9 +424,7 @@ if sys.version_info >= (3, 9):
424424
def __getattr__(self, name: str) -> Any: ... # incomplete
425425

426426
if sys.version_info >= (3, 10):
427-
@final
428-
class NoneType:
429-
def __bool__(self) -> Literal[False]: ...
427+
NoneType = type(None)
430428
EllipsisType = ellipsis # noqa F811 from builtins
431429
from builtins import _NotImplementedType
432430

0 commit comments

Comments
 (0)