Skip to content

docstring code formatter: emit warning messages when code snippets fail to format #8856

Open
@BurntSushi

Description

@BurntSushi

#8811 added initial support for formatting doctest code snippets in docstrings, but it does have some silent behavior that should probably be louder. For example, if it detects a code snippet that is invalid Python, then it will silently skip the code snippet. Another example is a bit more pathological, but it is possible for the code snippet formatter to generate invalid Python in some case (as a result of nested triple quoted strings in some cases). In this case, we detect it and bail out of reformatting the code snippet. Ideally, we would emit a warning about this too, although this is arguably more of a bug in the current implementation.

This was brought up in review, and it was suggested that perhaps we split the warning/logging infrastructure out from the linter and use it in the formatter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstringRelated to docstring linting or formattingformatterRelated to the formatterwishNot on the current roadmap; maybe in the future

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions