镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Closed

Description

@blink1073

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.

Activity

  1. henryiii commented on Dec 16, 2023

    @henryiii
    Collaborator

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

  2. blink1073 commented on Dec 16, 2023

    @blink1073
    Author

    Ah, good call out, thanks!

  3. nstarman commented on Apr 27, 2024

    @nstarman

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

    astral-sh/ruff#8237

  4. jarrodmillman commented on Jul 4, 2024

    @jarrodmillman
    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

  5. henryiii commented on Jul 4, 2024

    @henryiii
    Collaborator

    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!

  6. jarrodmillman commented on Jul 5, 2024

    @jarrodmillman
    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

  7. henryiii commented on Aug 7, 2024

    @henryiii
    Collaborator

    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.

  8. henryiii commented on Jul 24, 2026

    @henryiii
    Collaborator

    It supports markdown files now, as of 0.16. (not rst, AFAICT). https://astral.sh/blog/ruff-v0.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions