MCPcopy Index your code
hub / github.com/python/mypy / NoneType

Class NoneType

mypy/types.py:1429–1467  ·  view source on GitHub ↗

The type of 'None'. This type can be written by users as 'None'.

Source from the content-addressed store, hash-verified

1427
1428
1429class NoneType(ProperType):
1430 """The type of 'None'.
1431
1432 This type can be written by users as 'None'.
1433 """
1434
1435 __slots__ = ()
1436
1437 def __init__(self, line: int = -1, column: int = -1) -> None:
1438 super().__init__(line, column)
1439
1440 def can_be_true_default(self) -> bool:
1441 return False
1442
1443 def __hash__(self) -> int:
1444 return hash(NoneType)
1445
1446 def __eq__(self, other: object) -> bool:
1447 return isinstance(other, NoneType)
1448
1449 def accept(self, visitor: TypeVisitor[T]) -> T:
1450 return visitor.visit_none_type(self)
1451
1452 def serialize(self) -> JsonDict:
1453 return {".class": "NoneType"}
1454
1455 @classmethod
1456 def deserialize(cls, data: JsonDict) -> NoneType:
1457 assert data[".class"] == "NoneType"
1458 return NoneType()
1459
1460 def write(self, data: WriteBuffer) -> None:
1461 write_tag(data, NONE_TYPE)
1462 write_tag(data, END_TAG)
1463
1464 @classmethod
1465 def read(cls, data: ReadBuffer) -> NoneType:
1466 assert read_tag(data) == END_TAG
1467 return NoneType()
1468
1469
1470# NoneType used to be called NoneTyp so to avoid needlessly breaking

Callers 15

check_func_defMethod · 0.90
check_setattr_methodMethod · 0.90
check_assignmentMethod · 0.90
type_check_raiseMethod · 0.90
enter_partial_typesMethod · 0.90
get_isinstance_typeMethod · 0.90
analyze_typeddict_accessFunction · 0.90

Calls

no outgoing calls

Tested by 11

test_callable_typeMethod · 0.72
test_false_only_tupleMethod · 0.72
test_noneMethod · 0.72
test_any_typeMethod · 0.72
test_simple_genericsMethod · 0.72
test_noneMethod · 0.72
test_dynamic_typeMethod · 0.72
make_overloadMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…