✨ Add support for typing.TypeAliasType as valid parameter type.#970
✨ Add support for typing.TypeAliasType as valid parameter type.#970zarch wants to merge 4 commits into
typing.TypeAliasType as valid parameter type.#970Conversation
…>=4.6.0' to support 'TypeAliasType'
|
📝 Docs preview for commit e13d1d8 at: https://45f079b8.typertiangolo.pages.dev |
typing.TypeAliasType as valid parameter type.typing.TypeAliasType as valid parameter type.
…one argument containing the same TypeVar
|
📝 Docs preview for commit c97aff6 at: https://8682c9ff.typertiangolo.pages.dev |
|
@svlandeg I've fixed all the CI. To properly handle the TypeAliasType I also have to update mypy version to The only failing check is the one using Python 3.7 (not supported), se my other PR to bump the minimum requirement to Python 3.8. |
|
Hello, I was digging on the topic on that matter and I think this PR is incomplete:
type Name = Annotated[str, Argument(help="The human in front of the screen")]
@app.command()
def greet(name: Name):
echo(f"Hello {name}")
@app.command()
def farewell(name: Name):
echo(f"Good bye, {name}")To get it working, I had to modify
from typing import Doc
from pydantic import PositiveInt, validate_call
type Name = Annotated[str, Doc("An human's full name")]
type Age = Annotated[PositiveInt, Doc("An human's age")]
type Identity = tuple[Name, Age]
@app.command()
@validate_call
def register_to_vote(user_identity: Identity):
...Happy to discuss/help on this topic |
|
Hi @lachaib, Share the branch/commit - Do you have a specific branch or commit with these changes that can be pushed to this branch? This will help ensure we can properly review and integrate your changes. |
Hello @zarch , This is not a ready-to-merge contribution but I pushed my state so that you can get inspiration and consolidate this existing pull request. https://github.com/lachaib/typer/tree/pep695 Thanks a lot |
This comment was marked as outdated.
This comment was marked as outdated.
📝 Docs previewLast commit 110972a at: https://3a314827.typertiangolo.pages.dev |
|
This pull request has a merge conflict that needs to be resolved. |
|
Thanks for the interest and work on this! ☕ I want to implement a few big refactors and features that might solve many of these use cases. I also need to do that before expanding the surface of what is supported with additional external PRs, because that also means I would have to keep maintaining and handling backwards compatibility for those new changes while doing those big refactors. I have not wanted to close PRs that target the same or similar problems before I have an alternative, but then I have left many PRs open for too long, which is not useful or clear either. Sorry for that. And then, after I make those big refactors, the problem might be solved... and if not, a bunch of conflicts will show up, so it will be better and easier to start from scratch (from the new code state). So, I'll close this one for now to keep things clean. For the specific use case, the best would be to document it in a new GitHub Discussion (or 👍 any existing one) with the specific problem to solve (without details of the implementation) to track the feature request. Thank you! 🍰 |
See discussion for further details and sample code.