Skip to content

Commit c41f3e9

Browse files
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>
1 parent 5d467a7 commit c41f3e9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stdlib/2and3/_typeshed/__init__.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import array
1616
import mmap
1717
import sys
1818
from typing import AbstractSet, Container, Iterable, Protocol, Text, Tuple, TypeVar, Union
19-
from typing_extensions import Literal
19+
from typing_extensions import Literal, final
2020

2121
_KT = TypeVar("_KT")
2222
_KT_co = TypeVar("_KT_co", covariant=True)
@@ -164,3 +164,8 @@ if sys.version_info >= (3,):
164164
else:
165165
ReadableBuffer = Union[bytes, bytearray, memoryview, array.array, mmap.mmap, buffer]
166166
WriteableBuffer = Union[bytearray, memoryview, array.array, mmap.mmap, buffer]
167+
168+
# Used by type checkers for checks involving None (does not exist at runtime)
169+
@final
170+
class NoneType:
171+
def __bool__(self) -> Literal[False]: ...

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy