Thanks to visit codestin.com
Credit goes to github.com

Skip to content

replace_with has incorrect argument typing #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
esquonk opened this issue Mar 31, 2025 · 1 comment
Open

replace_with has incorrect argument typing #602

esquonk opened this issue Mar 31, 2025 · 1 comment

Comments

@esquonk
Copy link

esquonk commented Mar 31, 2025

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.

@ptmcg
Copy link
Member

ptmcg commented Mar 31, 2025

Makes sense to me - thanks for submitting, I'll include this in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants