Skip to content

Accessing a columns name via .alias makes the type checker complainΒ #51

@FrithjofWinkelmannQC

Description

@FrithjofWinkelmannQC

When accessing the name of a column via .alias, the type checker complains, since the type is str | None. See the following example:

class MetricSchema(dy.Schema):
    name = dy.String()
    value = dy.Float64()

df.join(other_df, on=MetricSchema.name.alias)
# mypy will complain with something like
# error: Argument 2 to "join" of "Expr" has incompatible type "str | None"; expected "str"

Right now you either have to silence mypy with eg # type: ignore[arg-type] or define an extra string constant for column names. It would be nice to have a method similar to .col() that raises a ValueError if the column name is not set and otherwise returns the string name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions