Skip to content

Conversation

dangotbanned
Copy link
Member

@dangotbanned dangotbanned commented Sep 18, 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

Been seeing this locally for a few days, but never in CI

image

@dangotbanned dangotbanned marked this pull request as ready for review September 18, 2025 17:13
@FBruzzesi
Copy link
Member

Out of curiosity, do you know why this is the case?

@dangotbanned
Copy link
Member Author

@FBruzzesi

Out of curiosity, do you know why this is the case?

Maybe related to https://discuss.python.org/t/unsoundness-of-contravariant-self-type/86338

But I guess to zoom in on it a bit more ...

I think the issue is EagerExprT gets bound in EagerDataFrame.aggregate - but then occasionally fails to be re-used for EagerDataFrame.select.

My intention for the typing is to say:

EagerDataFrame is generic over EagerDataFrame._expr: type[EagerExprT]
The type of EagerExprT should bind to the class

This is problematic because here that type is contravariant:

def select(self, *exprs: CompliantExprT_contra) -> Self: ...

But here that type is invariant:

def aggregate(self, *exprs: EagerExprT) -> Self:

... and then in EagerExpr itself, it depends on an invariant EagerDataFrame 😳:

class EagerExpr(
DepthTrackingExpr[EagerDataFrameT, EagerSeriesT],
Protocol[EagerDataFrameT, EagerSeriesT],
):
_call: EvalSeries[EagerDataFrameT, EagerSeriesT]
_scalar_kwargs: ScalarKwargs
def __init__(
self,
call: EvalSeries[EagerDataFrameT, EagerSeriesT],
*,
depth: int,
function_name: str,
evaluate_output_names: EvalNames[EagerDataFrameT],

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.

2 participants