Total Complexity | 2 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | PRIVATE MODULE: do not import (from) it directly. |
||
3 | |||
4 | This module contains the ``ListMatcher``class. |
||
5 | """ |
||
6 | import inspect |
||
7 | from jacked._inject import get_candidates |
||
8 | from jacked._injectable import Injectable |
||
9 | from jacked._container import Container |
||
10 | from jacked.matchers._base_matcher import BaseMatcher |
||
11 | |||
12 | |||
13 | class ListMatcher(BaseMatcher): |
||
14 | |||
15 | def match( |
||
16 | self, |
||
17 | hint: object, |
||
18 | injectable: Injectable, |
||
19 | container: Container): |
||
20 | sub_hint = getattr(hint, '__args__', [None])[0] |
||
21 | param = inspect.Parameter(name='_', kind=1, annotation=sub_hint) |
||
22 | return get_candidates(param.annotation, container=container) |
||
23 | |||
24 | def _matching_type(self): |
||
25 | return list |
||
26 |