-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
Labels
Brain 🧠
Needs a brain tip
Comments
More specifically, in the too early case, the import is called this way:
and in the good case, it's called this way:
|
marmarek
added a commit
to marmarek/astroid
that referenced
this issue
Jun 24, 2024
When importing Gtk, it looks like this: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk It is vital that gi.require_version() is made before related 'from gi.repository import ...'. The brain_gi tries to do that using transforms. And it works unless Gtk is imported as part of delayed assattr handling. Fix this by handling transforms earlier. Fixes pylint-dev#2190 Fixes pylint-dev/pylint#6352
marmarek
added a commit
to marmarek/astroid
that referenced
this issue
Jun 25, 2024
When importing Gtk, it looks like this: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk It is vital that gi.require_version() is made before related 'from gi.repository import ...'. The brain_gi tries to do that using transforms. And it works unless Gtk is imported as part of delayed assattr handling. Fix this by adding early transforms that are called before delayed assattr. Fixes pylint-dev#2190 Fixes pylint-dev/pylint#6352
marmarek
added a commit
to marmarek/astroid
that referenced
this issue
Jun 25, 2024
When importing Gtk, it looks like this: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk It is vital that gi.require_version() is made before related 'from gi.repository import ...'. The brain_gi tries to do that using transforms. And it works unless Gtk is imported as part of delayed assattr handling. Fix this by adding early transforms that are called before delayed assattr. Fixes pylint-dev#2190 Fixes pylint-dev/pylint#6352
marmarek
added a commit
to marmarek/astroid
that referenced
this issue
Jun 27, 2024
When importing Gtk, it looks like this: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk It is vital that gi.require_version() is made before related 'from gi.repository import ...'. The brain_gi tries to do that using transforms. And it works unless Gtk is imported as part of delayed assattr handling. Fix this by adding early transforms that are called before delayed assattr. Fixes pylint-dev#2190 Fixes pylint-dev/pylint#6352
marmarek
added a commit
to QubesOS/qubes-continuous-integration
that referenced
this issue
Jul 5, 2024
Workaround for pylint-dev/astroid#2190 The patch isn't used in this repo yet, but it's referenced from other repos.
marmarek
added a commit
to QubesOS/qubes-desktop-linux-manager
that referenced
this issue
Jul 5, 2024
pylint confuses GTK3 and GTK4, see details at Workaround for pylint-dev/astroid#2190
marmarek
added a commit
to QubesOS/qubes-desktop-linux-manager
that referenced
this issue
Jul 5, 2024
pylint confuses GTK3 and GTK4, see details at Workaround for pylint-dev/astroid#2190
marmarek
added a commit
to QubesOS/qubes-desktop-linux-manager
that referenced
this issue
Jul 7, 2024
pylint confuses GTK3 and GTK4, see details at Workaround for pylint-dev/astroid#2190
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
This only happens on systems where both Gtk 3 and Gtk 4 are available.
When you run pylint on this code, it works as expected; however, when you uncomment the
cell.props.xalign
line, it breaks withtest.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 haveconnect_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
The text was updated successfully, but these errors were encountered: