The type of 'None'. This type can be written by users as 'None'.
| 1427 | |
| 1428 | |
| 1429 | class 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 |
no outgoing calls
searching dependent graphs…