INNER CODE UNIT · Python

decorator

smagafurov/fastapi-jsonrpc · fastapi_jsonrpc/__init__.py:151

    def decorator(obj):
        assert issubclass(obj, BaseModel)
        effective_module = module or obj.__module__

        # Determine if we need module prefix in title to prevent deduplication
        # Exclude fastapi_jsonrpc (core library) and __main__ (entry point, unlikely to collide)
        needs_module_prefix = effective_module and effective_module not in ('fastapi_jsonrpc', '__main__')

        opts: dict[str, Any] = {
            '__base__': tuple(obj.mro()[1:]),  # remove self from __base__
            '__module__': effective_module,
            **{
                field_name: (field.annotation, field)
                for field_name, field in obj.model_fields.items()
            },
        }
        if obj.model_config:
            opts.pop('__base__')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…