Skip to content

Switch from docopt to typer#175

Closed
jsf9k wants to merge 6 commits intodevelopfrom
improvement/switch-from-docopt-to-typer
Closed

Switch from docopt to typer#175
jsf9k wants to merge 6 commits intodevelopfrom
improvement/switch-from-docopt-to-typer

Conversation

@jsf9k
Copy link
Copy Markdown
Member

@jsf9k jsf9k commented Jan 7, 2026

🗣 Description

This pull request switches from docopt to typer for our CLI argument-parsing needs.

💭 Motivation and context

I noticed that installing docopt generates warnings because it still uses a setup.py file versus a pyproject.toml file. Investigating further, I found that docopt hasn't seen any updates since 2014. I figured now would be a good time to start looking at alternatives.

The main two alternatives right now are click and typer. The former is a bit more verbose, whereas the latter is a bit more opinionated but also more Pythonic. typer uses click under the hood and leverages type hints to do some work for you. Both automatically generate tab completion for various shells.

See #176 for the click implementation. We can choose which one we like better.

🧪 Testing

All automated tests pass.

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • Tests have been added and/or modified to cover the changes in this PR.
  • All new and existing tests pass.
  • Bump major, minor, patch, pre-release, and/or build versions as appropriate via the bump_version script if this repository is versioned and the changes in this PR warrant a version bump.
  • Create a pre-release (necessary if and only if the pre-release version was bumped).

✅ Pre-merge checklist

  • Finalize version.

✅ Post-merge checklist

  • Create a release (necessary if and only if the version was bumped).

jsf9k added 3 commits January 6, 2026 17:37
docopt hasn't been updated in years and is still built using setup.py.
typer is a more modern CLI library that gives shell completion for
free.

For more information see:
- https://typer.tiangolo.com/
- https://github.com/fastapi/typer
@jsf9k jsf9k self-assigned this Jan 7, 2026
@jsf9k jsf9k moved this to In Progress in Next Kraken Jan 7, 2026
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file python Pull requests that update Python code test This issue or pull request adds or otherwise modifies test code labels Jan 7, 2026
The logging.getLevelNamesMapping() method was only introduced in
Python 3.11.
@jsf9k jsf9k added the kraken 🐙 This pull request is ready to merge during the next Lineage Kraken release label Jan 7, 2026
This is no longer needed since we're now using typer for our CLI
argument-parsing needs.
@jsf9k jsf9k mentioned this pull request Jan 7, 2026
11 tasks
@jsf9k
Copy link
Copy Markdown
Member Author

jsf9k commented Jan 7, 2026

Copy link
Copy Markdown
Member

@dav3r dav3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both typer and click seem fine for our needs. I asked Google about it and here's what it came back with:

Pick Typer if: You want a modern developer experience with excellent autocompletion and less boilerplate. It is ideal if you are already using FastAPI, as it shares the same design philosophy.

Pick Click if: You need a proven, stable tool with maximum control and minimal dependencies. It is often preferred for very large, complex CLI structures where explicit control over every parameter is necessary.

Hybrid Approach: Because Typer is built on Click, you can use Typer for your main interface but drop down into Click for advanced features that Typer might not yet support.

That being said, I have no major preference here and will gladly go with whichever one our team feels more strongly about.

Additional info from Google:
Image

Comment thread src/example/example.py
Co-authored-by: dav3r <david.redmin@gwe.cisa.dhs.gov>
Copy link
Copy Markdown
Contributor

@felddy felddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for writing up both of these implementations. The side-by-side is useful.

That said, I prefer the click implementation over this one. I appreciate the more explicit syntax.

@github-project-automation github-project-automation Bot moved this from In progress to Reviewer approved in Skeleton Maintenance Jan 8, 2026
@jsf9k
Copy link
Copy Markdown
Member Author

jsf9k commented Mar 2, 2026

We have decided to go with #176.

@jsf9k jsf9k closed this Mar 2, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Next Kraken Mar 2, 2026
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in Skeleton Maintenance Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file kraken 🐙 This pull request is ready to merge during the next Lineage Kraken release python Pull requests that update Python code test This issue or pull request adds or otherwise modifies test code

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants