-
Notifications
You must be signed in to change notification settings - Fork 13
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 #139 from evo-company/refactor-hiku-extensions
pass execution_context as an argment, drop ExtensionFactory
- Loading branch information
Showing
10 changed files
with
146 additions
and
196 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
from .base_extension import Extension | ||
from .base_extension import ExtensionFactory | ||
|
||
__all__ = [ | ||
"Extension", | ||
"ExtensionFactory", | ||
] |
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,25 +1,16 @@ | ||
from typing import Callable, Dict, Iterator | ||
|
||
from hiku.context import ExecutionContext | ||
from hiku.extensions.base_extension import Extension, ExtensionFactory | ||
from hiku.extensions.base_extension import Extension | ||
|
||
|
||
class _CustomContextImpl(Extension): | ||
class CustomContext(Extension): | ||
def __init__( | ||
self, | ||
get_context: Callable[[ExecutionContext], Dict], | ||
): | ||
self.get_context = get_context | ||
|
||
def on_execute(self) -> Iterator[None]: | ||
self.execution_context.context = self.get_context( | ||
self.execution_context | ||
) | ||
def on_execute(self, execution_context: ExecutionContext) -> Iterator[None]: | ||
execution_context.context = self.get_context(execution_context) | ||
yield | ||
|
||
|
||
class CustomContext(ExtensionFactory): | ||
ext_class = _CustomContextImpl | ||
|
||
def __init__(self, get_context: Callable[[ExecutionContext], Dict]): | ||
super().__init__(get_context) |
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
Oops, something went wrong.