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

Add support for Ruff's docstring-code-format #343

Open
blink1073 opened this issue Dec 16, 2023 · 7 comments
Open

Add support for Ruff's docstring-code-format #343

blink1073 opened this issue Dec 16, 2023 · 7 comments

Comments

@blink1073
Copy link

Ruff has a replacement for blacken-docs: astral.sh/blog/ruff-v0.1.8#formatting-code-snippets-in-docstrings.

In Jupyter Server we're skipping PC111 for now.

@henryiii
Copy link
Collaborator

It doesn’t support .md or .rst files quite yet. It should soon.

@blink1073
Copy link
Author

Ah, good call out, thanks!

@nstarman
Copy link

nstarman commented Apr 27, 2024

When it does support these file types, then this can replace blacken-docs, right? Answered.

astral-sh/ruff#8237

@jarrodmillman
Copy link
Member

When using ruff for docstring formatting, should repo-review mark not using blacken-doc in red?
2024-07-04T10:17:47,931979264-07:00

And this link doesn't seem to exist: https://learn.scientific-python.org/development/guides/style/#PC111

@henryiii
Copy link
Collaborator

henryiii commented Jul 4, 2024

This check is for formatting code samples in docs (not docstrings), which I think ruff doesn’t support yet (basically all the pieces are there, but not the infrastructure. If the link is missing, that’s a bug, will check!

@jarrodmillman
Copy link
Member

If we add - id: ruff-format in .pre-commit-config.yaml, we can add this

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

to pyproject.toml to enable some docstring code formatting. Is it worth mentioning this option? If not, should we be cautioning against it.

https://docs.astral.sh/ruff/formatter/#configuration

@henryiii
Copy link
Collaborator

henryiii commented Aug 7, 2024

I think we should be recommending it, but we should also make sure we don't have overlap with blacken-docs trying to format code blocks in python files. I'd not thought of it doing that, but if it does, we should note how to avoid it.

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

No branches or pull requests

4 participants