✨ Add module:function syntax support for typer CLI #1275
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.
Adds support for specifying functions directly using colon syntax in the typer CLI, as used in pyproject console scripts entrypoint syntax, and projects like uvicorn/gunicorn.
Described in discussion #1274
Before:
After:
The change is pretty minimal - 4 lines added to
maybe_update_state()to parse the colon syntax and set the function parameter on the click Context params dict which is then picked up in the existing part of the function afterwards.Changes:
"module:function"and"/path/to/file.py:function"syntax intyper.cli:maybe_update_state