Descriptor override of an `Any` attribute is rejected with decorator syntax but accepted with explicit assignment
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
Start by tracing the class member override checks that produce the bad-override diagnostic, then compare how decorator syntax and explicit assignment represent descriptor values. Use the supplied sandbox example to reproduce the discrepancy and look for nearby tests covering inherited Any attributes and descriptors. Done means both forms are accepted consistently, with the relevant regression test passing.
索引モデルが issue の本文から書いたものです。
説明
Describe the Bug
class Descriptor:
def __init__(self, *_: object) -> None:
pass
def __get__(self, *_: object) -> int:
return 1
def __set__(self, *_: Any) -> None:
pass
class Base:
x: Any
class Assigned(Base):
x: Descriptor = Descriptor(lambda cls: 1) # Accepted
class Decorated(Base):
@Descriptor
def x(cls) -> int: # Rejected
return 1
Specifically, the error is:
ERROR Class member `Decorated.x` overrides parent class `Base` in an inconsistent manner [bad-override]
`Decorated.x` and `Base.x` must both be descriptors
I'd expect both forms to be accepted: they both create an instance of the same descriptor class. Using decorator syntax shouldn't change whether it can override the inherited Any attribute.
For context, we're currently migrating from Pyright to Pyrefly and this issue is the largest cause of errors, specifically, we're using a SQLAlchemy construction:
@declared_attr.directive
@classmethod
def __table_args__(cls) -> Any:
...
Sandbox Link
(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
-
typechecking
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
-
quansight
難易度 3/5 半日 初心者へのやさしさ 55/100
-
Version-gated early exits: `from copy import replace` is accepted but `copy.replace` is rejectedオープンquansight
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
`type[Self]` converted to a callable drops constructor signature対応中かも @crypt0lith が 2 日前に担当しました。 オープンhas-open-pr typechecking
-
warning: hiding a lifetime that's elided elsewhere is confusing対応中かも @jay23606 が 2 日前に担当しました。 オープンgood first issue
facebook/pyrefly の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 94/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 2 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area:ui
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openfootmanager/openfootmanager#1365 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 90/100
JackMechem/marbble#305 ·
メンテナーはふだん 1 日以内に返信