-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support case-insensitive usage of Python Fire CLIs #43
Comments
issue courtesy of @zqureshi via https://twitter.com/zeeshanq/status/838604546389733378 :) |
Depending when fire inspects the objects to construct a lookup table, it could emit a warning as soon as it detects collisions. Always defaulting to lowercase with a warning seems like a reasonable default. |
You could add a config flag that errors out if collision detected for people who want to be sure. |
I don't think we'll want to add such a flag. In the majority of cases it will be clear what to do, and we'll just want to pick a sensible way to handle the occasional ambiguity. To be clear, the ambiguous case is only when an object has multiple members that have the same name but different capitalizations, and the end users enters a third capitalization that's different from any of the actual capitalizations. In this case, I'm leaning toward simply showing a warning and exiting rather than trying to guess (e.g. via edit distance) what the user was trying to do. |
As a quick drive by comment, this is as much about the functionality of Python as anything else. This is a constant loss of small amounts of programming time. Specifically, that "a_class", "aclass", and "aClass" are each distinct. I would recommend that the Fire API give a better error message, such as:
Meaning that a valid option matched except for case, underscores, and, possibly, spaces. |
Hey guys, is anyone working on this issue? If not, I wanted to take a stab at it. |
Go for it. :) I know there was some ambiguity in the original issue description, so here's what I think we should do. I think we should support precisely the exact match case and the all-lowercase case. If the all-lowercase case is ambiguous (and not also an exact match), then we'll show a usage error. How does that sound to you? |
Sounds awesome. It'll be my first open source contribution so I'm a bit nervous but wish me luck! haha |
Welcome to the open source world! A few notes:
Good luck! |
Hey, sorry I've been away for some time but I looked at this issue again today and just wanted to check up on my understanding of the code and validity of my approach for this issue. I assumed the main code base I'll be touching will be in the
I'm going to try these two things later today. I'm still learning about the codebase so if y'all find something glaringly off or think there's some better way to solve this issue, please don't hesitate to mention it! I'm very open to opinions and guidance. Hope y'all have a good day. |
May I take a shot at this? |
is this issue still relevant? if so, i’d like to work on it. |
Much like how we allow users to use hyphens
-
in place of underscores, this Issue is to allow users to use all-lowercase versions of identifiers.Typical case
Corner cases
Unlike with the -/_ support, there can potentially be members with multiple capitalization variants of the name.
E.g.
If the user provides an exact match, it's clear what we should do. I'm open to discussion about how to handle the ambiguous case.
Why?
The primary motivation is that command line tools typically use lower case commands, whereas Python classes (and occasionally methods/functions) typically have capital names. By allowing these capital names to be used via their lower-case variant, the CLIs that result from normal python code will feel natural more often.
Possible extension
If we also support dropping/adding -/_s in some situations, then people could use snake-case to refer to CamelCase items... just brainstorming. Thoughts?
The text was updated successfully, but these errors were encountered: