Polars:`Annotated[pl.DataFrame, S]` does not resolve when `S` is a type var bound to a schema class
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 57/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- devtools, testing-qa
調査の方向性
Start with the generic Frame[S] property annotated as Annotated[pl.DataFrame, S] and the reproduction using Pyrefly 1.4.0. Check how type-variable metadata is handled when resolving the property on Frame[Reading], then compare the revealed type and frame.df["typo"] diagnostic with the expected results. Done means the specialised property reveals the schema and reports the unknown column, while the unsolved S case may remain a plain DataFrame.
索引モデルが issue の本文から書いたものです。
説明
Describe the Bug
Background
Annotated[pl.DataFrame, Schema] builds a column schema when Schema is a literal class. When the metadata is a type variable, the annotation silently becomes a plain DataFrame. Specialising the enclosing class or function later does not bring the schema back. This makes it impossible to write a generic wrapper which is typed by a schema.
Reproduction
pyrefly 1.4.0, polars 2.1.0, Python 3.14.
from typing import Annotated, reveal_type
import polars as pl
class Reading:
interval_end: pl.Datetime
value: pl.Float64
class Frame[S]:
def __init__(self, df: pl.DataFrame, schema: type[S]) -> None:
self._df = df
@property
def df(self) -> Annotated[pl.DataFrame, S]:
return self._df
def reveal_df(frame: Frame[Reading]) -> None:
reveal_type(frame.df)
frame.df["typo"]
def return_df[S](frame: Frame[S]) -> Annotated[pl.DataFrame, S]:
return frame.df
Output
INFO revealed type: DataFrame [reveal-type]
INFO 0 errors
Frame.df itself reveals as [S](self: Frame[S]) -> DataFrame.
Expected
- In
reveal_df,SisReading, soreveal_type(frame.df)should showDataFrame[interval_end: Datetime, value: Float64]. - In
reveal_df,frame.df["typo"]should be anunknown-columnerror, the same as if the property had been annotatedAnnotated[pl.DataFrame, Reading]directly. - In
return_df,Sis never solved, soframe.dfstaying a plainDataFrameis fine (as it is today)
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
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
-
Handle editable installs with .pth files対応中かも @connernilsen が 1 日前に担当しました。 オープンconfiguration
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
-
narrowing typechecking
難易度 4/5 1〜2日 初心者へのやさしさ 48/100
-
django language-server
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
facebook/pyrefly の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
dekobon/big-code-analysis#1729 ·
メンテナーはふだん 1 日以内に返信
-
bug help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
akitaonrails/ai-memory#1888 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
peteonrails/voxtype#941 ·
メンテナーはふだん 4 日以内に返信
-
bug priority:medium triage:maintainable
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ccusage/ccusage#2000 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信