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
Fix default command in interactive_open #1793
Conversation
except ValueError: # Malformed shell tokens. | ||
args = [command] | ||
else: | ||
args = [open_anything()] |
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.
This construction looks like it could be simplified by simply redefining the function as
def interactive_open(targets, command = interactive_open()):
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.
That won't work because the command
parameter is being passed, it is just being explicitly set to a falsey value. So using a default argument won't work.
Nice work! I totally agree on the re-assigning fix! I just checked and it does indeed seem like So basically to me it boils down to better readability but accepting to call Also I don't know how robust it is to have a function call inside another function definition, that could be a problem in my proposition. |
As discussed in #1785, I like the idea, I think it would maybe make more sense to simply use the right default value for
Just from the top of my head, this seems a bit cleaner to me. |
But doesn't that leave open the possibility of crashing if the command is explicitly set to a falsey value? |
From the user perspective, I don't really know what you're expecting if you put It seems that on a non string value,
If it's important to handle nonsensical configuration(which I think it is), then handling this would probably make the code uglier than the solution you propose now, even though the "flow" of the program would make more sense in the normal cases. If you don't see a problem with this approach, and if nobody raises another point, I will probably merge this as is tomorrow in the evening. E: That being said, imho |
This looks good; thanks! And thanks for thinking through the error conditions. I don't have a particular opinion on what shows up in the default, but you're both right that it would be good to catch missing commands. I'm not 100% sure on the I'm going to write a brief changelog entry; can one or both of you please check to make sure it's correct? |
Fix default command in interactive_open
Fixes d5b7ce6