Skip to content

Conversation

@dangotbanned
Copy link
Member

@dangotbanned dangotbanned commented Aug 26, 2025

What type of PR is this? (check all applicable)

  • πŸ’Ύ Refactor
  • ✨ Feature
  • πŸ› Bug Fix
  • πŸ”§ Optimization
  • πŸ“ Documentation
  • βœ… Test
  • 🐳 Other

Related issues

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

Looks like I added this in (#2223), but that was before EagerDataFrame inherited collect from CompliantLazyFrame

class EagerDataFrame(
CompliantDataFrame[EagerSeriesT, EagerExprT_contra],
Protocol[EagerSeriesT, EagerExprT_contra],
):

class EagerDataFrame(
CompliantDataFrame[
EagerSeriesT, EagerExprT, NativeDataFrameT, "DataFrame[NativeDataFrameT]"
],
CompliantLazyFrame[EagerExprT, "Incomplete", "DataFrame[NativeDataFrameT]"],
ValidateBackendVersion,
Protocol[EagerSeriesT, EagerExprT, NativeDataFrameT, NativeSeriesT],
):

Current typing produces this weird edge case where we warn on.lazy().lazy() but don't on .collect().collect()

import pandas as pd

import narwhals as nw

data = {"a": ["A", "B", "A"]}
df = nw.from_native(pd.DataFrame(data))

compliant = df._compliant_frame
compliant.lazy(None)
compliant.lazy(None).lazy(None)  # type: ignore[attr-defined]

compliant.lazy(None).collect(None)
compliant.lazy(None).collect(None).collect(None)  # shouldn't be supported in typing

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one thanks

@MarcoGorelli MarcoGorelli merged commit 82052e2 into main Aug 26, 2025
30 of 32 checks passed
@MarcoGorelli MarcoGorelli deleted the compliant-df-remove-collect branch August 26, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants