Skip to content
Discussion options

You must be logged in to vote

Yea i'm not sure what purpose default=2 has in your original example, particularly if you're looking for None. Why would you not be setting the default to None versus 2 here?

On "Optional" types we do infer None as a default (by default) if you have no explicit default provided, but any provided default is meant to imply that the user doesn't want that behavior and chooses their own.

For num2: Annotated[int | None, cappa.Arg(default=2, required=False)] = None defaulting to None, this seems more like a bug. i'd consider any explicit values provided to cappa machinery (e.g. Arg) to have higher precedence than more generic sources of information like the dataclass-level default/default_facto…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@pawamoy
Comment options

@DanCardin
Comment options

Answer selected by wu-clan
@wu-clan
Comment options

@DanCardin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants