Skip to content
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

Quote extras to guard shells with glob qualifiers #11842

Conversation

matthewfeickert
Copy link
Contributor

@matthewfeickert matthewfeickert commented Mar 6, 2023

Resolves #11811

Shells like zsh have glob qualifiers that will error if an extra is not quoted. While the glob qualifiers can be disabled, adding quotes guards against errors if people are copy-pasting or do not know that they can disable the behavior.

A NEWS.rst is not included as this documentation change is minor enough that I assume it would be considered "trivial" in the context of

> The NEWS.rst file is managed using towncrier and all non trivial changes must be accompanied by a news entry.

If the maintainers would like a NEWS.rst for this PR I will happily provide one though.

@matthewfeickert
Copy link
Contributor Author

@uranusjr As you had some thoughts over on Issue #11811 I thought I'd tag you here for review as well.

While I agree that quoting

python -m pip install SomePackage==1.0.4 # specific version

to

python -m pip install 'SomePackage==1.0.4'

could be useful I'm not sure if additionally quoting

python -m pip install SomePackage # latest version

to

python -m pip install 'SomePackage'

really helps. What are your thoughts?

@uranusjr
Copy link
Member

uranusjr commented Mar 6, 2023

Yea, quoting simple names is probably not worthwhile. Quote everything that’s not a bare package name seems like a reasonable rule of thumb to send to shell beginners to me.

I wonder if it’s a good idea to use single quotes instead of double in the Linux/Mac part.

@uranusjr
Copy link
Member

uranusjr commented Mar 6, 2023

Could you add a .doc news fragment for this?

@matthewfeickert
Copy link
Contributor Author

I wonder if it’s a good idea to use single quotes instead of double in the Linux/Mac part.

Yeah, I think single quotes would be better. I was using double quotes to follow the existing standard of the page in PR #8589. I'll switch everything over to single quotes unless someone objects.

Could you add a .doc news fragment for this?

Sure!

@matthewfeickert matthewfeickert force-pushed the feat/quote-extras-to-guard-aginst-globbing-shells branch from d33a2f9 to 8c8cf0e Compare March 6, 2023 06:27
@matthewfeickert matthewfeickert force-pushed the feat/quote-extras-to-guard-aginst-globbing-shells branch from 8c8cf0e to cd4b251 Compare March 6, 2023 06:31
@uranusjr
Copy link
Member

uranusjr commented Mar 6, 2023

I don’t think double quotes work on cmd.exe, so we’ll need to stick with double quotes there (it’s still used by a lot of newcomers). Otherwise looks good to me.

@matthewfeickert
Copy link
Contributor Author

I don’t think double quotes work on cmd.exe, so we’ll need to stick with double quotes there (it’s still used by a lot of newcomers). Otherwise looks good to me.

Okay let me revert those.

Quote everything that’s not a bare package name seems like a reasonable rule of thumb to send to shell beginners to me.

I've now applied that in the second commit

@matthewfeickert matthewfeickert force-pushed the feat/quote-extras-to-guard-aginst-globbing-shells branch from 2146414 to 2b79e42 Compare March 6, 2023 06:54
@matthewfeickert
Copy link
Contributor Author

matthewfeickert commented Mar 6, 2023

All style changes are now applied: Single quotes are used for Linux/Mac and double quotes are used for Windows to follow existing style conventions.

(sorry for the multiple force pushes, I apparently can't spell well in my commit messages.)

* Shells like zsh have glob qualifiers that will error if an extra
  is not quoted. While the glob qualifiers can be disabled, adding
  quotes guards against errors if people are copy-pasting or do not
  know that they can disable the behavior.
* Use single quotes for Linux/Mac and use double quotes for Windows
  to follow existing style conventions.
* As a means to make things easier for new users, quote everything in
  a `pip install` command that is part of a package that isn't just
  a bare package name.
* Use single quotes for Linux/Mac and use double quotes for Windows
  to follow existing style conventions.
@matthewfeickert matthewfeickert force-pushed the feat/quote-extras-to-guard-aginst-globbing-shells branch from 3a7c500 to ced4569 Compare March 14, 2023 05:22
@uranusjr uranusjr added the type: docs Documentation related label Mar 14, 2023
@uranusjr uranusjr merged commit 85eb40d into pypa:main Mar 14, 2023
@matthewfeickert matthewfeickert deleted the feat/quote-extras-to-guard-aginst-globbing-shells branch March 14, 2023 05:51
matthewfeickert added a commit to matthewfeickert/packaging.python.org that referenced this pull request Mar 15, 2023
* As pointed out by Henry in PR 1216, adding quotes to version
  information on packages provides safeguards against common
  mistakes. Additionally this matches style with
  pypa/pip#11842.
matthewfeickert added a commit to matthewfeickert/packaging.python.org that referenced this pull request Mar 15, 2023
* As pointed out by Henry in PR 1216, adding quotes to version
  information on packages provides safeguards against common
  mistakes. Additionally this matches style with
  pypa/pip#11842.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: docs Documentation related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quote extras to avoid problems with glob qualifiers in shells
2 participants