-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix mypy errors, make lato compatibile with 3.9
- Loading branch information
Showing
11 changed files
with
65 additions
and
56 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
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
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,36 +1,37 @@ | ||
import contextlib | ||
from typing import Iterator | ||
|
||
from lato import Application | ||
|
||
|
||
@contextlib.contextmanager | ||
def override_app(application: Application, *args, **kwargs) -> Application: | ||
def override_app(application: Application, *args, **kwargs) -> Iterator[Application]: | ||
original_dependency_provider = application.dependency_provider | ||
overriden_dependency_provider = original_dependency_provider.copy(*args, **kwargs) | ||
overridden_dependency_provider = original_dependency_provider.copy(*args, **kwargs) | ||
|
||
application.dependency_provider = overriden_dependency_provider | ||
application.dependency_provider = overridden_dependency_provider | ||
yield application | ||
|
||
application.dependency_provider = original_dependency_provider | ||
|
||
|
||
@contextlib.contextmanager | ||
def override_ctx(application: Application, *args, **kwargs) -> Application: | ||
def override_ctx(application: Application, *args, **kwargs) -> Iterator[Application]: | ||
original_transaction_context = application.transaction_context | ||
|
||
def overriden_transaction_context(**dependencies): | ||
ctx = original_transaction_context(**dependencies) | ||
ctx.dependency_provider = ctx.dependency_provider.copy(*args, **kwargs) | ||
return ctx | ||
|
||
application.transaction_context = overriden_transaction_context | ||
application.transaction_context = overriden_transaction_context # type: ignore | ||
yield application | ||
|
||
application.transaction_context = original_transaction_context | ||
application.transaction_context = original_transaction_context # type: ignore | ||
|
||
|
||
@contextlib.contextmanager | ||
def override(application: Application, *args, **kwargs) -> Application: | ||
def override(application: Application, *args, **kwargs) -> Iterator[Application]: | ||
with override_app(application, **kwargs) as overridden1: | ||
with override_ctx(overridden1, **kwargs) as overridden2: | ||
yield overridden2 |
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,5 @@ | ||
from typing import Union | ||
from lato.message import Message | ||
|
||
HandlerAlias = Union[type[Message], str] | ||
DependencyIdentifier = Union[type, str] |
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