Skip to content

Is there a difference between a TypeVar and Any if it is unused. #8257

Answered by erictraut
JanEricNitschke asked this question in Q&A
Discussion options

You must be logged in to vote

Definitely use Any, not a TypeVar. A TypeVar is unnecessary and confusing at best (and inappropriate and incorrect at worst). TypeVars are also way more expensive for static type checkers to handle because they must gather constraints and then apply those constraints to "solve" the type variable. With Any, there is no such work required.

Replies: 1 comment 5 replies

Comment options

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

@erictraut
Comment options

@JanEricNitschke
Comment options

@erictraut
Comment options

Answer selected by JanEricNitschke
@JanEricNitschke
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
2 participants