-
-
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 implementationNeeds astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)
Description
Bug description
This is a follow-up to #8698, so I am using pylint
from master, see version info below. Similar to #1377, pylint
warns about inconsistent MRO with PySide6
objects although the code works fine. The error message is correct for other classes such as Path
, see second part of the example.
"""False-positive 'inconsistent MRO'."""
from pathlib import Path
from typing import Protocol
from PySide6.QtWidgets import QApplication, QMainWindow
class Appear(Protocol):
def appear(self) -> None:
...
# Here, we get a false-positive "inconsistent MRO" in `pylint` ...
class WindowMeta(type(QMainWindow), type(Appear)):
pass
class MyWindow(QMainWindow, Appear, metaclass=WindowMeta):
def appear(self) -> None:
self.show()
# ... as evidenced by this code working fine in `python`:
application = QApplication()
my_window = MyWindow()
my_window.appear()
application.exec()
# By contrast, this "inconsistent MRO" error in `pylint` ...
class PathMeta(type(Path), type(Appear)):
pass
class MyPath(Path, Appear, metaclass=PathMeta):
def appear(self) -> None:
print(self)
# ... matches the (failing) behavior in `python`:
my_path = MyPath()
my_path.appear()
Configuration
[tool.pylint]
enable = ["useless-suppression"]
disable = [
"missing-class-docstring",
"missing-function-docstring",
"too-many-lines",
"design",
]
Command used
pylint bug.py
Pylint output
(project_3.11) C:\Code\project>pylint bug.py
************* Module bug
bug.py:14:0: E0240: Inconsistent method resolution order for class 'WindowMeta' (inconsistent-mro)
bug.py:17:0: E1139: Invalid metaclass 'WindowMeta' used (invalid-metaclass)
bug.py:29:0: E0240: Inconsistent method resolution order for class 'PathMeta' (inconsistent-mro)
bug.py:32:0: E1139: Invalid metaclass 'PathMeta' used (invalid-metaclass)
------------------------------------------------------------------
Your code has been rated at 0.91/10 (previous run: 0.00/10, +0.91)
Expected behavior
No pylint error for WindowMeta
/MyWindow
bug.py:29:0: E0240: Inconsistent method resolution order for class 'PathMeta' (inconsistent-mro)
bug.py:32:0: E1139: Invalid metaclass 'PathMeta' used (invalid-metaclass)
Pylint version
pylint 3.0.0b1
astroid 3.0.0a3
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]
OS / Environment
Windows 10 21H2
Additional dependencies
pylint==3.0.0b1
- astroid [required: >=3.0.0a2,<=3.1.0-dev0, installed: 3.0.0a3]
- colorama [required: >=0.4.5, installed: 0.4.6]
- dill [required: >=0.3.6, installed: 0.3.6]
- isort [required: >=4.2.5,<6, installed: 5.12.0]
- mccabe [required: >=0.6,<0.8, installed: 0.7.0]
- platformdirs [required: >=2.2.0, installed: 3.5.1]
- tomlkit [required: >=0.10.1, installed: 0.11.8]
PySide6-Essentials==6.4.3 - shiboken6 [required: ==6.4.3, installed: 6.4.3]
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 implementationNeeds astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)