Skip to content

mypy and nested generics with type variables #1114

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

You must be logged in to vote

The problem is that EmptySet derives from collections.abc.Set[T] rather than typing.Set[T] or set[T]. The typeshed stubs define collections.abc.Set differently from the builtins set. This is probably a bug in the stubs. I think these should be the same.

I'll also note that the __and__ method in the base class ItemsView has an other parameter that can be specified as a keyword, so pyright flags your use of a position-only parameter separator (/) as invalid when overriding this method. I don't think mypy performs this check.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@AlexWaygood
Comment options

@JelleZijlstra
Comment options

@SimpleArt
Comment options

Answer selected by SimpleArt
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