facebook / facebook/pyrefly

Pydantic: create `__init__` overloads when validating by both name and alias

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

Description

### Describe the Bug

```
class Model4(BaseModel, validate_by_name=True, validate_by_alias=True):
x: int = Field(alias="y")

# ❓ Overloads? (May incur combinatorial explosion)
reveal_type(Model4.__init__) # (self: Model4, *, x: Any = ..., y: Any = ..., **Unknown) -> None
```

Needs further discussion, since a naive implementation wouldn't scale well.

### 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.