💥 Update metavar printing#1863
Draft
svlandeg wants to merge 30 commits into
Draft
Conversation
Contributor
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.
WIP: please don't review/comment yet 🙏
Description
We've decided to change a bit the "metavar" printing functionality of Typer. In short, the new rules are:
<>for displaying the type (including enum choices etc)[]for displaying something optional{}for referencing an object (i.e. not a literal string) if neither of the other 2 applyBreaking changes
<>, so"<str>"instead of"TEXT"and"<int>"instead of"INTEGER"etc.<simple|conv|lstm>instead of[simple|conv|lstm]or{simple|conv|lstm>}. Check the new testtest_param_type_help_metavarfor an overview.{}in the usage strings, unless they're already surrounded with the "optional" denoting brackets[].test_parameter_name_casing.Tangiantel fix
Default: Nonein the help text, PR 1120. I updated those as part of the documentation update here. I could also do this in a separate PR if preferred, but it would cause a lot of merge conflicts and duplicate work as I've now been going through all the docs in detail anyway.Documentation updates
When updating the documentation to show e.g.
<str>instead ofTEXT, this would be treated as an HTML tag and not actually displayed in our tutorial pages 😭 Hence the fixes tocustom.js.How to review this PR
Please mostly look at the test/documentation changes, and not so much the actual code changes in the Python files. Those will become obsolete with the Pydantic refactor that is in the works. In fact, this PR is a "spinoff" of the Pydantic refactor (#1831, WIP) in an attempt to make that one more "reviewable". The code changes here will be subsumed by that PR.
AI Disclaimer
Created through pair-programming with Cursor, manually reviewed in detail. Also went through all the Typer docs manually & in detail.
Checklist