`bad-argument-type` in synthesized __init__ for a descriptor-typed field on a pydantic BaseModel with a @dataclass_transform metaclass (regression in 1.5.0)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Reproduce with the two snippets in the issue: run pyrefly 1.5.0 on the Pydantic variant and confirm bad-argument-type for x, then compare against 1.4.1 to narrow the regression. The relevant area is synthesized __init__ generation for @dataclass_transform classes and how descriptor __set__ value types are read when a Pydantic ModelMetaclass is involved. Add a regression test covering the Pydantic metaclass plus descriptor field, and check the non-Pydantic case still infers int; done when both snippets type-check and the test suite passes.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the Bug
I've run into some typing errors with pyrefly 1.5.0 that didn't come up on 1.4.1 in the context of the Dagster framework's configurable resources. It doesn't seem to be specific to Dagster, and can be reproduced with Pydantic BaseModel classes. I'm currently using Python 3.14.10 with these pydantic packages installed in a Pixi + conda-forge managed environment:
pixi list | grep pydantic
Installed for: osx-arm64
pydantic 2.14.4 pyh5ded981_0
pydantic-core 2.50.5 py314h50bbb68_0
pydantic-extra-types 2.11.1 pyhcf101f3_0
pydantic-settings 2.16.3 pyh5ded981_0
The result is a number of failures in our dagster project where we define a number of ConfigurableResource classes with dg.ResourceDependency[T] fields.
Minimal reproducers below generated using Claude, demonstrating behavior of similar metaclasses both with and without Pydantic
No Error Without Pydantic
from typing import Any, Generic, TypeVar, dataclass_transform
T = TypeVar("T")
class Dep(Generic[T]):
def __get__(self, obj: Any, owner: Any) -> T:
raise NotImplementedError
def __set__(self, obj: object | None, value: T) -> None: ...
@dataclass_transform(kw_only_default=True)
class Meta(type): ...
class Base(metaclass=Meta): ...
class M(Base):
x: Dep[int]
M(x=1) # OK: __init__ takes the __set__ value type (int)
Error with Pydantic (on pyrefly 1.5.0)
from typing import Any, Generic, TypeVar, dataclass_transform
from pydantic import BaseModel, Field
from pydantic.main import ModelMetaclass
T = TypeVar("T")
class Dep(Generic[T]):
"""Stand-in for dagster.ResourceDependency[T]."""
def __get__(self, obj: Any, owner: Any) -> T:
raise NotImplementedError
def __set__(self, obj: object | None, value: T) -> None: ...
@dataclass_transform(kw_only_default=True, field_specifiers=(Field,))
class Meta(ModelMetaclass): ... # mirrors dagster's BaseConfigMeta
class Base(BaseModel, metaclass=Meta): ...
class M(Base):
x: Dep[int]
M(x=1) # 1.4.1: OK 1.5.0: bad-argument-type, parameter `x` has type `Dep[Unknown]`
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response
- Lingua principale
- Rust
- Stelle
- 7.2k
- Fork
- 578
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di facebook/pyrefly
-
pytorch tensor-shapes typechecking
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
good first issue typechecking
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
cargo b warning: unused dependency `zstd`Forse già presa @Narendersingh007 l’ha presa 4 giorni fa. Apertagood first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
-
False negative when assigning generic function without parameter default to callback protocolApertatypechecking
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
Tutte le issue di facebook/pyrefly
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
eventflux-io/eventflux#203 ·
I maintainer di solito rispondono entro 1 giorno
-
bug ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
userFRM/egui-charts#4068 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
trezor/trezor-firmware#8357 ·
I maintainer di solito rispondono entro 2 giorni
-
fuzz-crash review-followup
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno