Skip to content

Increase coverage#1690

Draft
svlandeg wants to merge 32 commits intofastapi:drop-clickfrom
svlandeg:feat/vendor_part4
Draft

Increase coverage#1690
svlandeg wants to merge 32 commits intofastapi:drop-clickfrom
svlandeg:feat/vendor_part4

Conversation

@svlandeg
Copy link
Copy Markdown
Member

@svlandeg svlandeg commented Apr 13, 2026

Continue work from #1525, #1601 and #1680, vendoring Click.

This PR does a few things at once:

  • Removing stuff we don't need in Typer
  • Writing unit tests for things we do need/document but aren't thoroughly tested in Typer's test suite
  • Adjusting the vendored code to adhere to Typer's code style
  • Adding colorama as dependency for Windows. It's in fact already pulled in by pytest anyway, but I figured explicit is better.

It's big to review, but all edits should be relatively trivial. The diff can be reviewed as one (instead of per-commit), as almost all edits should be pretty local and no code has been moved around.

Removed stuff

Sebastián: if there's anything in the list below that we do want to keep as functionality, let me know, then I'll write additional unit tests instead of removing the relevant code.

  • Remove unused code paths with UNSET (originally introduced in this PR). Typer has its own Default(...) to cover these use-cases.
  • Remove unused functionality: FLAG_NEEDS_VALUE, __debug__ statements, batch(), protected_args, Parameter.deprecated
  • Make _click.Command, _click.Parameter and _click.ShellComplete abstract
  • Adapt original Click code to use Typer's code style: remove Sphinx-specific docs styling, remove from __future__ import annotations, import directly from typing and collections, remove usage of gettext, use f-strings

This was all done 100% manually.

Added tests

Added coverage for:

  • _click.types.py & typer._types.py:
    • repr functions mostly added to existing type tutorial tests
    • convert functions into cf tests/test_type_conversion.py
    • shell_completion functionality into test_completion dir
    • other bits into ‎tests/test_types.py, ‎tests/test_types_files.py

This was done with AI assistance, micromanaged & thoroughly reviewed by me.

Coverage stats

This branch, before this PR:

13538 statements, 1037 missing (92.3% coverage)

This branch, after "cleaning" the original Click files:

13195 statements, 860 missing (93.5% coverage)

@svlandeg svlandeg self-assigned this Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

📝 Docs preview

Last commit 4c894e5 at: https://6671d306.typertiangolo.pages.dev

@svlandeg svlandeg changed the title WIP: cleanup after vendoring Increase coverage Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants