✨ 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 intofastapi:masterfrom
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. |
See discussion for further details and sample code.