types-click

7.1.8 · active · verified Thu Apr 09

types-click is a PEP 561 type stub package providing external type annotations for the popular Click library. It allows type-checking tools like MyPy, PyCharm, and Pyright to analyze code that uses Click, enabling static analysis, type inference, and autocompletion. Maintained as part of the broader typeshed project, its releases generally follow the versions of the Click library it stubs, with an additional datestamp suffix.

Warnings

Install

Imports

Quickstart

This example demonstrates a basic Click CLI application with type hints. When `types-click` is installed, a type checker like MyPy will use its stubs to validate the types in this code.

import click

@click.command()
@click.option('--name', default='World', help='The name to greet.')
@click.option('--count', default=1, type=int, help='Number of greetings.')
@click.argument('message', default='Hello', type=str)
def greet(name: str, count: int, message: str):
    """
    Simple program that greets NAME for COUNT times with a MESSAGE.
    """
    for _ in range(count):
        click.echo(f"{message}, {name}!")

if __name__ == '__main__':
    # Type checkers will use types-click for 'click' objects and functions.
    greet() # type: ignore

view raw JSON →