Define NoneType class in _typeshed

Type checkers can use this to handle protocol matching for None (e.g. `foo: Hashable = None`).

Co-authored-by: Eric Traut <erictr@microsoft.com>
This commit is contained in:
Eric Traut
2020-09-20 15:42:23 -07:00
committed by GitHub
parent 5d467a7756
commit c41f3e9bf9

View File

@@ -16,7 +16,7 @@ import array
import mmap
import sys
from typing import AbstractSet, Container, Iterable, Protocol, Text, Tuple, TypeVar, Union
from typing_extensions import Literal
from typing_extensions import Literal, final
_KT = TypeVar("_KT")
_KT_co = TypeVar("_KT_co", covariant=True)
@@ -164,3 +164,8 @@ if sys.version_info >= (3,):
else:
ReadableBuffer = Union[bytes, bytearray, memoryview, array.array, mmap.mmap, buffer]
WriteableBuffer = Union[bytearray, memoryview, array.array, mmap.mmap, buffer]
# Used by type checkers for checks involving None (does not exist at runtime)
@final
class NoneType:
def __bool__(self) -> Literal[False]: ...