-
Notifications
You must be signed in to change notification settings - Fork 76
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
Validating CLI arguments #561
Conversation
Validating CLI arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @mehtamohit013, can you give @tl3119 a hand? he's a bit stuck on how to approach this. you can meet on Slack and brainstorm do some pair programming session
all the relevant info is in the issue description: #531
Yeah sure. Btw @tl3119 are you on Slack, I can't seem to find you in Direct Messages? |
Yeah, I am on Slack, I have sent you a message! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once your PR is ready for review, please mark it as so (this one is still marked as a draft)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tl3119 please request a review only when all the comments have been addressed. there are still some comments where I don't see an answer
All the comments and issues have been addressed now |
Validating CLI arguments
Validating CLI arguments
@edublancas lgtm |
src/sql/magic.py
Outdated
def check_random_arguments(self, line="", cell=""): | ||
# check only for cell magic | ||
if cell != "": | ||
tokens = line.split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use shlex insted of line.split
: https://docs.python.org/3/library/shlex.html#shlex.split
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed we have to call if like this: shlex.split('--hello "--another"', posix=False)
so it doesn't remove any quotes inside the string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, update it to use shlex now
src/sql/magic.py
Outdated
# If the token starts with "--", it is an argument | ||
breakLoop = False | ||
for token in tokens: | ||
if token.startswith("--"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are short options as well, so we also need to check if the options start with a single dash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update it now
src/sql/magic.py
Outdated
def check_random_arguments(self, line="", cell=""): | ||
# check only for cell magic | ||
if cell != "": | ||
tokens = line.split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed we have to call if like this: shlex.split('--hello "--another"', posix=False)
so it doesn't remove any quotes inside the string
Validating CLI arguments
great work @tl3119 - this is gonna help users a lot! |
🙌🙌🙌 |
I am happy it can help users a lot! |
Describe your changes
Add checking for unrecognized arguments and a test
Issue number
Closes #531
Checklist before requesting a review
pkgmt format
📚 Documentation preview 📚: https://jupysql--561.org.readthedocs.build/en/561/