🌐 AI搜索 & 代理 主页
Skip to content

replace_with has incorrect argument typing #602

@esquonk

Description

@esquonk

Issue description

replace_with function is typed as:

def replace_with(repl_str: str) -> ParseAction:

It is my understanding that replace_with it so be used with set_parse_action to return an arbitrary object as a parse result. Also, it's own docstring has replace_with(math.nan), with a non-string argument. Finally, set_parse_action accepts a Callable with return type Any.

The current implementation works, but produces errors when type-checking, e.g. with mypy:

error: Argument 1 has incompatible type "dict[Never, Never]"; expected "str"  [arg-type]

Proposed solution

I believe replace_with should have an argument of type Any.

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