-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationRegression
Description
Bug description
If I am trying to OR more than two flags, pylint 2.15.0 fails with "E1131: unsupported operand type(s) for | (unsupported-binary-operation)". This worked with pylint 2.14.1
class MosaicFlags(Flag):
NONE = 0
SUPPLY_MUTABLE = 1
TRANSFERABLE = 2
RESTRICTABLE = 4
REVOKABLE = 8
value = MosaicFlags.SUPPLY_MUTABLE | MosaicFlags.RESTRICTABLE | MosaicFlags.REVOKABLE
Configuration
No response
Command used
python3 -m pylint --rcfile .pylintrc --load-plugins pylint_quotes
Pylint output
************* Module tests.test_RuleBasedTransactionFactory
tests/test_RuleBasedTransactionFactory.py:148:3: E1131: unsupported operand type(s) for | (unsupported-binary-operation)
tests/test_RuleBasedTransactionFactory.py:164:10: E1131: unsupported operand type(s) for | (unsupported-binary-operation)
Expected behavior
Expected no errors
Pylint version
pylint 2.15.0
Python 3.8.10
OS / Environment
Ubuntu 20.04
Additional dependencies
isort==5.10.1
pycodestyle==2.9.1
pylint==2.15.0
pylint-quotes==0.2.3
timobrembeck, sevdog, jessebrennan, Igetin, clavedeluna and 1 more
Metadata
Metadata
Assignees
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationRegression
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
RemiCardona commentedon Aug 30, 2022
Same issue when using Django's "Q objects" https://docs.djangoproject.com/en/3.1/topics/db/queries/#complex-lookups-with-q
2 Q objects
|
-ed or&
-ed together is fine, 3 or more breaks pylint. We're getting hundreds of errors as Q objects are a fairly common sight in Django projects.mbyrnepr2 commentedon Aug 30, 2022
Thanks for the report. I can't reproduce this one myself:
Add a functional test for combinations of ``enum.Flag`` constants wit…
enum.Flag
members #7385Wayonb commentedon Aug 30, 2022
Hi @mbyrnepr2, Thanks for taking a look. Sorry, I didnt actually try the sample code.
I was able to repo with the sample below.
pylint example.py --load-plugins pylint_quotes
SamyCookie commentedon Aug 30, 2022
if you want a shorter example without enum dependency you can reproduce this false positive bug with this:
mbyrnepr2 commentedon Aug 30, 2022
Thanks for the examples.
@Wayonb you're right - something between 2.14.1 & 2.15.0 has led to this false positive. Note it happens only for Python versions below 3.10 because of this logic: https://github.com/PyCQA/pylint/blob/main/pylint/checkers/typecheck.py#L1879-L1880
RemiCardona commentedon Sep 8, 2022
Is there any chance for part or all of the new type checker code to be reverted until the issue is fixed?
Thanks
23 remaining items