{"id":2336,"library":"types-click","title":"types-click","description":"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.","status":"active","version":"7.1.8","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed/tree/main/stubs/click","tags":["typing","type-stubs","click","cli","mypy","typeshed"],"install":[{"cmd":"pip install types-click","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This package provides type stubs for the 'click' library. 'click' itself is required at runtime for the stubs to be useful for type checking your application code.","package":"click","optional":false}],"imports":[{"note":"You do not directly import from `types-click`. Instead, `types-click` provides type information for the `click` library, which type checkers will automatically pick up when you import `click`.","symbol":"click","correct":"import click"},{"note":"Symbols are imported from the runtime library `click`, not from `types-click`.","symbol":"command","correct":"from click import command, option"}],"quickstart":{"code":"import click\n\n@click.command()\n@click.option('--name', default='World', help='The name to greet.')\n@click.option('--count', default=1, type=int, help='Number of greetings.')\n@click.argument('message', default='Hello', type=str)\ndef greet(name: str, count: int, message: str):\n    \"\"\"\n    Simple program that greets NAME for COUNT times with a MESSAGE.\n    \"\"\"\n    for _ in range(count):\n        click.echo(f\"{message}, {name}!\")\n\nif __name__ == '__main__':\n    # Type checkers will use types-click for 'click' objects and functions.\n    greet() # type: ignore\n","lang":"python","description":"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."},"warnings":[{"fix":"Uninstall `types-click` (`pip uninstall types-click`) if `click` version 8.0 or higher is installed in your environment. Rely on the inline types provided by `click` itself.","message":"Click versions 8.0 and newer include inline type annotations. If you are using `click` version 8.0 or later, `types-click` is no longer necessary and should be uninstalled. Installing both can lead to type checking conflicts or incorrect type information.","severity":"breaking","affected_versions":"click >= 8.0"},{"fix":"Ensure your `types-click` version is compatible with your installed `click` version. Typeshed generally recommends using the same version bounds for the stub package as for the runtime package (e.g., `pip install 'click>=7.1.0,<8.0.0' 'types-click>=7.1.0,<8.0.0'`).","message":"The `types-click` package provides stubs for specific versions of the `click` library. While its version attempts to match the `click` version (e.g., `types-click==7.1.x` for `click==7.1.x`), discrepancies can occur. Using `types-click` with a significantly different `click` version than it was designed for can lead to inaccurate or misleading type checking results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always import symbols from the actual `click` library (e.g., `from click import command`), not from `types_click`.","message":"As a PEP 561 stub-only package, `types-click` contains no runtime code. It only provides `.pyi` files for type checkers. Attempting to import symbols directly from `types_click` at runtime will result in a `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}