ContextStack
- class app.util.config.context_stack.ContextStack[source]
Bases:
object
ContextStack(name: str | None = None, parent: ContextStack | None = None, current: CurrentType | None = None, token: _contextvars.Token | None = None)
Inheritance Diagram for ContextStack
Methods
__init__
([name, parent, current, token])find_inheritance
(name[, skip])Find a context by name in the stack.
find_name
(name[, skip])Check if a context with the given name exists in the stack.
get
()Get the current context from the stack.
iterate
([skip])Iterate over the current context and all parent contexts.
pop
([token])Pop the current context from the stack and return it.
push
(current[, name])Push a new context onto the stack.
with_context
(current[, name])Context manager to push a new context onto the stack.
with_updated_name
(name)Attributes
- CurrentType = CurrentType
- __init__(name: str | None = None, parent: ContextStack | None = None, current: CurrentType | None = None, token: Token | None = None) None
- Parameters:
name (str | None)
parent (ContextStack | None)
current (CurrentType | None)
token (Token | None)
- Return type:
None
- classmethod find_inheritance(name: str, skip: int = 0) dict[str, Any] | BaseModel | None [source]
Find a context by name in the stack.
- classmethod find_name(name: str, skip: int = 0) bool [source]
Check if a context with the given name exists in the stack.
- classmethod get() ContextStack | None [source]
Get the current context from the stack.
If the stack is empty, return None.
- Return type:
ContextStack | None
- classmethod iterate(skip: int = 0) Generator[ContextStack] [source]
Iterate over the current context and all parent contexts.
- Parameters:
skip (int)
- Return type:
- parent: ContextStack | None = None
- classmethod pop(token: Token | None = None) None [source]
Pop the current context from the stack and return it.
If the stack is empty, return None.
- Parameters:
token (Token | None)
- Return type:
None
- classmethod push(current: CurrentType, name: str | None = None) ContextStack [source]
Push a new context onto the stack.
- Parameters:
current (CurrentType)
name (str | None)
- Return type: