Repository navigation
fix default value become ... in hover a sqlalchemy orm class #4802 - #5723
asukaminato0721 wants to merge 2 commits into
Conversation
|
This pull request has been imported. If you are a Meta employee, you can view this in D133853504. (Because this pull request was imported automatically, there will not be any future comments.) |
This comment has been minimized.
This comment has been minimized.
stroxler
left a comment
There was a problem hiding this comment.
Thanks!
It looks like there's one issue we need to fix before we merge, we're creating too many Unknown types (which probably explains the noisy mypy primer result).
AI reviewer notes here:
Do not turn synthetic defaults into unknown constructor types
At pyrefly/lib/alt/class/dataclass.rs:1369–1370, every existing field-default payload is now attached to the generated parameter:
Required::Optional(field_flags.default.clone())But an ordinary annotated class-body default is represented upstream by a placeholder implicit Any, not its actual value. Wrapping that placeholder in DefaultValue does not make it a real value. DefaultValue’s visitor delegates to ty, so signature unknownness checks now encounter it.
Minimal counterexample:
from dataclasses import dataclass
from typing import Callable
@dataclass
class C:
value: int = 0
init: Callable[[C, int], None] = C.__init__Check with pyrefly check --preset all:
- Base: no
partially-unknown-typeerror. - Head:
The type of attribute __init__ is partially unknown; it contains an implicit Any. - mypy --strict: accepts the equivalent reproducer.
- Runtime: constructor/default behavior is ordinary and valid.
Violated contract: the generated constructor’s annotated parameter and return types are fully known. A sentinel recording “this field has a default” is not an unknown input annotation. The PR’s display improvement should not create an unknown type in that signature.
Impact: valid, fully annotated dataclass constructor references gain false diagnostics under all. The primer’s large partially-unknown cluster is consistent with this path, including ordinary-default dataclasses in Meson. This is not a complaint about all being strict: the unknownness is introduced by the checker itself.
Why fix here: this is a direct regression caused by the new payload propagation, on a common construct. Documenting it or disabling the diagnostic would not repair the representation/consumer boundary. Do not attach the existing placeholder Any as a genuine callable default. Preserve default display while keeping synthetic optionality markers out of signature unknownness, and rerun the primer after correction.
18198f4 to
5ba8bab
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
stroxler
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
|
This pull request has been merged in 78a9517. |
Summary
Fixes #4802
SQLAlchemy, attrs constructor hovers now show explicit defaults, including None.
Test Plan