Conditions | 2 |
Total Lines | 11 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2 |
Changes | 0 |
1 | 1 | import inspect |
|
13 | 1 | def dependency_definition(container: Container): |
|
14 | 1 | def decorator(func): |
|
15 | 1 | try: |
|
16 | 1 | arg_spec = inspect.getfullargspec(func) |
|
17 | 1 | return_type = arg_spec.annotations["return"] |
|
18 | 1 | except KeyError: |
|
19 | 1 | raise SyntaxError("Function used as a definition must have a return type") |
|
20 | 1 | container.define(return_type, func) |
|
21 | 1 | return func |
|
22 | |||
23 | return decorator |
||
24 |