Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

DAR101 and typer don't play nice together. #204

Open
scottbolte opened this issue Aug 17, 2022 · 0 comments
Open

DAR101 and typer don't play nice together. #204

scottbolte opened this issue Aug 17, 2022 · 0 comments

Comments

@scottbolte
Copy link

Both Typer, a python CLI framework, and the older click framework on which it is based, will automatically extract user documentation from function docstrings. Separate from that, typer will extract command line option documentation from a function's parameter set. (See line 6 in Sample Code below.) Together, the two sets of information will be used to craft well-formatted documentation for end users. (See lines 4 and 7 in Sample Typer Help below.)

Since the function's API information is not appropriate for someone using the CLI, I want to omit it from the docstring. However, darglint complains with a DAR101 if the Parameters section is missing.

darglint ~/answer.py
/Users/scott.bolte/answer.py:main:6: DAR101: - who

The only way I can suppress the warning is to include the # noqa: DAR101 inside the docstring. When I do that, the noqa text is inappropriately included in the user documentation. It appears that the noqa used to work if it came after the docstring, but as of darglint version 1.8.1, that no longer works.

Is there a way to suppress the warning without including the noqa statement inside the docstring? If not, can the previous behavior of """User documentation""" # noqa: DAR101 (line 7 in the sample source) be restored?

Sample Code

     1	"""Demonstrate typer CLI construction."""
     2
     3	import typer
     4
     5
     6	def main(who: str = typer.Argument("World", help="Who to say hello to.")):
     7	    """The top-level entry point for a demonstration app."""  # noqa: DAR101
     8	    print(f"Hello {who}.")
     9
    10
    11	if __name__ == "__main__":
    12	    typer.run(main)

Sample Typer Help

python ~/answer.py --help

     1
     2	 Usage: answer.py [OPTIONS] [WHO]
     3
     4	 The top-level entry point for a demonstration app.
     5
     6	╭─ Arguments ────────────────────────────────────────────────────────────────────────╮
     7	│   who      [WHO]  Who to say hello to. [default: World]                            │
     8	╰────────────────────────────────────────────────────────────────────────────────────╯
     9	╭─ Options ──────────────────────────────────────────────────────────────────────────╮
    10	│ --install-completion          Install completion for the current shell.            │
    11	│ --show-completion             Show completion for the current shell, to copy it or │
    12	│                               customize the installation.                          │
    13	│ --help                        Show this message and exit.                          │
    14	╰────────────────────────────────────────────────────────────────────────────────────╯
    15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant