Skip to content

Unpacking dict in class header (i.e. in class kwargs) #1762

@yangdanny97

Description

@yangdanny97

I'm making sure about the plan of the feature of unpacking in class.
I'm using pydantic-xml, and doing a lot of duplicated namespace handling. So implement a dict like this is very useful but not supported by pyrefly:

from pydantic_xml import BaseXmlModel, attr

META: dict[str, Any] = {
    "nsmap": {"": "http://xxxxxxx"},
    "ns": "",
    "search_mode": SearchMode.UNORDERED,
}

class UniqueID(BaseXmlModel, **META, tag="UniqueID"):

    id: Annotated[str, attr(name="ID")]
    id_context: Annotated[str | None, attr(name="ID_Context")] = None

The code: Sandbox

Originally posted by @TommrraraSnow in #1756

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions