8000 Add help string formatters that don't use escaped characters. · Issue #2882 · pallets/click · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

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

Open
Phrogz opened this issue Apr 9, 2025 · 1 comment
Open

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

Phrogz opened this issue Apr 9, 2025 · 1 comment
Labels
TBD Not enough information to proceed

Comments

@Phrogz
Copy link
Phrogz commented Apr 9, 2025

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
@Rowlando13
Copy link
Collaborator

Click is a long standing project that has been using \b and \f for a very long time. I would suggest turning off Ruff D301 or seeing if there is a VS code setting you can alter. Is there something I am missing ? @kdeldycke

@Rowlando13 Rowlando13 added the TBD Not enough information to proceed label Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TBD Not enough information to proceed
Projects
None yet
Development

No branches or pull requests

2 participants
0