| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | 1 | import inspect |
|
| 2 | |||
| 3 | 1 | from .container import Container |
|
| 4 | |||
| 5 | |||
| 6 | 1 | def bind_to_container(container: Container): |
|
| 7 | 1 | def decorator(func): |
|
| 8 | 1 | return container.partial(func) |
|
| 9 | |||
| 10 | 1 | return decorator |
|
| 11 | |||
| 12 | |||
| 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 |