-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from AlTosterino/feature/move-to-lidi
🏗️ Move injection to `lidipy`
- Loading branch information
Showing
13 changed files
with
60 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from adrpy.injection import setup_injection | ||
|
||
setup_injection() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from adrpy.injection.modules import RepositoryModules, ServiceModules | ||
from adrpy.injection.settings import configure_settings | ||
from injector import Inject as Inject_Injector | ||
from injector import Injector | ||
from adrpy.injection.modules import bind_modules | ||
from adrpy.injection.settings import bind_settings | ||
from lidipy import Lidi | ||
|
||
injector = Injector((configure_settings, RepositoryModules(), ServiceModules())) | ||
lidi = Lidi() | ||
|
||
Inject = Inject_Injector | ||
|
||
def setup_injection() -> None: | ||
bind_settings(lidi) | ||
bind_modules(lidi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
from adrpy.repositories.adr.base import BaseADRRepository | ||
from adrpy.repositories.adr.repository import ADRFileRepository | ||
from adrpy.services.template.base import BaseTemplateService | ||
from adrpy.services.template.service import MakoTemplateService | ||
from adrpy.shared_kernel.settings import Settings | ||
from injector import Module, provider, singleton | ||
from lidipy import Lidi | ||
|
||
|
||
class RepositoryModules(Module): | ||
@singleton | ||
@provider | ||
def provide_adr_repository(self, settings: Settings) -> BaseADRRepository: | ||
from adrpy.repositories.adr.repository import ADRFileRepository | ||
|
||
return ADRFileRepository(settings=settings) | ||
|
||
|
||
class ServiceModules(Module): | ||
@singleton | ||
@provider | ||
def provide_template_service(self) -> BaseTemplateService: | ||
from adrpy.services.template.service import MakoTemplateService | ||
|
||
return MakoTemplateService() | ||
def bind_modules(lidi: Lidi) -> None: | ||
lidi.bind(BaseADRRepository, ADRFileRepository(settings=lidi.resolve(Settings))) | ||
lidi.bind(BaseTemplateService, MakoTemplateService()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from adrpy.shared_kernel.settings import Settings | ||
from injector import Binder, singleton | ||
from lidipy import Lidi | ||
|
||
|
||
def configure_settings(binder: Binder) -> None: | ||
binder.bind(Settings, to=Settings(), scope=singleton) | ||
def bind_settings(lidi: Lidi) -> None: | ||
lidi.bind(Settings, Settings(), singleton=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from typing import cast | ||
|
||
import pytest | ||
from injector import Injector | ||
from adrpy.injection import setup_injection | ||
from lidipy import Lidi | ||
|
||
|
||
@pytest.fixture | ||
def injector() -> Injector: | ||
from adrpy.injection import injector | ||
def lidi() -> Lidi: | ||
from adrpy.injection import lidi | ||
|
||
return cast(Injector, injector) | ||
setup_injection() | ||
yield lidi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters