gh-119670: Add force keyword only argument to shlex.quote#148846
Open
jb2170 wants to merge 6 commits intopython:mainfrom
Open
gh-119670: Add force keyword only argument to shlex.quote#148846jb2170 wants to merge 6 commits intopython:mainfrom
force keyword only argument to shlex.quote#148846jb2170 wants to merge 6 commits intopython:mainfrom
Conversation
There are propositions to add a single-quote-double-quote switch (pythongh-90630), so to avoid hiccups of people passing `force` as a positional and it being used for the single-double switch, we make kwargs kwargs-only.
Test special cases of strings that don't need quoting, do need quoting, do use `force`, don't use `force` etc. I've tried to be exhaustive.
…to `shlex.force`
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #119670
Supersedes my out-of-date PR #119674
We use
forceinstead ofalwaysas a word more consistent with other programming jargon (like inrm -fthefis for 'force') as discussedCommits
shlex.quote's kwargs kwargs-only. Backwards compatible. There are propositions to add a single-quote-double-quote switch, which I'm ambivalent about, but to future-proof against hiccups of people passingforceas a positional and it ending up being used as the wrong kwarg, we make the kwargs kwargs-only, eg likejson.loads.As mentioned I'm also going to open an issue about
shlex.quotereturning"''"for falsey non-str data. This PR and that issue seem independent of each other, that is this PR doesn't need to be held back until that issue is addressed.📚 Documentation preview 📚: https://cpython-previews--148846.org.readthedocs.build/