Total Complexity | 5 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | PRIVATE MODULE: do not import (from) it directly. |
||
3 | |||
4 | This module contains the ``TypeMatcher``class. |
||
5 | """ |
||
6 | import inspect |
||
7 | from jacked._injectable import Injectable |
||
8 | from jacked._container import Container |
||
9 | from jacked.matchers._base_matcher import BaseMatcher |
||
10 | |||
11 | |||
12 | class TypeMatcher(BaseMatcher): |
||
13 | |||
14 | def match( |
||
15 | self, |
||
16 | hint: object, |
||
17 | injectable: Injectable, |
||
18 | container: Container): |
||
19 | cls = hint.__args__[0] |
||
20 | if (inspect.isclass(injectable.subject) |
||
21 | and issubclass(injectable.subject, cls)): |
||
22 | return injectable.subject |
||
23 | |||
24 | def _matching_type(self): |
||
25 | return type |
||
26 | |||
27 | def priority(self): |
||
28 | return 200 |
||
29 |