Normalize an iterable of Mark or MarkDecorator objects into a list of marks by retrieving the `mark` attribute on MarkDecorator instances. :param mark_list: marks to normalize :returns: A new list of the extracted Mark objects
(
mark_list: Iterable[Union[Mark, MarkDecorator]]
)
| 369 | |
| 370 | |
| 371 | def normalize_mark_list( |
| 372 | mark_list: Iterable[Union[Mark, MarkDecorator]] |
| 373 | ) -> Iterable[Mark]: |
| 374 | """ |
| 375 | Normalize an iterable of Mark or MarkDecorator objects into a list of marks |
| 376 | by retrieving the `mark` attribute on MarkDecorator instances. |
| 377 | |
| 378 | :param mark_list: marks to normalize |
| 379 | :returns: A new list of the extracted Mark objects |
| 380 | """ |
| 381 | for mark in mark_list: |
| 382 | mark_obj = getattr(mark, "mark", mark) |
| 383 | if not isinstance(mark_obj, Mark): |
| 384 | raise TypeError(f"got {repr(mark_obj)} instead of Mark") |
| 385 | yield mark_obj |
| 386 | |
| 387 | |
| 388 | def store_mark(obj, mark: Mark) -> None: |
no outgoing calls
no test coverage detected