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

docstring-code-format incorrectly formats semicolons+expressions #11480

Open
Tracked by #13371
JasonGrace2282 opened this issue May 21, 2024 · 3 comments
Open
Tracked by #13371
Labels
bug Something isn't working docstring Related to docstring linting or formatting formatter Related to the formatter

Comments

@JasonGrace2282
Copy link

JasonGrace2282 commented May 21, 2024

Example

"""
>>> l = []
>>> l.append(3); l
[3]
"""

Expected

"""
>>> l = []
>>> l.append(3)
>>> l
[3]
"""

Result

"""
>>> l = []
>>> l.append(3)
... l
[3]
"""

Reproduce:

[tool.ruff.format]
docstring-code-format = true

And run ruff format on the file.

Ruff Version

$ ruff -V
ruff 0.4.4
@JasonGrace2282 JasonGrace2282 changed the title docstring-code-format fails with semicolons docstring-code-format fails with semicolons+expressions May 21, 2024
@charliermarsh charliermarsh added bug Something isn't working docstring Related to docstring linting or formatting formatter Related to the formatter labels May 21, 2024
@charliermarsh
Copy link
Member

Interesting. Is that actually an error, or just suboptimal formatting? I can't remember what the execution semantics are of doctests like that.

@JasonGrace2282
Copy link
Author

JasonGrace2282 commented May 21, 2024

Ah, bad phrasing on my part. It's simply incorrect formatting.

Edit: I misread your question. Running the doctest fails.

@JasonGrace2282 JasonGrace2282 changed the title docstring-code-format fails with semicolons+expressions docstring-code-format incorrectly formats semicolons+expressions May 21, 2024
@charliermarsh
Copy link
Member

Thanks for the follow-up. The request makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docstring Related to docstring linting or formatting formatter Related to the formatter
Projects
None yet
Development

No branches or pull requests

2 participants