Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Polars:`Annotated[pl.DataFrame, S]` does not resolve when `S` is a type var bound to a schema class

オープン
#5,445 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
57/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, rust

調査の方向性

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 の本文から書いたものです。

説明

dataframe
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, S is Reading, so reveal_type(frame.df) should show DataFrame[interval_end: Datetime, value: Float64].
  • In reveal_df, frame.df["typo"] should be an unknown-column error, the same as if the property had been annotated Annotated[pl.DataFrame, Reading] directly.
  • In return_df, S is never solved, so frame.df staying a plain DataFrame is 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 はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

facebook/pyrefly のほかの issue

facebook/pyrefly の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。