[issue33219] x in IntFlag() should test int x's inclusion in IntFlag

2018-04-04 Thread Ethan Furman
Ethan Furman added the comment: Nitish, Flag can check if the current Flag class has a mixin, and if so if the object being checked for is of that same type. Dutcho, my apologies. Looks like I did not fully understand how __contains__ is supposed to work and a TypeError

[issue33219] x in IntFlag() should test int x's inclusion in IntFlag

2018-04-04 Thread Dutcho
Dutcho added the comment: @Nitish The easiest way would probably be to change __contains__ in Flag to: def __contains__(self, other): try: return other & self == other # leave selection of _value_ attribute (if other is Flag) or conversion (if other is

[issue33219] x in IntFlag() should test int x's inclusion in IntFlag

2018-04-03 Thread Nitish
Nitish added the comment: @Ethan Furman how can Flag do that? IntFlag can deal with int values too. Would it be possible to deal with int values in this case in Flag.__contains__? -- nosy: +nitishch ___ Python tracker

[issue33219] x in IntFlag() should test int x's inclusion in IntFlag

2018-04-03 Thread Ethan Furman
Ethan Furman added the comment: issue33217 will not be "fixed" with a TypeError, but incorrect Falses are also bad. Rather than add __contains__ to IntFlag (and every other Flag mixin), I think the best answer is to adjust Flag.__contains__ a little bit more to check if

[issue33219] x in IntFlag() should test int x's inclusion in IntFlag

2018-04-03 Thread Ethan Furman
Change by Ethan Furman : -- assignee: -> ethan.furman nosy: +barry, eli.bendersky, ethan.furman versions: +Python 3.8 -Python 3.6 ___ Python tracker

[issue33219] x in IntFlag() should test int x's inclusion in IntFlag

2018-04-03 Thread Dutcho
New submission from Dutcho : While `enum.IntFlag.__and__` accepts an int arg `other` and converts it to `IntFlag` before masking, `enum.IntFlag.__contains__` handles an int arg `other` no different from a different type arg `other` (i.e. returns `True` in Python 3.6 due to