anchor.py 471 B

1234567891011121314151617181920
  1. from __future__ import annotations
  2. if False: # MYPY
  3. from typing import Any, Dict, Optional, List, Union, Iterator # NOQA
  4. anchor_attrib = '_yaml_anchor'
  5. class Anchor:
  6. __slots__ = 'value', 'always_dump'
  7. attrib = anchor_attrib
  8. def __init__(self) -> None:
  9. self.value = None
  10. self.always_dump = False
  11. def __repr__(self) -> Any:
  12. ad = ', (always dump)' if self.always_dump else ""
  13. return f'Anchor({self.value!r}{ad})'