Skip to content

"no-member" not triggered for C-extension member but "--unsafe-load-any-extension=y" #9541

Open
@buhtz

Description

@buhtz

Question

I do know about the exceptional behavior of PyLint when it comes to c-extensions. I thought I had workaround that but it seems I still misunderstand something.

I expect a no-membe (E1101) error at this line (original code):

    self.colorRed.setColor(QPalette.WindowText, QColor(205, 0, 0))

The class QPalette is imported correct from PyQt6. But the member WindowText do not exit. Correct would be QPalette.ColorRole.WindowText. But PyLint do not see this error.

This is the pylint call I do use to test this:

pylint --disable=E0401,C0301,C0116,W0108,C0209,R0902,R0914,C0411,C0103,W0212,R0915,W0613,C0115,C3001,C0302,W0511,W0702,R1725,C0114,C0415,W0612,R0912,R1705 --extension-pkg-whitelist=PyQt6,PyQt6.QtCore --additional-builtins=_,ngettext --max-line-length=79 --good-names=idx,fp --unsafe-load-any-extension=y settingsdialog.py

So the question for me and my project is if I can configure PyLint in a way that it will give errors on that example line or if I have to live with it that it does not work with PyQt?

Documentation for future user

Don't know because I do not understand the underlying problem.

Additional context

https://github.com/bit-team/backintime/blob/dev/qt/settingsdialog.py#L2271-L2275

I am aware that PyQt6 is doing this "sip" magic. The Python code is somehow auto-generated based on the C-extension or the original C-code. Don't understand the details. I don't know if there is an official git repo having the Python code in it. But I found on my local system a file named .../PyQt6/QtGui.pyi containing the class QPalette and inside of it the enum ColorRole.

image

Looks wired.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions