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

Ruff: prefer single quotes over double quotes #2001

Merged
merged 2 commits into from
May 3, 2024

Conversation

adamjstewart
Copy link
Collaborator

I promise this is the single most controversial style change I will ever propose.

I hate double quotes. The only reason I've ever used double quotes is because black required them. Single quotes are better for the following reasons:

  • I don't have to press the Shift key as often
  • They are easier on the eyes, especially for short strings (in my opinion)
  • Python repr defaults to single quotes (print(repr("hello world")) displays 'hello world')
  • They don't have to be escaped in Jupyter Notebooks (yes, I edit those in vim)

Conversely, double quotes are better for the following reason:

  • Single quote apostrophes are more common than double quotes in text

However, both black and ruff default to " when ' is in the string, and vice versa. So this decision only affects strings that contain neither.

We will want to add this PR commit to .git-blame-ignore-revs after merging so that git blame still works correctly.

psf/black#118 also contains some arguments for and against single and double quotes.

@github-actions github-actions bot added documentation Improvements or additions to documentation datasets Geospatial or benchmark datasets models Models and pretrained weights testing Continuous integration testing samplers Samplers for indexing datasets trainers PyTorch Lightning trainers transforms Data augmentation transforms datamodules PyTorch Lightning datamodules losses Geospatial loss functions dependencies Packaging and dependencies scripts Training and evaluation scripts labels Apr 16, 2024
@adamjstewart adamjstewart merged commit b09122f into microsoft:main May 3, 2024
19 checks passed
@adamjstewart adamjstewart deleted the style/quotes branch May 3, 2024 17:30
@adamjstewart adamjstewart added this to the 0.6.0 milestone Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datamodules PyTorch Lightning datamodules datasets Geospatial or benchmark datasets dependencies Packaging and dependencies documentation Improvements or additions to documentation losses Geospatial loss functions models Models and pretrained weights samplers Samplers for indexing datasets scripts Training and evaluation scripts testing Continuous integration testing trainers PyTorch Lightning trainers transforms Data augmentation transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants