Skip to content

Dataframely mypy plugin: Inheritance not supported by TypedDict #54

@robinholzi

Description

@robinholzi

The dataframely mypy plugin doesn't support inheritance (parent collections) in the TypedDicts of collection filter failures. See "s1" is not a valid TypedDict key; expected one of ("s2") Mypymisc

# -------------------------------------- ARRANGE ------------------------------------- #

import polars as pl
import dataframely as dy

class Schema(dy.Schema):
    a = dy.Int64(primary_key=True)

class ParentCollection(dy.Collection):
    s1: dy.LazyFrame[Schema]

class ChildCollection(ParentCollection):
    s2: dy.LazyFrame[Schema]

    @dy.filter()
    def rule(self) -> dy.LazyFrame[Schema]:
        return self.s1.join(self.s2, on="a", how="inner")

valid, failures = ChildCollection.filter(
    {"s1": pl.DataFrame({"a": [1, 2, 3]}), "s2": pl.DataFrame({"a": [2, 3, 4]})},
    cast=True,
)

# --------------------------------------- ISSUE -------------------------------------- #

a = failures[
    "s1"
]  # Mypy: "s1" is not a valid TypedDict key; expected one of ("s2") Mypymisc
b = failures["s2"]

fyi. @delsner

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions