Skip to content

how to type a function that returns new classes without writing a mypy plugin? #1020

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

You must be logged in to vote

This should arguably generate an error in pyright/pylance as well. The statement MyBase = make_a_base_class() looks similar to a type alias declaration, but it's not really a legal type alias because it uses a call expression. Therefore it should be treated as a normal variable assignment. A variable shouldn't be allowed as a base class in a class declaration.

Replies: 1 comment 13 replies

Comment options

You must be logged in to vote
13 replies
@sobolevn
Comment options

@erictraut
Comment options

@erictraut
Comment options

@zzzeek
Comment options

@erictraut
Comment options

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