GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch master (62458d)
by Raphaël
01:07
created

pyjection.resolvers   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 95%

Importance

Changes 0
Metric Value
wmc 8
eloc 21
dl 0
loc 51
rs 10
c 0
b 0
f 0
ccs 19
cts 20
cp 0.95

4 Methods

Rating   Name   Duplication   Size   Complexity  
A BaseResolver.resolve() 0 2 1
A BaseResolver.__init__() 0 2 1
A NameResolver.resolve() 0 3 2
A ServiceResolver.resolve() 0 11 4
1
"""
2
Module that contains all the resolvers.
3
4
A resolver is a class that is able to retrieve a dependency to inject.
5
"""
6 1
from pyjection.reference import Reference
7
8
9 1
class BaseResolver(object):
10
    """
11
    Base class for the resolvers
12
    """
13
14 1
    def __init__(self, injector):
15 1
        self._injector = injector
16
17 1
    def resolve(self, method_parameter, service):
18
        pass
19
20
21 1
class ServiceResolver(BaseResolver):
22
    """
23
    Try to resolve the dependency based on
24
    the service that has been provided to the injector.
25
    """
26
27 1
    def resolve(self, method_parameter, service):
28 1
        if method_parameter.name not in service.arguments:
29 1
            return None
30
31 1
        value = service.arguments[method_parameter.name]
32 1
        if not isinstance(value, Reference):
33 1
            return value
34
        # The value references an other dependency service
35 1
        if value.return_class:
36 1
            return self._injector.get_uninstantiated(value.name)
37 1
        return self._injector.get(value.name)
38
39
40 1
class NameResolver(BaseResolver):
41
    """
42
    Try to resolve the dependency based on the parameter name.
43
44
    If the latter is declared in the dependency injector then we retrieve it
45
    as the instance to inject.
46
    """
47
48 1
    def resolve(self, method_parameter, service):
49 1
        if self._injector.has_service(method_parameter.name):
50
            return self._injector.get(method_parameter.name)
51