Author ethan.furman
Recipients Dutcho, barry, eli.bendersky, ethan.furman
Date 2018-04-04.23:08:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522883283.31.0.682650639539.issue33217@psf.upfronthosting.co.za>
In-reply-to
Content
Stepping back slightly, it is more general to say that str, and in certain other cases dict and set (and possibly others) will raise instead of return False when it is impossible for the target type to ever hold the checked-for type.  A couple examples of what will raise:

    1 in 'hello'       # integers will never be in a string
    list() in dict()   # dict keys must be hashable (and lists are not)

So, yes, at least for pure Enums and Flags, raising TypeError when a non-Enum/Flag is checked for would be appropriate.

Since there may be code currently relying on always getting True/False, though, a deprecation period is called for.  I'll see if I can get that into 3.7.
History
Date User Action Args
2018-04-04 23:08:03ethan.furmansetrecipients: + ethan.furman, barry, eli.bendersky, Dutcho
2018-04-04 23:08:03ethan.furmansetmessageid: <1522883283.31.0.682650639539.issue33217@psf.upfronthosting.co.za>
2018-04-04 23:08:03ethan.furmanlinkissue33217 messages
2018-04-04 23:08:03ethan.furmancreate