| 199 | |
| 200 | |
| 201 | class _AttrGetter: |
| 202 | __slots__ = ("attr_name", "getter") |
| 203 | |
| 204 | def __init__(self, attr_name: str): |
| 205 | self.attr_name = attr_name |
| 206 | self.getter = operator.attrgetter(attr_name) |
| 207 | |
| 208 | def __call__(self, mapped_object: Any) -> Any: |
| 209 | obj = self.getter(mapped_object) |
| 210 | if obj is None: |
| 211 | state = base.instance_state(mapped_object) |
| 212 | mp = state.mapper |
| 213 | if self.attr_name in mp.attrs: |
| 214 | dict_ = state.dict |
| 215 | obj = dict_.get(self.attr_name, base.NO_VALUE) |
| 216 | if obj is None: |
| 217 | return Missing |
| 218 | else: |
| 219 | return Missing |
| 220 | |
| 221 | return obj |
| 222 | |
| 223 | def __reduce__(self) -> Tuple[Type[_AttrGetter], Tuple[str]]: |
| 224 | return _AttrGetter, (self.attr_name,) |
| 225 | |
| 226 | |
| 227 | def attribute_keyed_dict( |
no outgoing calls
no test coverage detected