jacked.matchers._type   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TypeMatcher.priority() 0 2 1
A TypeMatcher.match() 0 9 3
A TypeMatcher._matching_type() 0 2 1
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