| 355 | |
| 356 | |
| 357 | class _GetColumns: |
| 358 | __slots__ = ("cls",) |
| 359 | |
| 360 | cls: Type[Any] |
| 361 | |
| 362 | def __init__(self, cls: Type[Any]): |
| 363 | self.cls = cls |
| 364 | |
| 365 | def __getattr__(self, key: str) -> Any: |
| 366 | mp = class_mapper(self.cls, configure=False) |
| 367 | if mp: |
| 368 | if key not in mp.all_orm_descriptors: |
| 369 | raise AttributeError( |
| 370 | "Class %r does not have a mapped column named %r" |
| 371 | % (self.cls, key) |
| 372 | ) |
| 373 | |
| 374 | desc = mp.all_orm_descriptors[key] |
| 375 | if desc.extension_type is interfaces.NotExtension.NOT_EXTENSION: |
| 376 | assert isinstance(desc, attributes.QueryableAttribute) |
| 377 | prop = desc.property |
| 378 | if isinstance(prop, SynonymProperty): |
| 379 | key = prop.name |
| 380 | elif not isinstance(prop, ColumnProperty): |
| 381 | raise exc.InvalidRequestError( |
| 382 | "Property %r is not an instance of" |
| 383 | " ColumnProperty (i.e. does not correspond" |
| 384 | " directly to a Column)." % key |
| 385 | ) |
| 386 | return getattr(self.cls, key) |
| 387 | |
| 388 | |
| 389 | inspection._inspects(_GetColumns)( |
no outgoing calls
no test coverage detected