pallets / pallets/click

Add help string formatters that don't use escaped characters.

Open
#2,882 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help output
Dominant language
Python
Stars
17.7k
Forks
2.3k
Avg merge
1d 30m
Merged PRs (30d)
18

Description

I'd love to use the \f and \b in my docstrings to have a single source of help text. However, Ruff D301 enforces PEP 257 which requires docstrings to be raw (r"""…""") if they have any backslashes in them. Doing that breaks the VS Code syntax highlighting to no longer treat the string as a docstring.

So, I've had to move documentation out of the docstring for the function and into the help argument, repeating the docstring first line, all because I want to use \b and \f to fight Click's helpful auto-formatting. Please add an additional formatting mechanism to support these functions. If I'm going to put visual garbage in my source file to get the formatting to behave, it would be nice if it were self-documenting, e.g.

@click.option(…)
@click.option(…)
def myfunc(cats: int = 0, feet: int = 0) -> None:
    """Does good stuff.
    
    Here's more detailed information
    on how this works.
    
    <<click-preserve-whitespace>>
    Examples:
         # basic usage
         $ myfunc
    
         # overrides
         $ myfunc --cats 1 --feet 17

    <<click-end-help>>

    Args:
        cats: Number of cats to assume prowling around.
        feet: How far cats can jump during attacks.
    """
    pass

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name implementation files, tests, or an entry point. Start by locating Click's existing help formatting and docstring handling, then compare its current whitespace behavior with the proposed preserve/end markers; done means a documented formatter mechanism with coverage for the example cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.