alecthomas / importmagic

A Python library for finding unresolved symbols in Python code, and the corresponding imports
BSD 2-Clause "Simplified" License
120 stars 20 forks source link

GTK+ "broken" #53

Open 0x3333 opened 5 years ago

0x3333 commented 5 years ago

When using GTK+ 3.0 you must call gi.require_version("Gtk", "3.0") before other imports, like:

import gi
gi.require_version("Gtk", "3.0")

from gi.repository import Gdk, Gtk

builder = Gtk.Builder()
...

But importmagic re-arrange the imports broking the semantic:

import gi
from gi.repository import Gdk, Gtk

gi.require_version("Gtk", "3.0")

builder = Gtk.Builder()
...

Is that possible to add something to code to disable in these lines? Something like:

# importmagic-ignore-start
import gi
gi.require_version("Gtk", "3.0")
# importmagic-ignore-end

from gi.repository import Gdk, Gtk

builder = Gtk.Builder()
...