osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] GH-6392: Enum, __contains__, TypeError, and DeprecationWarnings


Oh my!  ;)

So, after the previous discussion about when __contains__ should raise TypeError instead of returning False, it seems 
there are a couple cases where a TypeError should be raised now:

1)  non-enum-instance in EnumClass
2)  anything in enum_instance
3)  non-flag-instance in flag instance

(1) can be True/False if an Enum instance is checked for;
(2) should (and does already) always raise TypeError;
(3) can be True/False when a Flag instance is checked for in another flag instance.

I suspect these are corner cases, and infrequently, if ever, being used incorrectly now, but I would rather have a 
deprecation period in 3.7 instead of just changing in 3.8 to TypeErrors.  To that end I have a PR [1] readay, and would 
appreciate any review, thoughts, and/or comments.

--
~Ethan~

[1] https://github.com/python/cpython/pull/6392