pylint icon indicating copy to clipboard operation
pylint copied to clipboard

False positive E1130 invalid-unary-operand-type for Flag

Open marcinwrochna opened this issue 6 years ago • 4 comments

Pylint emits a false positive E1130 invalid-unary-operand-type error for enum.Flag:

from enum import Flag
class Perm(Flag):
    R = 4
    W = 2
    X = 1
print(~Perm(2))

Emits two errors:

$ pylint-3 -E a.py 
************* Module a
a.py:6:6: E1130: bad operand type for unary ~: Perm (invalid-unary-operand-type)
a.py:6:6: E1130: bad operand type for unary ~: NoneType (invalid-unary-operand-type)

pylint --version output

$ pylint-3 --version
pylint-3 2.1.1
astroid 2.0.4
Python 3.7.3 (default, Mar 27 2019, 13:41:07) 
[GCC 8.3.1 20190223 (Red Hat 8.3.1-2)]

marcinwrochna avatar May 01 '19 20:05 marcinwrochna

Thanks for the report!

PCManticore avatar May 05 '19 10:05 PCManticore

This no longer emits on main.

DanielNoord avatar Jun 02 '22 12:06 DanielNoord

Thanks!

marcinwrochna avatar Jun 02 '22 13:06 marcinwrochna

Never mind 😓

It does partially emit... Reopening. New incorrect output is:

❯ pylint test.py --enable=invalid-unary-operand-type
************* Module test
test.py:10:6: E1130: bad operand type for unary ~: EnumMeta (invalid-unary-operand-type)

DanielNoord avatar Jun 02 '22 13:06 DanielNoord