| 270 | |
| 271 | @classmethod |
| 272 | def _deserialize_path(cls, path: _SerializedPath) -> _PathRepresentation: |
| 273 | def _deserialize_mapper_token(mcls: Any) -> Any: |
| 274 | return ( |
| 275 | # note: we likely dont want configure=True here however |
| 276 | # this is maintained at the moment for backwards compatibility |
| 277 | orm_base._inspect_mapped_class(mcls, configure=True) |
| 278 | if mcls not in PathToken._intern |
| 279 | else PathToken._intern[mcls] |
| 280 | ) |
| 281 | |
| 282 | def _deserialize_key_token(mcls: Any, key: Any) -> Any: |
| 283 | if key is None: |
| 284 | return None |
| 285 | elif key in PathToken._intern: |
| 286 | return PathToken._intern[key] |
| 287 | else: |
| 288 | mp = orm_base._inspect_mapped_class(mcls, configure=True) |
| 289 | assert mp is not None |
| 290 | return mp.attrs[key] |
| 291 | |
| 292 | p = tuple( |
| 293 | chain( |
| 294 | *[ |
| 295 | ( |
| 296 | _deserialize_mapper_token(mcls), |
| 297 | _deserialize_key_token(mcls, key), |
| 298 | ) |
| 299 | for mcls, key in path |
| 300 | ] |
| 301 | ) |
| 302 | ) |
| 303 | if p and p[-1] is None: |
| 304 | p = p[0:-1] |
| 305 | return p |
| 306 | |
| 307 | def serialize(self) -> _SerializedPath: |
| 308 | path = self.path |