Skip to content

pydantic.create_model + **fields fails when fields is explicitly typed #2216

@Zaczero

Description

@Zaczero

Describe the Bug

Direct create_model('M', x=(int, ...)) is fine, but create_model('M', **fields) fails when fields is annotated.

from typing import Any
from pydantic import create_model

fields: dict[str, tuple[type[Any], Any]] = {"x": (int, ...)}
M = create_model("M", **fields)

pyrefly output (pyrefly 0.49.0):

  • No matching overload found for function pydantic.main.create_model
    called with arguments: (Literal['M'], **dict[str, tuple[type[Any],
    Any]])

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions