-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Literal #69
Comments
Everything works fine, only issue is with prettifying type at |
I believe the fundamental solution to this is to delegate this to Pydantic and call https://github.com/pydantic/pydantic/blob/main/pydantic/_internal/_repr.py#L82 There's a few notes:
For example: from pydantic import PositiveInt, Field
from enum import Enum, auto
from pydantic_cli import run_and_exit, Cmd
from typing import Literal, Final
class State(Enum):
a = auto()
b = auto()
class Options(Cmd):
input_file: Literal[1, 2]
alpha: Final[int]
beta: PositiveInt
state: State = Field(..., description="The State of the Job to filter on.")
name: None | str
def run(self) -> None:
print(f"Mock example running with {self}")
if __name__ == "__main__":
run_and_exit(Options, description=__doc__, version="0.1.0") With
|
@pavan-uppari Thank you for your time and feedback. |
Currently when used a field with type
Literal
, it is failing with below tracebackLiteral are like Enums only, when Enums are been supported, Literal can be supported too
The text was updated successfully, but these errors were encountered: