| Conditions | 5 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5 |
| 1 | """Functions to interact with mapped classes and instances.""" |
||
| 64 | 1 | def _ensure_mapped(obj, *, expected=True): |
|
| 65 | 1 | mapper = common.get_mapper(obj) |
|
| 66 | |||
| 67 | 1 | if mapper and not expected: |
|
| 68 | 1 | msg = "{!r} is already mapped".format(obj) |
|
| 69 | 1 | raise TypeError(msg) |
|
| 70 | |||
| 71 | 1 | if not mapper and expected: |
|
| 72 | 1 | msg = "{!r} is not mapped".format(obj) |
|
| 73 | 1 | raise TypeError(msg) |
|
| 74 | |||
| 75 | return mapper |
||
| 76 |