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

Commit ee54e30

Browse files
KotlinIslandMorgan Bartholomew
authored and
Morgan Bartholomew
committed
fix NoneType
1 parent 21cfa2d commit ee54e30

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
@@ -177,10 +177,7 @@ WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, ctyp
177177
ReadableBuffer = Union[ReadOnlyBuffer, WriteableBuffer] # stable
178178

179179
# stable
180-
if sys.version_info >= (3, 10):
181-
from types import NoneType as NoneType
182-
else:
183-
# Used by type checkers for checks involving None (does not exist at runtime)
184-
@final
185-
class NoneType:
186-
def __bool__(self) -> Literal[False]: ...
180+
# Used by type checkers for checks involving None (does not exist at runtime)
181+
@final
182+
class NoneType:
183+
def __bool__(self) -> Literal[False]: ...

stdlib/types.pyi

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

4242
@final
43-
class FunctionType:
43+
class FunctionType(Callable):
4444
__closure__: Tuple[_Cell, ...] | None
4545
__code__: CodeType
4646
__defaults__: Tuple[Any, ...] | None
@@ -248,7 +248,7 @@ class _StaticFunctionType:
248248
def __get__(self, obj: object | None, type: type | None) -> FunctionType: ...
249249

250250
@final
251-
class MethodType:
251+
class MethodType(Callable):
252252
__closure__: Tuple[_Cell, ...] | None # inherited from the added function
253253
__defaults__: Tuple[Any, ...] | None # inherited from the added function
254254
__func__: _StaticFunctionType
@@ -259,7 +259,7 @@ class MethodType:
259259
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
260260

261261
@final
262-
class BuiltinFunctionType:
262+
class BuiltinFunctionType(Callable):
263263
__self__: object | ModuleType
264264
__name__: str
265265
__qualname__: str
@@ -269,14 +269,14 @@ BuiltinMethodType = BuiltinFunctionType
269269

270270
if sys.version_info >= (3, 7):
271271
@final
272-
class WrapperDescriptorType:
272+
class WrapperDescriptorType(Callable):
273273
__name__: str
274274
__qualname__: str
275275
__objclass__: type
276276
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
277277
def __get__(self, obj: Any, type: type = ...) -> Any: ...
278278
@final
279-
class MethodWrapperType:
279+
class MethodWrapperType(Callable):
280280
__self__: object
281281
__name__: str
282282
__qualname__: str
@@ -285,14 +285,14 @@ if sys.version_info >= (3, 7):
285285
def __eq__(self, other: Any) -> bool: ...
286286
def __ne__(self, other: Any) -> bool: ...
287287
@final
288-
class MethodDescriptorType:
288+
class MethodDescriptorType(Callable):
289289
__name__: str
290290
__qualname__: str
291291
__objclass__: type
292292
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
293293
def __get__(self, obj: Any, type: type = ...) -> Any: ...
294294
@final
295-
class ClassMethodDescriptorType:
295+
class ClassMethodDescriptorType(Callable):
296296
__name__: str
297297
__qualname__: str
298298
__objclass__: type
@@ -384,9 +384,7 @@ if sys.version_info >= (3, 9):
384384
def __getattr__(self, name: str) -> Any: ... # incomplete
385385

386386
if sys.version_info >= (3, 10):
387-
@final
388-
class NoneType:
389-
def __bool__(self) -> Literal[False]: ...
387+
NoneType = type(None)
390388
EllipsisType = ellipsis # noqa F811 from builtins
391389
from builtins import _NotImplementedType
392390

0 commit comments

Comments
 (0)