-
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.
EXPERIMENTAL: reworked context injection such it is handled immediate…
…ly in 'structured_view.ask()' and than stored in 'ExposedFunction' instances
- Loading branch information
1 parent
a154577
commit 623effd
Showing
14 changed files
with
97 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
class ContextNotAvailableError(Exception): | ||
class BaseContextError(Exception): | ||
""" | ||
An exception inheriting from BaseContextException pointining that no sufficient context information | ||
was provided by the user while calling view.ask(). | ||
A base error for context handling logic. | ||
""" | ||
|
||
|
||
class SuitableContextNotProvidedError(BaseContextError): | ||
""" | ||
Raised when method argument type hint points that a contextualization is available | ||
but not suitable context was provided. | ||
""" | ||
|
||
def __init__(self, filter_fun_signature: str, context_class_name: str) -> None: | ||
# this syntax 'or BaseCallerContext' is just to prevent type checkers | ||
# from raising a warning, as filter_.context_class can be None. It's essenially a fallback that should never | ||
# be reached, unless somebody will use this Exception against its purpose. | ||
# TODO consider raising a warning/error when this happens. | ||
|
||
message = ( | ||
f"No context of class {context_class_name} was provided" | ||
f"while the filter {filter_fun_signature} requires it." | ||
) | ||
super().__init__(message) |
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
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.