INNER CODE UNIT · Python
is_scope_child
smagafurov/fastapi-jsonrpc · fastapi_jsonrpc/__init__.py:198
def is_scope_child(owner: Type[BaseModel], child: Type[BaseModel]) -> bool:
return (
(
owner.__dict__.get(child.__name__) is child or
owner.__dict__.get(child.__name__) is Optional[child]
) and
child.__qualname__ == owner.__qualname__ + '.' + child.__name__ and
child.__module__ == owner.__module__
)
def rename_if_scope_child_component(owner: type, child, postfix: str):
if is_scope_child(owner, child):
child = component_name(f'{owner.__name__}.{postfix}', owner.__module__)(child)
return child
class BaseError(Exception):