Skip to content

Type system errors when list[dict] is passed from Talonscript #553

@AndreasArvidsson

Description

@AndreasArvidsson

I get the following error message in the log

2023-02-24 16:05:56 ERROR Line 14: user.cursorless_multiple_target_command(action: str, targets: list[dict], arg1: Any = <class 'user.cursorless-talon.src.command.NotSet'>, arg2: Any = <class 'user.cursorless-talon.src.command.NotSet'>, arg3: Any = <class 'user.cursorless-talon.src.command.NotSet'>)
2023-02-24 16:05:56 ERROR Line 14:   parameter 2 (targets) expects type list[dict], got list[typing.Any]

That Talon script looks like this: https://github.com/pokey/cursorless-vscode/blob/1b18e38efe87904b918faf88c7d16c0ffa1b0e1f/cursorless-talon/src/cursorless.talon#L13-L14

{user.cursorless_move_bring_action} <user.cursorless_move_bring_targets>:
    user.cursorless_multiple_target_command(cursorless_move_bring_action, cursorless_move_bring_targets)

The action is defined here: https://github.com/pokey/cursorless-vscode/blob/1b18e38efe87904b918faf88c7d16c0ffa1b0e1f/cursorless-talon/src/command.py#L96-L111
The problem is that if I add print statements for the type getting passed in is list[dict]

def cursorless_multiple_target_command(
        action: str,
        targets: list[dict],
        arg1: Any = NotSet,
        arg2: Any = NotSet,
        arg3: Any = NotSet,
    ):
        """Execute multi-target cursorless command"""
        print(type(targets))
        for t in targets:
            print(type(t))

Output:

2023-02-24 16:05:56    IO <class 'list'>
2023-02-24 16:05:56    IO <class 'dict'>
2023-02-24 16:05:56    IO <class 'dict'>

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