`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)
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Rust
- スター
- 7.2k
- フォーク
- 578
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
facebook/pyrefly のほかの issue
-
pytorch tensor-shapes typechecking
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue typechecking
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
cargo b warning: unused dependency `zstd`対応中かも @Narendersingh007 が 4 日前に担当しました。 オープンgood first issue
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
typechecking
難易度 4/5 3〜5日 初心者へのやさしさ 40/100
facebook/pyrefly の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
eventflux-io/eventflux#203 ·
メンテナーはふだん 1 日以内に返信
-
bug ui
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
userFRM/egui-charts#4068 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
trezor/trezor-firmware#8357 ·
メンテナーはふだん 2 日以内に返信
-
fuzz-crash review-followup
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信