Buckets:

download
raw
2.05 kB
from ._base import *
class Params(fastapi.params.Body):
def __init__(
self,
default: Any,
*,
media_type: str = 'application/json',
title: str = None,
description: str = None,
gt: float = None,
ge: float = None,
lt: float = None,
le: float = None,
min_length: int = None,
max_length: int = None,
regex: str = None,
**extra: Any,
):
super().__init__(
default,
embed=False,
media_type=media_type,
alias='params',
title=title,
description=description,
gt=gt,
ge=ge,
lt=lt,
le=le,
min_length=min_length,
max_length=max_length,
regex=regex,
**extra,
)
components = {}
def component_name(name: str, module: str = None):
"""OpenAPI components must be unique by name"""
def decorator(obj):
obj.__name__ = name
obj.__qualname__ = name
if module is not None: obj.__module__ = module # see: pydantic.schema.get_long_model_name
key = (obj.__name__, obj.__module__)
if key in components:
if components[key].schema() != obj.schema():
raise RuntimeError(f"Different models with the same name detected: {obj!r} != {components[key]}")
return components[key]
components[key] = obj
return obj
return decorator
def is_scope_child(owner: type, child: type):
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

Xet Storage Details

Size:
2.05 kB
·
Xet hash:
789991d4c2a362ba5c29d3946716a7ad1d6654054651eb35d83adc9125b830f5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.