_forward_ref.py 611 B

1234567891011121314151617181920212223
  1. from __future__ import annotations as _annotations
  2. from dataclasses import dataclass
  3. from typing import Union
  4. @dataclass
  5. class PydanticRecursiveRef:
  6. type_ref: str
  7. __name__ = 'PydanticRecursiveRef'
  8. __hash__ = object.__hash__
  9. def __call__(self) -> None:
  10. """Defining __call__ is necessary for the `typing` module to let you use an instance of
  11. this class as the result of resolving a standard ForwardRef.
  12. """
  13. def __or__(self, other):
  14. return Union[self, other] # type: ignore
  15. def __ror__(self, other):
  16. return Union[other, self] # type: ignore