Skip to content

Formatter: Docstrings with quote-style = "single" configuration #7615

@alkatar21

Description

@alkatar21

Following #1904 (comment) I tried the new configuration

[tool.ruff.format]
# Use single quotes rather than double quotes.
quote-style = "single"

But now docstrings are also formatted with single quotes:

def func():
  '''Docstring.'''
  string_taking_function('A string')

I thought with docstrings there is no real discussion that they always use """ and it only refers to normal strings and PEP 8 also says so. Like the following example:

def func():
  """Docstring."""
  string_taking_function('A string')

There was a short discussion on Discord already where @charliermarsh mentioned the following:

Yeah need to look into this — we’ve discussed it before but started off by using the configured quotes universally.
Worth checking what the single-quote Black forks do here, and if users of our flake8-quotes plug-in tend to use double quotes for docstrings even when enforcing single quotes

For me it would be important that docstrings always use """ regardless of quote-style. I am not quite sure if this is to be understood as a feature request or rather as a bug. D300 considers this as a bug as well.

Metadata

Metadata

Assignees

Labels

acceptedReady for implementationformatterRelated to the formatter

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions