Skip to content

✨ Add plugin system via fastapi_cli.plugins entry point group - #421

Open
craforge wants to merge 8 commits into
fastapi:mainfrom
craforge:feat/plugin-entry-points
Open

✨ Add plugin system via fastapi_cli.plugins entry point group#421
craforge wants to merge 8 commits into
fastapi:mainfrom
craforge:feat/plugin-entry-points

Conversation

@craforge

@craforge craforge commented Jun 3, 2026

Copy link
Copy Markdown

✨ Add plugin system via fastapi_cli.plugins entry point group

Description

_load_cli_plugins() discovers third-party CLI commands registered under the
fastapi_cli.plugins entry point group and loads them at startup.

  • Discovery via importlib.metadata.entry_points
  • Wired into main() so it actually runs (revolutionary, I know 🚀)
  • Broken plugins log a warning and are skipped — no CLI crash
  • Name collisions (plugin vs built-in, plugin vs plugin) emit a single
    logger.warning per offending plugin

Third-party packages commands declaration:

[project.entry-points."fastapi_cli.plugins"]
my-plugin = "my_package.cli:register"

Files

Modified

  • src/fastapi_cli/cli.py — _load_cli_plugins, _cmd_name helper, hook into main()

Added

  • tests/test_cli_plugin.py — 4 tests: happy path, broken plugin, built-in collision, cross-plugin collision
  • tests/assets/plugins/sample.py — well-behaved plugin (registers ping)
  • tests/assets/plugins/broken.py — raises on register (the chaos plugin)
  • tests/assets/plugins/colliding.py — tries to clobber the built-in dev command

AI Disclaimer

AI (Deepseek Pro) was used to generate the initial pull request message and code review.

Checklist

  • This PR is an obvious typo fix, or it links to a GitHub Discussion for the proposed code change.
  • I added tests for the change.
  • The new or updated tests fail on the main branch and pass on this PR.
  • Coverage stays at 100%.
  • The documentation explains the change if needed.

@svlandeg svlandeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please declare any AI usage - the "AI Disclaimer" part from the PR template has been removed?

@craforge
craforge force-pushed the feat/plugin-entry-points branch from ee3de78 to 8a6a6d0 Compare June 6, 2026 00:20
@craforge

craforge commented Jun 6, 2026

Copy link
Copy Markdown
Author

Hi maintainers 👋 — the check-labels workflow is failing because the PR has no label. Could one of you add feature + refactor so CI can proceed? Thanks

@svlandeg svlandeg added the feature New feature or request label Jun 8, 2026
@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Jun 18, 2026
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Jun 18, 2026
@github-actions github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This pull request has a merge conflict that needs to be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automatically generated when a PR has a merge conflict feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants