facebook / facebook/pyrefly

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

Open
#2,216 4 comments 0 reactions 0 assignees View on GitHub
needs-discussion pydantic stale
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

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

```py
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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.