{{ message }}
Repository navigation
Load addons from Python entry points (mitmproxy.addons) (#7755) - #8480
Open
johnnylemonny wants to merge 1 commit into
Open
johnnylemonny wants to merge 1 commit into
johnnylemonny wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes: #7755
Description
Currently, third-party addons must be passed via CLI flags (
-s /path/to/addon.py), loaded via configuration, or imported in custom wrapper scripts.This PR introduces automatic discovery and loading of addons registered under the entry point group
mitmproxy.addons.This enables packaging third-party addons into standalone Python packages (e.g. on PyPI) that are automatically activated when installed into the same environment or virtualenv as mitmproxy.
Key changes:
mitmproxy.addons.entrypoint_addons):importlib.metadata.entry_points(group="mitmproxy.addons").addon.nameif the loaded addon does not already specify one.logger.errorif a broken or incompatible third-party addon fails to import or instantiate, ensuring mitmproxy starts reliably regardless of third-party issues.default_addons():test/mitmproxy/addons/test_entrypoints.pycovering all discovery patterns, error resilience, and integration withdefault_addons().uv run tox -e individual_coverage.CHANGELOG.mdunder## Unreleased: mitmproxy next.How to use
In
pyproject.tomlof an addon package:Once installed into the environment (
pip install my_package/uv pip install my_package), mitmproxy will automatically discover and loadmy_addon.Checklist
mitmproxy.addons.uv run pytest test/mitmproxy/addons/test_entrypoints.py).uv run tox -e individual_coverage -- test/mitmproxy/addons/test_entrypoints.py).uv run ruff check .anduv run ruff format --check .).uv run mypy).CHANGELOG.mdupdated.