facebook / facebook/pyrefly

Class-level field default with Optional[int] assigned to int field

Open
#2,735 3 comments 0 reactions 0 assignees View on GitHub
needs-discussion typechecking usability
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

Minimal repro:
```python
class AgentConfig:
cycle_budget: int | None = 1
cycles_remaining: int = cycle_budget # FP: int | None not assignable to int
```
Only Mypy aligns with Pyrefly on this behavior today.

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxlKnHAAQCCA5jOgC4DCu6kziAHXT0R9SqWowA%2BtgCumVu0T0IHegB96AOR4x6AXnoBGIaLETYcKQCcYAW1SrV-FWsPjJM%2BYpEBiegBiAArKquwa2rr06LjhtHAQzOio2LD07Liu7CAANCCy7NBwJOSIIP4AqoVQEOyk9GCy6JSFPHBCQpgwYA241g7sUuiydtgw1gAU%2BKEcAJT0ALQAfPRw7NaCwqK27LLWwmACIFojYxv0wPgAvkdCuSBktmBQpIQZdlAU-kGkTy%2BrGBwBDEPD4e1QrXQhCE-gAyjA9AALdjsYhwRAAegxj26L0IfWYGLYGMwuEocAxlFBiXBkIxvWs9FQADdHDRUnoqbwadYIRAePRcMRIcUhGR2IieAtmeMEgLDEcAMyEIwAJlu6BAVzyqBaEBlAWgMAoaCweCIZC1QA

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