-
Describe the bugTyper does not seem to be compatible with uppercase lettered arguments. To ReproduceSteps to reproduce the behavior with a minimum self-contained file. Replace each part with your own scenario:
import typer
app = typer.Typer()
@app.command()
def f(var_with_UPPERCASE: int, lowercase_var: int):
return var_with_UPPERCASE + lowercase_var
app()
python main.py 1 2
Expected behaviorTyper should preserve the variable case. Additional contextI 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 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
|
The issue seems to stem not from Typer but Click itself which doesn't seem to preserve the casing of the options/method arguments. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the help @aakuyr! 🙇 Yep, it comes from Click, and as Click is what does the work underneath, that is handled there. Also have in mind that for many scenarios letter case doesn't have significance in Windows, having something that requires uppercase might be confusing, or it could work on some platforms but not on others. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks. That kind of makes sense. I forgot what exact scenario I was under but I definitely had a case where uppercase letter is preferred. If this is not going to be supported, maybe raise a more interpretable error explicitly marking uppercase as not allowed? |
Beta Was this translation helpful? Give feedback.
-
|
I know this ticket is ~4 yrs old, and i've been using Typer for 3yrs of that, but I just today struggled for way to long to figure out why my optional argument wasn't working. I kept double checking the syntax for an optional string argument like: and kept getting the error I see now it is a design decision of Click since it is awkward to type mixed case at a cli, but for an optional argument, it is never actually typed, at this point it is just a variable name. I kinda agree with above, that maybe a raise a more interpretable error should be raised. or at least maybe point this out in the docs. I remember seeing the section on dashes and underscores, but I don't recall anything about mixed case. Anyway, mainly adding this comment so others hitting the unexpected keyword error might find this thread. thanks for all you do! |
Beta Was this translation helpful? Give feedback.
-
|
As I see it, this issue has two sides:
In the case At the same time variable names like Considering low level of support and assuming this behavior comes from Click, I think we can close this issue. |
Beta Was this translation helpful? Give feedback.
Thanks for the help @aakuyr! 🙇
Yep, it comes from Click, and as Click is what does the work underneath, that is handled there.
Also have in mind that for many scenarios letter case doesn't have significance in Windows, having something that requires uppercase might be confusing, or it could work on some platforms but not on others.