Skip to content

Typer not compatible with uppercase lettered arguments. #167

Description

@thisiscam

Describe the bug

Typer does not seem to be compatible with uppercase lettered arguments.

To Reproduce

Steps to reproduce the behavior with a minimum self-contained file.

Replace each part with your own scenario:

  • Create a file main.py with:
import typer

app = typer.Typer()


@app.command()
def f(var_with_UPPERCASE: int, lowercase_var: int):
  return var_with_UPPERCASE + lowercase_var


app()
  • Call it with:
python main.py 1 2
  • It outputs:
TypeError: f() got an unexpected keyword argument 'var_with_uppercase'
  • But I expected it to output:
3

Expected behavior

Typer should preserve the variable case.

Additional context

I suspect this is related to Typer's name mangling with underscores, which always turns the variable to lower case? I think a more robust solution is to allow any case + "_"/"-" combinations, or at least an option in Typer(...) to enable this feature will be great!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion or problem

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions