Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brain_gi uses wrong Gtk version for analysis #2190

Open
kulikjak opened this issue May 23, 2023 · 0 comments
Open

brain_gi uses wrong Gtk version for analysis #2190

kulikjak opened this issue May 23, 2023 · 0 comments
Labels
Brain 🧠 Needs a brain tip

Comments

@kulikjak
Copy link

Steps to reproduce

This only happens on systems where both Gtk 3 and Gtk 4 are available.

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

cell = Gtk.CellRendererText()
#cell.props.xalign = 1.0

Gtk.Builder().connect_signals({})

When you run pylint on this code, it works as expected; however, when you uncomment the cell.props.xalign line, it breaks with
test.py:8:0: E1101: Instance of 'Builder' has no 'connect_signals' member (no-member)
(connect_signals is only available in Gtk3, not in Gtk4)

Current behavior

test.py:8:0: E1101: Instance of 'Builder' has no 'connect_signals' member (no-member)

Expected behavior

E1101 is not there (as Builder does have connect_signals member in Gtk 3.0).

More info

I did a little bit more digging and found out that in the second (failing) case, following exception is raised in _register_require_version:
Namespace Gtk is already loaded with version 4.0

Debug prints in each function in brain_gi.py further showed that in the first case, require_version is handled first as expected. In the second case, _register_require_version is called after everything else has been processed, which is wrong (newer Gtk was already loaded at this point).

I found this in astroid 2.12.5 and pylint 2.15.2 with Python 3.7 and 3.11, but I also tried the latest and greatest (astroid 2.15.5 & pylint 2.17.4), and the same issue is still reproducible.

This issue was initially reported here:
pylint-dev/pylint#6352

@Pierre-Sassoulas Pierre-Sassoulas added the Brain 🧠 Needs a brain tip label May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Brain 🧠 Needs a brain tip
Projects
None yet
Development

No branches or pull requests

2 participants