(cls, kind, *, groups=None)
| 75 | |
| 76 | @classonly |
| 77 | def get_group(cls, kind, *, groups=None): |
| 78 | if not isinstance(kind, cls): |
| 79 | raise TypeError(f'expected KIND, got {kind!r}') |
| 80 | if groups is None: |
| 81 | groups = ['type'] |
| 82 | elif not groups: |
| 83 | groups = () |
| 84 | elif isinstance(groups, str): |
| 85 | group = groups |
| 86 | if group not in cls._GROUPS: |
| 87 | raise ValueError(f'unsupported group {group!r}') |
| 88 | groups = [group] |
| 89 | else: |
| 90 | unsupported = [g for g in groups if g not in cls._GROUPS] |
| 91 | if unsupported: |
| 92 | raise ValueError(f'unsupported groups {", ".join(repr(unsupported))}') |
| 93 | for group in groups: |
| 94 | if kind in cls._GROUPS[group]: |
| 95 | return group |
| 96 | else: |
| 97 | return kind.value |
| 98 | |
| 99 | @classonly |
| 100 | def resolve_group(cls, group): |
no test coverage detected