Skip to content

Allowable subclasses for a function that accepts base class with a custom metaclass #9082

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

You must be logged in to vote

The annotation you're using for the some_cls parameter indicates that the corresponding argument value must be an instance of MyBaseCls. I think what you intend here is that the value must be a class object that is a subclass of MyBaseCls. If my assumption is correct, then you should change the annotation to type[MyBaseCls]. This eliminates the error.

Alternatively, if you want to accept any instance of the MyMeta metaclass, you could change the parameter's annotation to MyMeta.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BaconPancakes
Comment options

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