Skip to content

Derive takes columns as **kwargs, so naming one by constant cannot type-check #632

Description

@vertix

What breaks

Derive.__init__ takes the columns to derive as **transforms beside a keyword-only meta:

def __init__(self, *, meta: dict[str, Any] | None = None, **transforms: Callable[[Episode], Any]):

A caller whose column name is a constant has to unpack a dict, and every such call fails the type check: with **{name: fn} the checker cannot rule out name == 'meta', so it matches the transform function against meta: dict[str, Any] | None and reports reportArgumentType. This holds whether the key is a variable, a Final, or a plain string literal — verified against basedpyright on a reduced case.

The consequence is that the only way to name a derived column by constant is to earn a baseline entry. positronic/cfg/ds/internal.py:54 is exactly that:

_RENAME_ROBOT_COMMAND = Derive(**{keys.TARGET_EE_POSE: Get('robot_commands.pose', None)})

and it sits in .basedpyright/baseline.json for it. So the API pushes callers toward bare literals, which is hardcoded-keys — a name shared with whoever reads the column, written as a literal because the typed alternative does not check.

The shape of a fix

Take the transforms as a mapping rather than as **kwargs, so a constant key is an ordinary value and meta cannot collide with a column name. Around 58 call sites use the keyword form, so this is a mechanical sweep rather than a small edit, and it wants doing in one pass rather than alongside unrelated work.

Note the collision is also a real (if unlikely) hole: a dataset column named meta is unrepresentable today.

Where this came up

Review of #591 asked positronic/replay_record.py to define its replay channel name once. Two of the three spellings now share a constant; RestoreCommand.__init__ keeps its literal keyword because unifying it would have added a baseline entry, which grandfathered-violation forbids.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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