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 ignores "quote-style = 'single'" #12003

Closed
jackdesert opened this issue Jun 24, 2024 · 1 comment
Closed

Ruff ignores "quote-style = 'single'" #12003

jackdesert opened this issue Jun 24, 2024 · 1 comment
Labels
question Asking for support or clarification

Comments

@jackdesert
Copy link

Ruff wants to use double quotes even though pyproject.toml specifies single quotes.

Keywords: single, single quote, quote style

Code snippet:

print('single')
print("double")

Command:

ruff check --config pyproject.toml sample.py

Output:

sample.py:1:1: D100 Missing docstring in public module
sample.py:1:7: Q000 [*] Single quotes found but double quotes preferred
Found 2 errors.
[*] 1 fixable with the `--fix` option.

Expected Output:

sample.py:1:1: D100 Missing docstring in public module
sample.py:2:7: Q000 [*] Double quotes found but single quotes preferred
Found 2 errors.
[*] 1 fixable with the `--fix` option.

Version:

ruff 0.4.10

pyproject.toml:

[tool.ruff]

target-version = 'py311'

# Exclude a variety of commonly ignored directories.
exclude = [
    '.bzr',
    '.direnv',
    '.eggs',
    '.git',
    '.hg',
    '.mypy_cache',
    '.nox',
    '.pants.d',
    '.ruff_cache',
    '.svn',
    '.tox',
    '.venv',
    '__pypackages__',
    '_build',
    'buck-out',
    'build',
    'dist',
    'node_modules',
    'venv',
    'env',
]

# Same as Black.
line-length = 88

[tool.ruff.lint]

# Enable All rules.
# We may not want all rules, but this is a good starting point for you to
# see the full capabilities of ruff
select = ['ALL']

unfixable = []

per-file-ignores = {}

# Putting an entry in `ignore` will ignore all errors that start with that string.
# For example, adding `T` will ignore all errors beginning with `T`,
# whereas adding `T20` will only ignore the `T20` error
# (and probably any errors that start with `T20`)
ignore = ['INP001', # implicit-namespace-package
          'T20',    # flake8-print (warns when there are print statements)

          # One of either D212 or D213 must be disabled.
          # (I prefer disabling D212 (Multi-line docstring summary should start at the first line)
          #  because I like text inside a docstring
          #  to start the line below the three ''')
          #'D213', # See https://github.com/charliermarsh/ruff/issues/2281
          'D212', # See https://github.com/charliermarsh/ruff/issues/2281
          # One of D203 and D200 must be disabled.
          # No strong preference here.
          # One expects a blank line before a class docstring
          #'D203', # See https://github.com/charliermarsh/ruff/issues/2281
          'D211', # See https://github.com/charliermarsh/ruff/issues/2281


          'D200', # Allow multiline docstring even when it could fit on one line

          'C408', # Allow instantiating dictionary as dict(key=value)
          'G004', # Logging statement uses f-string
          'E501', # Line too long
          'ANN101', # Don't require self to be annotated.
          'PTH', # allow os.path
          'PLR0913', # allow too many arguments
          'COM812', # may cause issues with ruff format
          'ISC001', # may cause issues with ruff format

]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = '^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$'

# In order for a particular class to be fixable with `ruff [file] --fix`,
# the class must be in `fixable`.
fixable = ['A', 'B', 'C', 'D', 'E', 'F', 'Q']

# I like the google docstyle
# See https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
# and http://google.github.io/styleguide/pyguide.html
# https://gist.github.com/redlotus/3bc387c2591e3e908c9b63b97b11d24e
[tool.ruff.lint.pydocstyle]
convention = 'google'  # Or 'numpy', or 'pep257'


[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

# Configure single quotes
[tool.ruff.format]
quote-style = 'single'
@zanieb
Copy link
Member

zanieb commented Jun 24, 2024

Hi! The configuration setting you're checking is for ruff formatruff check only runs the linter right now (see #8232 for more on that). If you run ruff format, your desired quote style should be enforced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

3 participants