Skip to content

Type-Checkers fail for overloads based on Literal attribute. #1515

Answered by Daverball
randolf-scholz asked this question in Q&A
Discussion options

You must be logged in to vote

The iter list thing looks like a bug to me as well, as for the unknown case, it looks like the behavior with using S | B | W | M instead of Any as Mode for the unknown case helps and will return the correct overload for __iter__. I think that's a better representation of the unknown mode anyways, and still allows you to return Iterator[Any].

Note that this will require either adding S | B | W | M to the list of constraints on the TypeVar or setting its bound to that.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Daverball
Comment options

@Daverball
Comment options

@randolf-scholz
Comment options

@Daverball
Comment options

@erictraut
Comment options

Answer selected by randolf-scholz
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