···4242 # the real type. Assumes that this has no subclasses.
4343 return typing_inspect.get_args(cls)[0]
44444545+ @classmethod
4646+ def __get_validators__(cls):
4747+ """Pydantic v1 validator"""
4848+ yield cls.validate
4949+5050+ @classmethod
5151+ def validate(cls, v):
5252+ """Validate and convert to EntityT"""
5353+ if isinstance(v, cls):
5454+ return v
5555+ if isinstance(v, dict):
5656+ if 'type' in v and 'id' in v:
5757+ return cls(type=v['type'], id=v['id'])
5858+ raise TypeError(f'EntityT expects dict with "type" and "id" keys, got {v}')
5959+ raise TypeError(f'EntityT expected EntityT or dict; got {type(v)}')
6060+45614662# Make sure this looks as it's used in the Osprey language when used in error messages.
4763EntityT.__name__ = 'Entity'