Skip to content

@overload correctness #1291

Answered by srittau
dvoraen asked this question in Q&A
Nov 17, 2022 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

I have no experience with Evennia, so please take that in mind in my response.

While passing something other than "c", "l", or "r" into align is possible, this would most likely be unintended, i.e. a bug, and is exactly what type checking is supposed to catch. Personally I would use the Literal. One exception would be if passing anything else (for example an empty string) is a common idiom in existing code.

I would expect the author of foo() to use the same literal type for align as you are using in pad(). You could provide a type alias like _Alignment: TypeVar = Literal["c", "l", "r"] and use that. This alias could then be used by the author of foo() (although it requires a bit of an awk…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@dvoraen
Comment options

@srittau
Comment options

@dvoraen
Comment options

@erictraut
Comment options

@dvoraen
Comment options

Answer selected by dvoraen
Comment options

You must be logged in to vote
1 reply
@dvoraen
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
4 participants