Prefer (move to the front) distributions that have metadata. Ref python/importlib_resources#489.
(dists: Iterable[Distribution])
| 488 | |
| 489 | @staticmethod |
| 490 | def _prefer_valid(dists: Iterable[Distribution]) -> Iterable[Distribution]: |
| 491 | """ |
| 492 | Prefer (move to the front) distributions that have metadata. |
| 493 | |
| 494 | Ref python/importlib_resources#489. |
| 495 | """ |
| 496 | |
| 497 | has_metadata = ExceptionTrap(MetadataNotFound).passes( |
| 498 | operator.attrgetter('metadata') |
| 499 | ) |
| 500 | |
| 501 | buckets = bucket(dists, has_metadata) |
| 502 | return itertools.chain(buckets[True], buckets[False]) |
| 503 | |
| 504 | @staticmethod |
| 505 | def at(path: str | os.PathLike[str]) -> Distribution: |
no test coverage detected