I've recently installed Pylance as python language server on VSCode.
I'm building an app with PyQt5. In the script under question,
I'm inheriting a UI python script automatically generated by pyqt5 uic. listProfiles
is a QListView
object generated in Ui_ProfileMainWindow
class ProfileMainWindow(QMainWindow, Ui_ProfileMainWindow):
def __init__(self, model = None):
super().__init__()
self.setupUi(self)
if model:
self.listProfiles.setModel(model)
Pylance is capable of seeing the listProfiles
attribute and recognizes it as a QListView
object:
But no autocomplete is provided for it:
Furthermore, a when the mouse is over self.listProfiles
, a generic Any
type is pointed out for it:
I really can't figure out what's going on. I'd like to assume I've messed something up before thinking of a bug.
Since it's been a day I'm working with Pylance, I'd say that this was not happened as soon as I installed the language server, but I'm not sure about this piece of information, since I was working on another part of the script and, maybe, I just didn't realize that
No errors are in the code, since the app run and works properly.
EDIT 1
The problem is solved swapping the order of the inherited class:
class ProfileMainWindow(Ui_ProfileMainWindow,QMainWindow):
def __init__(self, model = None):
super().__init__()
self.setupUi(self)
if model:
self.listProfiles.setModel(model)
Still can't figure out why and what's going on.