CodeMD repository analysis · example report
An analysis of github.com/pallets/click as it was on 2026-11-13.
What the repository is and how it is built, written by AI from the analysis.
Click is a Python package for creating beautiful command line interfaces in a composable way, with as little code as necessary. Known as the "Command Line Interface Creation Kit", it is highly configurable but ships with sensible defaults out of the box. It aims to make writing command line tools quick and fun, while preventing the frustration of being unable to implement an intended CLI API. Click is developed and supported by the Pallets organization.
CliRunner invokes commands in isolation, including an isolated filesystem.The repository includes examples that show common patterns:
repo).aliases).complex).imagepipe; requires pillow).inout).colors, termui).completion).validation).naval example, to Click with POSIX-style semantics (naval).The examples are not runnable by themselves. Install each one into a virtualenv, for example with pip install --editable ..
Click is a library, not an application, and has no user interface of its own. The repository contains the click package, documentation in docs/, runnable examples/, and a CHANGES.md changelog.
Its design centers on commands and groups. A command carries its parameters (options and arguments), which are parsed, converted by type and validated before the command's callback runs. Groups hold subcommands and can nest, so complex tools form a tree of commands. The tree can be extended with custom group behavior for aliases or with plugin-style dynamic loading.
A context object carries state through an invocation and handles exit codes. Separate modules provide help formatting, shell completion, terminal UI utilities and the testing runner. Click is distributed under the BSD-3-Clause license.
12 features found in the code and documentation.
Lets you build command line tools in a composable way with as little code as necessary and sensible defaults out of the box.
Lets you nest commands and groups to any depth to structure complex CLIs.
Generates help pages for commands, options and arguments automatically, so users get usage documentation without extra work.
Loads subcommands at runtime only when needed, including dynamically from a plugin folder.
Supports aliases read from a config file and automatic abbreviations of command names by customizing how commands are located.
Provides tab completion for Bash, Zsh and Fish (and PowerShell as of 8.5.0) so users can complete commands and options in their shell.
Offers colorized text, pagers, progress bars, single-character input and confirmation prompts for interactive terminal programs.
Parses options and arguments with type handling and supports custom validation of parameters.
Makes it easy to read from and write to files while also accepting stdin and writing to stdout.
Provides a CliRunner to invoke commands in isolation, including an isolated filesystem, for testing CLIs.
Manages process exit codes through the context and command main entry point.
Allows commands to be chained together in a pipeline, as in the image-processing example where steps run in sequence.
Possible problems found without running the code.
| Kind | Signal | Where | Severity |
|---|---|---|---|
| Possible bugs | Exception silently swallowed An except block catches an exception and does nothing with it. | src/click/_compat.py:77 | high |
| Possible bugs | Exception silently swallowed An except block catches an exception and does nothing with it. | src/click/_compat.py:170 | high |
| Possible bugs | Exception silently swallowed An except block catches an exception and does nothing with it. | src/click/_compat.py:568 | high |
| Possible bugs | Exception silently swallowed An except block catches an exception and does nothing with it. | src/click/_winconsole.py:204 | high |
| Possible bugs | Exception silently swallowed An except block catches an exception and does nothing with it. | src/click/testing.py:600 | high |
| Possible bugs | Exception silently swallowed An except block catches an exception and does nothing with it. | src/click/testing.py:610 | high |
| Possible bugs | Exception silently swallowed An except block catches an exception and does nothing with it. | src/click/utils.py:41 | high |
| Possible bugs | Broad except with no logging or re-raise A bare `except:` or `except Exception:` handler neither logs nor re-raises the error. | examples/imagepipe/imagepipe.py:97 | high |
| Structure | Duplicate function name in file `_get_argv_encoding` is defined 2 times in the same scope. | src/click/_compat.py:520 | high |
| Structure | Duplicate function name in file `edit` is defined 3 times in the same scope. | src/click/_termui_impl.py:742 | high |
| Structure | Duplicate function name in file `raw_terminal` is defined 2 times in the same scope. | src/click/_termui_impl.py:882 | high |
| Structure | Duplicate function name in file `getchar` is defined 2 times in the same scope. | src/click/_termui_impl.py:885 | high |
| Structure | Duplicate function name in file `lookup_default` is defined 3 times in the same scope. | src/click/core.py:803 | high |
| Structure | Duplicate function name in file `invoke` is defined 3 times in the same scope. | src/click/core.py:877 | high |
| Structure | Duplicate function name in file `main` is defined 3 times in the same scope. | src/click/core.py:1487 | high |
| Structure | Call exits before following statements `sys.exit` always terminates execution, so following statements in this block are unreachable. | src/click/core.py:1672 | high |
| Call graph | Circular call relationship 4 functions participate in a static call cycle. | click/_compat.py:80 | medium |
| Call graph | Circular call relationship 2 functions participate in a static call cycle. | click/core.py:581 | medium |
| Call graph | Circular call relationship 2 functions participate in a static call cycle. | click/core.py:1844 | medium |
| Call graph | Circular call relationship 2 functions participate in a static call cycle. | click/core.py:1893 | medium |
| Call graph | Circular call relationship 4 functions participate in a static call cycle. | click/core.py:3017 | medium |
| Call graph | Circular call relationship 2 functions participate in a static call cycle. | click/types.py:1243 | medium |
| Call graph | Circular call relationship 2 functions participate in a static call cycle. | click/types.py:1246 | medium |
| Across files | Missing internal call target `click._compat._make_text_stream` calls `click._compat._NonClosingTextIOWrapper`, but the target was not found in the parsed function index. | click/_compat.py:22 | high |
| Across files | Missing internal call target `click._compat._NonClosingTextIOWrapper.__init__` calls `click._compat._FixupStream`, but the target was not found in the parsed function index. | click/_compat.py:60 | high |
| Across files | Missing internal call target `click._termui_impl._resolve_pager_command` calls `click.types.Path`, but the target was not found in the parsed function index. | click/_termui_impl.py:423 | high |
| Across files | Missing internal call target `click._termui_impl.get_pager_file` calls `click._termui_impl._PagerWriter`, but the target was not found in the parsed function index. | click/_termui_impl.py:495 | high |
| Across files | Missing internal call target `click._termui_impl.Editor.edit_files` calls `click.exceptions.ClickException`, but the target was not found in the parsed function index. | click/_termui_impl.py:711 | high |
| Across files | Missing internal call target `click._winconsole.get_buffer` calls `click._winconsole.Py_buffer`, but the target was not found in the parsed function index. | click/_winconsole.py:101 | high |
| Across files | Missing internal call target `click._winconsole._get_text_stdin` calls `click._compat._NonClosingTextIOWrapper`, but the target was not found in the parsed function index. | click/_winconsole.py:222 | high |
| Across files | Missing internal call target `click._winconsole._get_text_stdin` calls `click._winconsole.ConsoleStream`, but the target was not found in the parsed function index. | click/_winconsole.py:222 | high |
A sample of the highest-ranked signals. These come from static analysis: they are leads to review, not confirmed bugs.
Functions nothing in the repository calls.
10 functions have no caller in the call graph. They may be public API, called dynamically, or dead code.
| Function | Location | Lines |
|---|---|---|
click._compat._FixupStream.read1 | click/_compat.py:108 | 7 |
click._compat._FixupStream.readable | click/_compat.py:116 | 11 |
click._compat._FixupStream.seekable | click/_compat.py:143 | 9 |
click._winconsole._WindowsConsoleReader.readable | click/_winconsole.py:124 | 2 |
click._winconsole._WindowsConsoleWriter.writable | click/_winconsole.py:159 | 2 |
click.core.Context.get_help | click/core.py:862 | 5 |
click.core.Context.get_usage | click/core.py:856 | 5 |
click.types.FloatRange._clamp | click/types.py:780 | 8 |
click.types.IntRange._clamp | click/types.py:732 | 5 |
click.types.Tuple.arity | click/types.py:1257 | 2 |
What changed in the last 30 days, in plain language.
Product / behavior change (the only runtime code change in the evidence)
src/click/core.py, Command.get_short_help_str and Command.format_help_text previously wrapped the command's own help text in gettext (_(text)) when the command was deprecated. Now only the (DEPRECATED…) label is translated. A command's help text is application data, and non-deprecated commands never translated it, so this makes deprecated commands consistent with the rest of Click, including options and arguments. It is recorded in CHANGES.md under Unreleased. A new test, test_deprecated_help_text_is_not_translated in tests/test_commands.py, monkeypatches click.core._ to upper-case its input and checks that both the long help and the group's command listing show sub help (DEPRECATED: REASON). The callgraph tool rated this "High impact" (score 91). The changed functions have 2 callers, all in one file. The risk label is Low.Documentation
less and Ctrl+C (5c1963a, merged as 5e7cf6b / #3900). docs/faqs.md gains a section, "Ctrl+C in the pager stops the program". When less is following a stream with F, Ctrl+C leaves follow mode, but it also sends SIGINT to the command and stops it. The documented way to leave less without killing the program is Ctrl+X then q. The docs only; no code changed.Tests
click.unstyle() (685dadf, merged as 6d34602 / #3899). tests/test_utils/test_style.py was restructured so test_styling is parametrized over both the text and the style codes. The text cases now include the empty string, text that looks like the tail of an ANSI code ("38;5;91m", "[1mx y"), non-ASCII text with an emoji, and text containing a newline. Every case asserts click.style(...) equals codes + text + reset and that click.unstyle(...) returns the original text. The tests also add an "every option at once" case and test_unstyle_exception_message, which covers issue #2419 (a styled ClickException message reads back as plain text). No library code changed; the commit adds 107 lines and removes 67.Patterns
Caveat: The payload was truncated after the third visible file of the fifth commit, and it lists 31 commits but details only the first few. The other ~26 commits are not covered by this summary.
An example question, answered from the code.
What does this project do and how is it organised?
The user asked what this project does and how it is organised.
docs/conf.py:44 links to https://pypi.org/project/click/, and the code lives in a click/ package. [SEMANTIC/derived] Stored summaries describe it as pallets/click, a library for building command-line interfaces. No README is in the evidence, so that purpose statement isn't confirmed from source.--version and --help options (click/decorators.py)click/exceptions.py)echo output helper (click/utils.py)click/ source package, with docs/, examples/ (for example examples.imagepipe), tests/, pyproject.toml and .pre-commit-config.yaml alongside it.click/click/core.py, decorators.py, utils.py, exceptions.py, _compat.py, _termui_impl.py, termui.py, types.py, parser.py, shell_completion.py, globals.py, _winconsole.py and testing. Only some of these have code in the snippets; I can't describe the rest beyond their names and edges.click.core has Context, Parameter, Option, Command.main, Command.invoke and Group.Parameter.type_cast_value and Parameter.value_is_missing are in core.py; they appear only as semantic matches.Option.value_from_envvar and Option.add_to_parser are also in core.py. The graph links add_to_parser to click.parser._OptionParser.add_option, which suggests options are registered with a parser in click/parser.py. This rests on callgraph edges alone, and add_to_parser is a [SEMANTIC] candidate.click/decorators.py has pass_meta_key, version_option, custom_version_option and help_option.version_option (lines 417-552) adds a --version option that prints the version and exits. If no version is given, it tries to detect one with importlib.metadata.version, per its docstring.custom_version_option (lines 555-594, added in 8.5.0 per its docstring) takes a callback(ctx) that builds the string to print.help_option (lines 597-621) defaults to --help.pass_meta_key (lines 96-126) passes a Context.meta key as the first argument to the decorated function.click/utils.py has echo (lines 236-330). Its docstring says it should be used instead of print. It supports Unicode on the Windows console, supports binary outputs, removes ANSI codes when the output isn't an interactive terminal, and always flushes. [GRAPH] It is called from many modules, including core, termui, exceptions, shell_completion and _termui_impl.click/exceptions.py defines ClickException.show, UsageError.show and NoArgsIsHelpError.show. Each calls echo.custom_version_option.show_version (click/decorators.py:579-584)value is falsy or ctx.resilient_parsing is set, it returns without doing anything.echo(callback(ctx), color=ctx.color) and then ctx.exit().custom_version_option. Its callees are click.utils.echo, Context.exit, Context, Parameter and click.decorators.version_option.callback. The snippet shows the call going to the callback argument of custom_version_option, so I can't reconcile it with the graph's version_option.callback edge.help_option.show_help (lines 606-610) has the same shape. It calls echo(ctx.get_help(), color=ctx.color) and then ctx.exit().docs/ holds Markdown pages (entry-points.md, contrib.md, faqs.md, testing.md) and conf.py. The conf.py project links point to palletsprojects.com and PyPI. entry-points.md discusses a pyproject.toml that describes a project..pre-commit-config.yaml references the codespell repo.tests/ directory has tests.test_basic and tests.test_options. tests.test_basic calls custom_version_option.examples/ directory has examples.imagepipe.imagepipe.display_cmd, which calls ClickException.show.An AI review of how outside input reaches risky operations.
No exploitable findings.
This is the Click library, which Python CLI applications use to parse command lines. It has no network service and no authentication. It handles no repository content, LLM output or plugins of its own, and every input it reads comes from the local user who launched the program. I read the source to check each process-execution sink, and none of them has a path from untrusted input to code execution. (1) The pagers _pipepager and _tempfilepager in src/click/_termui_impl.py run the program named in the PAGER environment variable. They pass subprocess.Popen or subprocess.call an argv list with shell=False, so the paged text is never interpreted by a shell. PAGER is set by the user running the program, who could already run any command. (2) Editor.edit_files runs shlex.split(editor) from VISUAL or EDITOR, or from an editor name the application developer passes in, plus temp file names. It also uses an argv list with no shell, so the same trust argument applies. (3) open_url runs xdg-open, open, explorer or cygstart with an argv list, or calls os.startfile. The URL comes from the application that calls click.launch, not from Click, so passing untrusted URLs to it is the application's own design choice. (4) BashComplete._check_version runs a fixed bash command line. (5) The writes in _AtomicFile.close and types.File go to file paths that the CLI's own user typed as arguments, which is the intended behaviour. Shell completion reads environment variables (COMP_WORDS and similar) that the user's own shell sets. No path crosses a trust boundary, so none meets the catastrophic threshold.