[pygobject] Correct pyflakes warnings/errors



commit c8bc6ae10cfe8b2eff4204ec2175907a6eb0585a
Author: Johan Dahlin <johan gnome org>
Date:   Wed Mar 21 14:45:53 2012 -0300

    Correct pyflakes warnings/errors
    
    And add a target to make check that runs pyflakes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672578

 demos/gtk-demo/demos/Entry/entry_buffer.py       |    2 +-
 demos/gtk-demo/demos/Entry/entry_completion.py   |    2 +-
 demos/gtk-demo/demos/Entry/search_entry.py       |   12 +-
 demos/gtk-demo/demos/Icon View/iconviewbasics.py |    2 +-
 demos/gtk-demo/demos/Icon View/iconviewedit.py   |    2 +-
 demos/gtk-demo/demos/Tree View/liststore.py      |    3 +-
 demos/gtk-demo/demos/appwindow.py                |   13 +-
 demos/gtk-demo/demos/assistant.py                |    4 +-
 demos/gtk-demo/demos/builder.py                  |    4 +-
 demos/gtk-demo/demos/button_box.py               |    2 +-
 demos/gtk-demo/demos/clipboard.py                |    2 +-
 demos/gtk-demo/demos/colorselector.py            |    2 +-
 demos/gtk-demo/demos/combobox.py                 |    4 +-
 demos/gtk-demo/demos/dialogs.py                  |    4 +-
 demos/gtk-demo/demos/drawingarea.py              |    2 +-
 demos/gtk-demo/demos/expander.py                 |    4 +-
 demos/gtk-demo/demos/images.py                   |    8 +-
 demos/gtk-demo/demos/infobars.py                 |    2 +-
 demos/gtk-demo/demos/links.py                    |    2 +-
 demos/gtk-demo/demos/menus.py                    |    5 +-
 demos/gtk-demo/demos/pickers.py                  |    2 +-
 demos/gtk-demo/demos/pixbuf.py                   |    2 +-
 demos/gtk-demo/demos/printing.py                 |    3 +-
 demos/gtk-demo/demos/rotatedtext.py              |    6 +-
 demos/gtk-demo/gtk-demo.py                       |    9 +-
 examples/cairo-demo.py                           |    2 +-
 gi/__init__.py                                   |    4 +
 gi/_glib/__init__.py                             |  101 +++++++++++-
 gi/_glib/option.py                               |    1 +
 gi/_gobject/__init__.py                          |  203 +++++++++++++++++++---
 gi/_gobject/constants.py                         |    2 -
 gi/_gobject/propertyhelper.py                    |    4 +-
 gi/importer.py                                   |    2 +-
 gi/module.py                                     |    1 -
 gi/overrides/Gtk.py                              |    1 -
 gi/overrides/__init__.py                         |    1 -
 gi/pygtkcompat.py                                |    2 +
 gi/types.py                                      |    3 +
 tests/Makefile.am                                |    5 +
 tests/test_everything.py                         |    6 +-
 tests/test_gi.py                                 |    8 +-
 tests/test_option.py                             |   10 +-
 tests/test_overrides.py                          |   30 ++--
 tests/test_properties.py                         |   12 +-
 tests/test_pygtkcompat.py                        |    4 -
 tests/test_signal.py                             |    4 +-
 tests/test_source.py                             |    6 +-
 47 files changed, 377 insertions(+), 138 deletions(-)
---
diff --git a/demos/gtk-demo/demos/Entry/entry_buffer.py b/demos/gtk-demo/demos/Entry/entry_buffer.py
index cf4dfe1..39d4f8b 100644
--- a/demos/gtk-demo/demos/Entry/entry_buffer.py
+++ b/demos/gtk-demo/demos/Entry/entry_buffer.py
@@ -65,7 +65,7 @@ class EntryBufferApp:
         Gtk.main_quit()
 
 def main(demoapp=None):
-    app = EntryBufferApp()
+    EntryBufferApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/Entry/entry_completion.py b/demos/gtk-demo/demos/Entry/entry_completion.py
index abed962..a5387ac 100644
--- a/demos/gtk-demo/demos/Entry/entry_completion.py
+++ b/demos/gtk-demo/demos/Entry/entry_completion.py
@@ -79,7 +79,7 @@ class EntryBufferApp:
         Gtk.main_quit()
 
 def main(demoapp=None):
-    app = EntryBufferApp()
+    EntryBufferApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/Entry/search_entry.py b/demos/gtk-demo/demos/Entry/search_entry.py
index bf290f4..5955f8f 100644
--- a/demos/gtk-demo/demos/Entry/search_entry.py
+++ b/demos/gtk-demo/demos/Entry/search_entry.py
@@ -24,7 +24,7 @@ description = """
 GtkEntry allows to display icons and progress information. This demo shows how to use these features in a search entry.
  """
 
-from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GObject
+from gi.repository import Gtk, GObject
 
 (PIXBUF_COL,
  TEXT_COL) = range(2)
@@ -218,10 +218,10 @@ class SearchboxApp:
         self.start_search(button, entry)
 
     def search_entry_destroyed(self, widget):
-        if finish_search_id != 0:
-            GObject.source_remove(finish_search_id)
-        if search_progress_id != 0:
-            GObject.source_remove(search_progress_id)
+        if self.finish_search_id != 0:
+            GObject.source_remove(self.finish_search_id)
+        if self.search_progress_id != 0:
+            GObject.source_remove(self.search_progress_id)
 
         self.window = None
 
@@ -245,7 +245,7 @@ class SearchboxApp:
         menu.append (item)
 
 def main(demoapp=None):
-    app = SearchboxApp(demoapp)
+    SearchboxApp(demoapp)
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/Icon View/iconviewbasics.py b/demos/gtk-demo/demos/Icon View/iconviewbasics.py
index bd72b0c..fbf1eb3 100644
--- a/demos/gtk-demo/demos/Icon View/iconviewbasics.py	
+++ b/demos/gtk-demo/demos/Icon View/iconviewbasics.py	
@@ -213,7 +213,7 @@ class IconViewApp:
             store.append((path, name, pixbuf, is_dir))
 
 def main(demoapp=None):
-    app = IconViewApp(demoapp)
+    IconViewApp(demoapp)
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/Icon View/iconviewedit.py b/demos/gtk-demo/demos/Icon View/iconviewedit.py
index a137bd3..115d92c 100644
--- a/demos/gtk-demo/demos/Icon View/iconviewedit.py	
+++ b/demos/gtk-demo/demos/Icon View/iconviewedit.py	
@@ -94,7 +94,7 @@ class IconviewEditApp:
         model.set_row(iter_, [text])
 
 def main(demoapp=None):
-    app = IconviewEditApp()
+    IconviewEditApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/Tree View/liststore.py b/demos/gtk-demo/demos/Tree View/liststore.py
index 0be862e..3375c02 100644
--- a/demos/gtk-demo/demos/Tree View/liststore.py	
+++ b/demos/gtk-demo/demos/Tree View/liststore.py	
@@ -25,7 +25,6 @@ The GtkListStore is used to store data in list form, to be used later on by a Gt
 """
 
 from gi.repository import Gtk, GObject
-import sys
 
 class Bug:
     def __init__(self, is_fixed, number, severity, description):
@@ -198,7 +197,7 @@ class ListStoreApp:
         model.set_value(iter_, self.COLUMN_FIXED, is_fixed)
 
 def main(demoapp=None):
-    app = ListStoreApp()
+    ListStoreApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/appwindow.py b/demos/gtk-demo/demos/appwindow.py
index 8a7efbe..2c3402f 100644
--- a/demos/gtk-demo/demos/appwindow.py
+++ b/demos/gtk-demo/demos/appwindow.py
@@ -24,17 +24,15 @@ description = """
 Demonstrates a typical application window with menubar, toolbar, statusbar.
 """
 
-
 import os
-import sys
 
-from gi.repository import GLib, GdkPixbuf, Gdk, Gtk
+from gi.repository import GdkPixbuf, Gtk
 
 
-global infobar
-global window
-global messagelabel
-global _demoapp
+infobar = None
+window = None
+messagelabel = None
+_demoapp = None
 
 def widget_destroy(widget, button):
     widget.destroy()
@@ -280,6 +278,7 @@ def register_stock_icons():
 
     Gtk.stock_add(item, 1)
     '''
+    global _demoapp
 
     factory = Gtk.IconFactory()
     factory.add_default()
diff --git a/demos/gtk-demo/demos/assistant.py b/demos/gtk-demo/demos/assistant.py
index 84cedef..de42394 100644
--- a/demos/gtk-demo/demos/assistant.py
+++ b/demos/gtk-demo/demos/assistant.py
@@ -27,7 +27,7 @@ through these steps.
 """
 
 
-from gi.repository import Gtk, GdkPixbuf
+from gi.repository import Gtk
 
 
 class AssistantApp:
@@ -126,7 +126,7 @@ class AssistantApp:
         self.assistant.set_page_header_image(label, pixbuf)
 
 def main(demoapp=None):
-    app = AssistantApp()
+    AssistantApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/builder.py b/demos/gtk-demo/demos/builder.py
index 4f07bbb..196cc9d 100644
--- a/demos/gtk-demo/demos/builder.py
+++ b/demos/gtk-demo/demos/builder.py
@@ -27,7 +27,7 @@ Demonstrates an interface loaded from a XML description.
 
 import os
 
-from gi.repository import Gtk, GdkPixbuf, Gdk
+from gi.repository import Gtk
 
 
 class BuilderApp:
@@ -56,7 +56,7 @@ class BuilderApp:
         Gtk.main_quit()
 
 def main(demoapp=None):
-    app = BuilderApp(demoapp)
+    BuilderApp(demoapp)
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/button_box.py b/demos/gtk-demo/demos/button_box.py
index f13f799..8695dc2 100644
--- a/demos/gtk-demo/demos/button_box.py
+++ b/demos/gtk-demo/demos/button_box.py
@@ -113,7 +113,7 @@ class ButtonBoxApp:
         return frame
 
 def main(demoapp=None):
-    app = ButtonBoxApp()
+    ButtonBoxApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/clipboard.py b/demos/gtk-demo/demos/clipboard.py
index 315bbe0..4622690 100644
--- a/demos/gtk-demo/demos/clipboard.py
+++ b/demos/gtk-demo/demos/clipboard.py
@@ -224,7 +224,7 @@ class ClipboardApp:
         self.menu.popup(None, None, None, None, event.button, event.time)
 
 def main(demoapp=None):
-    app = ClipboardApp()
+    ClipboardApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/colorselector.py b/demos/gtk-demo/demos/colorselector.py
index c4d3b5f..dd5d5f6 100644
--- a/demos/gtk-demo/demos/colorselector.py
+++ b/demos/gtk-demo/demos/colorselector.py
@@ -103,7 +103,7 @@ class ColorSelectorApp:
         dialog.destroy()
 
 def main(demoapp=None):
-    app = ColorSelectorApp()
+    ColorSelectorApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/combobox.py b/demos/gtk-demo/demos/combobox.py
index 1e54ef0..8335b5e 100644
--- a/demos/gtk-demo/demos/combobox.py
+++ b/demos/gtk-demo/demos/combobox.py
@@ -29,7 +29,7 @@ How the options are displayed is controlled by cell renderers.
  """
 
 
-from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GObject
+from gi.repository import Gtk, Gdk, GdkPixbuf, GLib
 
 
 (PIXBUF_COL,
@@ -331,7 +331,7 @@ class ComboboxApp:
         entry.append_text('Three')
 
 def main(demoapp=None):
-    app = ComboboxApp(demoapp)
+    ComboboxApp(demoapp)
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/dialogs.py b/demos/gtk-demo/demos/dialogs.py
index 78ad5df..4539ff9 100644
--- a/demos/gtk-demo/demos/dialogs.py
+++ b/demos/gtk-demo/demos/dialogs.py
@@ -24,7 +24,7 @@ description = """
 Dialog widgets are used to pop up a transient window for user feedback.
 """
 
-from gi.repository import Gtk, GdkPixbuf
+from gi.repository import Gtk
 
 class DialogsApp:
     def __init__(self):
@@ -146,7 +146,7 @@ class DialogsApp:
         dialog.destroy()
 
 def main(demoapp=None):
-    app = DialogsApp()
+    DialogsApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/drawingarea.py b/demos/gtk-demo/demos/drawingarea.py
index 8d7cb51..5d65fc4 100644
--- a/demos/gtk-demo/demos/drawingarea.py
+++ b/demos/gtk-demo/demos/drawingarea.py
@@ -198,7 +198,7 @@ class DrawingAreaApp:
         return True
 
 def main(demoapp=None):
-    app = DrawingAreaApp()
+    DrawingAreaApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/expander.py b/demos/gtk-demo/demos/expander.py
index 96387b2..22c0440 100644
--- a/demos/gtk-demo/demos/expander.py
+++ b/demos/gtk-demo/demos/expander.py
@@ -25,7 +25,7 @@ GtkExpander allows to provide additional content that is initially hidden.
 This is also known as "disclosure triangle".
 """
 
-from gi.repository import Gtk, GdkPixbuf
+from gi.repository import Gtk
 
 class ExpanderApp:
     def __init__(self):
@@ -53,7 +53,7 @@ class ExpanderApp:
         self.window.show_all()
 
 def main(demoapp=None):
-    app = ExpanderApp()
+    ExpanderApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/images.py b/demos/gtk-demo/demos/images.py
index 7e8d19e..6e72545 100644
--- a/demos/gtk-demo/demos/images.py
+++ b/demos/gtk-demo/demos/images.py
@@ -24,11 +24,11 @@ description = """GtkImage is used to display an image; the image can be in a num
 This demo code shows some of the more obscure cases, in the simple case a call to gtk_image_new_from_file() is all you need.
 """
 
-from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, Gio, GObject
 import os
-import math
 from os import path
 
+from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, Gio, GObject
+
 class ImagesApp:
     def __init__(self):
         self.pixbuf_loader = None
@@ -63,7 +63,7 @@ class ImagesApp:
         filename = os.path.join(self.base_path, 'gtk-logo-rgb.gif')
         pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename)
         transparent = pixbuf.add_alpha(True, 0xff, 0xff, 0xff)
-        image = Gtk.Image.new_from_pixbuf(pixbuf)
+        image = Gtk.Image.new_from_pixbuf(transparent)
         frame.add(image)
 
         # Animation
@@ -293,7 +293,7 @@ class ImagesApp:
         Gtk.main_quit()
 
 def main(demoapp=None):
-    app = ImagesApp()
+    ImagesApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/infobars.py b/demos/gtk-demo/demos/infobars.py
index 5819038..fbbdc1d 100644
--- a/demos/gtk-demo/demos/infobars.py
+++ b/demos/gtk-demo/demos/infobars.py
@@ -92,7 +92,7 @@ class InfobarApp:
         dialog.destroy()
 
 def main(demoapp=None):
-    app = InfobarApp()
+    InfobarApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/links.py b/demos/gtk-demo/demos/links.py
index 898f3e6..1ea57b5 100644
--- a/demos/gtk-demo/demos/links.py
+++ b/demos/gtk-demo/demos/links.py
@@ -67,7 +67,7 @@ a program (exclusively) via keyboard input."""
         dialog.destroy()
 
 def main(demoapp=None):
-    app = LinksApp()
+    LinksApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/menus.py b/demos/gtk-demo/demos/menus.py
index 2e3a41b..6b70361 100644
--- a/demos/gtk-demo/demos/menus.py
+++ b/demos/gtk-demo/demos/menus.py
@@ -47,8 +47,6 @@ class MenusApp:
         menubar = Gtk.MenuBar()
         box1.pack_start(menubar, False, True, 0)
 
-        menu = self.create_menu(2, True)
-
         menuitem = Gtk.MenuItem(label='test\nline2')
         menuitem.set_submenu(self.create_menu(3, True))
         menubar.append(menuitem)
@@ -78,7 +76,6 @@ class MenusApp:
             return None
 
         menu = Gtk.Menu()
-        group = None
 
         if tearoff:
             menuitem = Gtk.TearoffMenuItem()
@@ -115,7 +112,7 @@ class MenusApp:
             menubar.props.pack_direction = Gtk.PackDirection.LTR
 
 def main(demoapp=None):
-    app = MenusApp()
+    MenusApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/pickers.py b/demos/gtk-demo/demos/pickers.py
index 8ecedb6..8d0046a 100644
--- a/demos/gtk-demo/demos/pickers.py
+++ b/demos/gtk-demo/demos/pickers.py
@@ -67,7 +67,7 @@ class PickersApp:
         self.window.show_all()
 
 def main(demoapp=None):
-    app = PickersApp()
+    PickersApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/pixbuf.py b/demos/gtk-demo/demos/pixbuf.py
index 3b3e8c9..1dd0125 100644
--- a/demos/gtk-demo/demos/pixbuf.py
+++ b/demos/gtk-demo/demos/pixbuf.py
@@ -173,7 +173,7 @@ class PixbufApp:
         Gtk.main_quit()
 
 def main(demoapp=None):
-    app = PixbufApp()
+    PixbufApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/demos/printing.py b/demos/gtk-demo/demos/printing.py
index 196aedb..77d576f 100644
--- a/demos/gtk-demo/demos/printing.py
+++ b/demos/gtk-demo/demos/printing.py
@@ -25,7 +25,6 @@ GtkPrintOperation offers a simple API to support printing in a cross-platform wa
 """
 
 from gi.repository import Gtk, GLib, Pango, PangoCairo
-import cairo
 import math
 import os
 
@@ -94,7 +93,7 @@ class PrintingApp:
         if not os.path.isfile(file_path):
             file_path = os.path.join('demos', file_path)
             if not os.path.isfile:
-                raise FileNotFoundError()
+                raise Exception("file not found: " % (file_path, ))
 
         # in reality you should most likely not read the entire
         # file into a buffer
diff --git a/demos/gtk-demo/demos/rotatedtext.py b/demos/gtk-demo/demos/rotatedtext.py
index af33319..19388f7 100644
--- a/demos/gtk-demo/demos/rotatedtext.py
+++ b/demos/gtk-demo/demos/rotatedtext.py
@@ -117,14 +117,14 @@ class RotatedTextApp:
         logical_rect.y = -ascent
         logical_rect.height = ascent
 
-        ink_rect = logical_rect
 
         # Set fancy shape attributes for all hearts
         attrs = Pango.AttrList()
-        p = BYTES_TEXT.find(BYTES_HEART)
 
         # FIXME: attr_shape_new_with_data isn't introspectable
         '''
+        ink_rect = logical_rect
+        p = BYTES_TEXT.find(BYTES_HEART)
         while (p != -1):
             attr = Pango.attr_shape_new_with_data(ink_rect,
                                                   logical_rect,
@@ -189,7 +189,7 @@ class RotatedTextApp:
         return False
 
 def main(demoapp=None):
-    app = RotatedTextApp()
+    RotatedTextApp()
     Gtk.main()
 
 if __name__ == '__main__':
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index d19eed2..2739332 100755
--- a/demos/gtk-demo/gtk-demo.py
+++ b/demos/gtk-demo/gtk-demo.py
@@ -20,14 +20,13 @@
 # USA
 
 
-import os
-import sys
 import codecs
-import glob
-import tokenize
 import keyword
+import os
+import tokenize
+import sys
 
-from gi.repository import GLib, GObject, Gio, Pango, GdkPixbuf, Gtk
+from gi.repository import GLib, GObject, Pango, GdkPixbuf, Gtk
 
 
 
diff --git a/examples/cairo-demo.py b/examples/cairo-demo.py
index cec45d8..1cc69bf 100755
--- a/examples/cairo-demo.py
+++ b/examples/cairo-demo.py
@@ -4,7 +4,7 @@ Based on cairo-demo/X11/cairo-demo.c
 """
 
 import cairo
-from gi.repository import Gdk, Gtk
+from gi.repository import Gtk
 
 SIZE = 30
 
diff --git a/gi/__init__.py b/gi/__init__.py
index e6bc06e..d72351b 100644
--- a/gi/__init__.py
+++ b/gi/__init__.py
@@ -25,6 +25,10 @@ from ._gi import _API, Repository
 # Force loading the GObject typelib so we have available the wrappers for
 # base classes such as GInitiallyUnowned
 import gi._gobject
+gi # pyflakes
+
+_API = _API  # pyflakes
+
 import os
 
 _versions = {}
diff --git a/gi/_glib/__init__.py b/gi/_glib/__init__.py
index f56e6d5..b0d2212 100644
--- a/gi/_glib/__init__.py
+++ b/gi/_glib/__init__.py
@@ -1,6 +1,6 @@
 # -*- Mode: Python; py-indent-offset: 4 -*-
 # pygobject - Python bindings for the GObject library
-# Copyright (C) 2006-2008 Johan Dahlin
+# Copyright (C) 2006-2012 Johan Dahlin
 #
 #   glib/__init__.py: initialisation file for glib module
 #
@@ -19,8 +19,103 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 # USA
 
-from ._glib import *
+from . import _glib
 
+# Internal API
 _PyGLib_API = _glib._PyGLib_API
 
-del _glib
+# Types
+GError = _glib.GError
+IOChannel = _glib.IOChannel
+Idle = _glib.Idle
+MainContext = _glib.MainContext
+MainLoop = _glib.MainLoop
+OptionContext = _glib.OptionContext
+OptionGroup = _glib.OptionGroup
+Pid = _glib.Pid
+PollFD = _glib.PollFD
+Source = _glib.Source
+Timeout = _glib.Timeout
+
+# Constants
+IO_ERR = _glib.IO_ERR
+IO_FLAG_APPEND = _glib.IO_FLAG_APPEND
+IO_FLAG_GET_MASK = _glib.IO_FLAG_GET_MASK
+IO_FLAG_IS_READABLE = _glib.IO_FLAG_IS_READABLE
+IO_FLAG_IS_SEEKABLE = _glib.IO_FLAG_IS_SEEKABLE
+IO_FLAG_IS_WRITEABLE = _glib.IO_FLAG_IS_WRITEABLE
+IO_FLAG_MASK = _glib.IO_FLAG_MASK
+IO_FLAG_NONBLOCK = _glib.IO_FLAG_NONBLOCK
+IO_FLAG_SET_MASK = _glib.IO_FLAG_SET_MASK
+IO_HUP = _glib.IO_HUP
+IO_IN = _glib.IO_IN
+IO_NVAL = _glib.IO_NVAL
+IO_OUT = _glib.IO_OUT
+IO_PRI = _glib.IO_PRI
+IO_STATUS_AGAIN = _glib.IO_STATUS_AGAIN
+IO_STATUS_EOF = _glib.IO_STATUS_EOF
+IO_STATUS_ERROR = _glib.IO_STATUS_ERROR
+IO_STATUS_NORMAL = _glib.IO_STATUS_NORMAL
+OPTION_ERROR = _glib.OPTION_ERROR
+OPTION_ERROR_BAD_VALUE = _glib.OPTION_ERROR_BAD_VALUE
+OPTION_ERROR_FAILED = _glib.OPTION_ERROR_FAILED
+OPTION_ERROR_UNKNOWN_OPTION = _glib.OPTION_ERROR_UNKNOWN_OPTION
+OPTION_FLAG_FILENAME = _glib.OPTION_FLAG_FILENAME
+OPTION_FLAG_HIDDEN = _glib.OPTION_FLAG_HIDDEN
+OPTION_FLAG_IN_MAIN = _glib.OPTION_FLAG_IN_MAIN
+OPTION_FLAG_NOALIAS = _glib.OPTION_FLAG_NOALIAS
+OPTION_FLAG_NO_ARG = _glib.OPTION_FLAG_NO_ARG
+OPTION_FLAG_OPTIONAL_ARG = _glib.OPTION_FLAG_OPTIONAL_ARG
+OPTION_FLAG_REVERSE = _glib.OPTION_FLAG_REVERSE
+OPTION_REMAINING = _glib.OPTION_REMAINING
+PRIORITY_DEFAULT = _glib.PRIORITY_DEFAULT
+PRIORITY_DEFAULT_IDLE = _glib.PRIORITY_DEFAULT_IDLE
+PRIORITY_HIGH = _glib.PRIORITY_HIGH
+PRIORITY_HIGH_IDLE = _glib.PRIORITY_HIGH_IDLE
+PRIORITY_LOW = _glib.PRIORITY_LOW
+SPAWN_CHILD_INHERITS_STDIN = _glib.SPAWN_CHILD_INHERITS_STDIN
+SPAWN_DO_NOT_REAP_CHILD = _glib.SPAWN_DO_NOT_REAP_CHILD
+SPAWN_FILE_AND_ARGV_ZERO = _glib.SPAWN_FILE_AND_ARGV_ZERO
+SPAWN_LEAVE_DESCRIPTORS_OPEN = _glib.SPAWN_LEAVE_DESCRIPTORS_OPEN
+SPAWN_SEARCH_PATH = _glib.SPAWN_SEARCH_PATH
+SPAWN_STDERR_TO_DEV_NULL = _glib.SPAWN_STDERR_TO_DEV_NULL
+SPAWN_STDOUT_TO_DEV_NULL = _glib.SPAWN_STDOUT_TO_DEV_NULL
+USER_DIRECTORY_DESKTOP = _glib.USER_DIRECTORY_DESKTOP
+USER_DIRECTORY_DOCUMENTS = _glib.USER_DIRECTORY_DOCUMENTS
+USER_DIRECTORY_DOWNLOAD = _glib.USER_DIRECTORY_DOWNLOAD
+USER_DIRECTORY_MUSIC = _glib.USER_DIRECTORY_MUSIC
+USER_DIRECTORY_PICTURES = _glib.USER_DIRECTORY_PICTURES
+USER_DIRECTORY_PUBLIC_SHARE = _glib.USER_DIRECTORY_PUBLIC_SHARE
+USER_DIRECTORY_TEMPLATES = _glib.USER_DIRECTORY_TEMPLATES
+USER_DIRECTORY_VIDEOS = _glib.USER_DIRECTORY_VIDEOS
+
+# Functions
+child_watch_add = _glib.child_watch_add
+filename_display_basename = _glib.filename_display_basename
+filename_display_name = _glib.filename_display_name
+filename_from_utf8 = _glib.filename_from_utf8
+find_program_in_path = _glib.find_program_in_path
+get_application_name = _glib.get_application_name
+get_current_time = _glib.get_current_time
+get_prgname = _glib.get_prgname
+get_system_config_dirs = _glib.get_system_config_dirs
+get_system_data_dirs = _glib.get_system_data_dirs
+get_user_cache_dir = _glib.get_user_cache_dir
+get_user_config_dir = _glib.get_user_config_dir
+get_user_data_dir = _glib.get_user_data_dir
+get_user_special_dir = _glib.get_user_special_dir
+glib_version = _glib.glib_version
+idle_add = _glib.idle_add
+io_add_watch = _glib.io_add_watch
+main_context_default = _glib.main_context_default
+main_depth = _glib.main_depth
+markup_escape_text = _glib.markup_escape_text
+pyglib_version = _glib.pyglib_version
+set_application_name = _glib.set_application_name
+set_prgname = _glib.set_prgname
+source_remove = _glib.source_remove
+spawn_async = _glib.spawn_async
+threads_init = _glib.threads_init
+timeout_add = _glib.timeout_add
+timeout_add_seconds = _glib.timeout_add_seconds
+uri_list_extract_uris = _glib.uri_list_extract_uris
diff --git a/gi/_glib/option.py b/gi/_glib/option.py
index c84d303..af718fb 100644
--- a/gi/_glib/option.py
+++ b/gi/_glib/option.py
@@ -42,6 +42,7 @@ else:
     _bytes = str
 
 import gi._glib
+gi # pyflakes
 _glib = sys.modules['gi._glib._glib']
 
 __all__ = [
diff --git a/gi/_gobject/__init__.py b/gi/_gobject/__init__.py
index 4304b80..8fadfea 100644
--- a/gi/_gobject/__init__.py
+++ b/gi/_gobject/__init__.py
@@ -1,6 +1,6 @@
 # -*- Mode: Python; py-indent-offset: 4 -*-
 # pygobject - Python bindings for the GObject library
-# Copyright (C) 2006  Johan Dahlin
+# Copyright (C) 2006-2012  Johan Dahlin
 #
 #   gobject/__init__.py: initialisation file for gobject module
 #
@@ -27,34 +27,187 @@ import sys
 if 'gobject' in sys.modules:
     raise ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".')
 
-from .._glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
-     io_add_watch, source_remove, child_watch_add, markup_escape_text, \
-     get_current_time, filename_display_name, filename_display_basename, \
-     filename_from_utf8, get_application_name, set_application_name, \
-     get_prgname, set_prgname, main_depth, Pid, GError, glib_version, \
-     MainLoop, MainContext, main_context_default, IOChannel, Source, Idle, \
-     Timeout, PollFD, OptionGroup, OptionContext, option, uri_list_extract_uris
-from .._glib import SPAWN_LEAVE_DESCRIPTORS_OPEN, SPAWN_DO_NOT_REAP_CHILD, \
-     SPAWN_SEARCH_PATH, SPAWN_STDOUT_TO_DEV_NULL, SPAWN_STDERR_TO_DEV_NULL, \
-     SPAWN_CHILD_INHERITS_STDIN, SPAWN_FILE_AND_ARGV_ZERO, PRIORITY_HIGH, \
-     PRIORITY_DEFAULT, PRIORITY_HIGH_IDLE, PRIORITY_DEFAULT_IDLE, \
-     PRIORITY_LOW, IO_IN, IO_OUT, IO_PRI, IO_ERR, IO_HUP, IO_NVAL, \
-     IO_STATUS_ERROR, IO_STATUS_NORMAL, IO_STATUS_EOF, IO_STATUS_AGAIN, \
-     IO_FLAG_APPEND, IO_FLAG_NONBLOCK, IO_FLAG_IS_READABLE, \
-     IO_FLAG_IS_WRITEABLE, IO_FLAG_IS_SEEKABLE, IO_FLAG_MASK, \
-     IO_FLAG_GET_MASK, IO_FLAG_SET_MASK, OPTION_FLAG_HIDDEN, \
-     OPTION_FLAG_IN_MAIN, OPTION_FLAG_REVERSE, OPTION_FLAG_NO_ARG, \
-     OPTION_FLAG_FILENAME, OPTION_FLAG_OPTIONAL_ARG, OPTION_FLAG_NOALIAS, \
-     OPTION_ERROR_UNKNOWN_OPTION, OPTION_ERROR_BAD_VALUE, \
-     OPTION_ERROR_FAILED, OPTION_REMAINING, OPTION_ERROR
-
-from .constants import *
-from ._gobject import *
+from .. import _glib
+from . import _gobject
+from . import constants
+from .propertyhelper import Property
 
+GBoxed = _gobject.GBoxed
+GEnum = _gobject.GEnum
+GFlags = _gobject.GFlags
+GInterface = _gobject.GInterface
+GObject = _gobject.GObject
+GObjectWeakRef = _gobject.GObjectWeakRef
+GParamSpec = _gobject.GParamSpec
+GPointer = _gobject.GPointer
+GType = _gobject.GType
+PARAM_CONSTRUCT = _gobject.PARAM_CONSTRUCT
+PARAM_CONSTRUCT_ONLY = _gobject.PARAM_CONSTRUCT_ONLY
+PARAM_LAX_VALIDATION = _gobject.PARAM_LAX_VALIDATION
+PARAM_READABLE = _gobject.PARAM_READABLE
+PARAM_READWRITE = _gobject.PARAM_READWRITE
+PARAM_WRITABLE = _gobject.PARAM_WRITABLE
+SIGNAL_ACTION = _gobject.SIGNAL_ACTION
+SIGNAL_DETAILED = _gobject.SIGNAL_DETAILED
+SIGNAL_NO_HOOKS = _gobject.SIGNAL_NO_HOOKS
+SIGNAL_NO_RECURSE = _gobject.SIGNAL_NO_RECURSE
+SIGNAL_RUN_CLEANUP = _gobject.SIGNAL_RUN_CLEANUP
+SIGNAL_RUN_FIRST = _gobject.SIGNAL_RUN_FIRST
+SIGNAL_RUN_LAST = _gobject.SIGNAL_RUN_LAST
+TYPE_GSTRING = _gobject.TYPE_GSTRING
+TYPE_INVALID = _gobject.TYPE_INVALID
+Warning = _gobject.Warning
 _PyGObject_API = _gobject._PyGObject_API
+add_emission_hook = _gobject.add_emission_hook
+features = _gobject.features
+list_properties = _gobject.list_properties
+new = _gobject.new
+pygobject_version = _gobject.pygobject_version
+remove_emission_hook = _gobject.remove_emission_hook
+signal_accumulator_true_handled = _gobject.signal_accumulator_true_handled
+signal_list_ids = _gobject.signal_list_ids
+signal_list_names = _gobject.signal_list_names
+signal_lookup = _gobject.signal_lookup
+signal_name = _gobject.signal_name
+signal_new = _gobject.signal_new
+signal_query = _gobject.signal_query
+threads_init = _gobject.threads_init
+type_children = _gobject.type_children
+type_from_name = _gobject.type_from_name
+type_interfaces = _gobject.type_interfaces
+type_is_a = _gobject.type_is_a
+type_name = _gobject.type_name
+type_parent = _gobject.type_parent
+type_register = _gobject.type_register
 
-from .propertyhelper import Property
+spawn_async = _glib.spawn_async
+idle_add = _glib.idle_add
+timeout_add = _glib.timeout_add
+timeout_add_seconds = _glib.timeout_add_seconds
+io_add_watch = _glib.io_add_watch
+source_remove = _glib.source_remove
+child_watch_add = _glib.child_watch_add
+markup_escape_text = _glib.markup_escape_text
+get_current_time = _glib.get_current_time
+filename_display_name = _glib.filename_display_name
+filename_display_basename = _glib.filename_display_basename
+filename_from_utf8 = _glib.filename_from_utf8
+get_application_name = _glib.get_application_name
+set_application_name = _glib.set_application_name
+get_prgname = _glib.get_prgname
+set_prgname = _glib.set_prgname
+main_depth = _glib.main_depth
+Pid = _glib.Pid
+GError = _glib.GError
+glib_version = _glib.glib_version
+MainLoop = _glib.MainLoop
+MainContext = _glib.MainContext
+main_context_default = _glib.main_context_default
+IOChannel = _glib.IOChannel
+Source = _glib.Source
+Idle = _glib.Idle
+Timeout = _glib.Timeout
+PollFD = _glib.PollFD
+OptionGroup = _glib.OptionGroup
+OptionContext = _glib.OptionContext
+uri_list_extract_uris = _glib.uri_list_extract_uris
+
+SPAWN_LEAVE_DESCRIPTORS_OPEN = _glib.SPAWN_LEAVE_DESCRIPTORS_OPEN
+SPAWN_DO_NOT_REAP_CHILD = _glib.SPAWN_DO_NOT_REAP_CHILD
+SPAWN_SEARCH_PATH = _glib.SPAWN_SEARCH_PATH
+SPAWN_STDOUT_TO_DEV_NULL = _glib.SPAWN_STDOUT_TO_DEV_NULL
+SPAWN_STDERR_TO_DEV_NULL = _glib.SPAWN_STDERR_TO_DEV_NULL
+SPAWN_CHILD_INHERITS_STDIN = _glib.SPAWN_CHILD_INHERITS_STDIN
+SPAWN_FILE_AND_ARGV_ZERO = _glib.SPAWN_FILE_AND_ARGV_ZERO
+PRIORITY_HIGH = _glib.PRIORITY_HIGH
+PRIORITY_DEFAULT = _glib.PRIORITY_DEFAULT
+PRIORITY_HIGH_IDLE = _glib.PRIORITY_HIGH_IDLE
+PRIORITY_DEFAULT_IDLE = _glib.PRIORITY_DEFAULT_IDLE
+PRIORITY_LOW = _glib.PRIORITY_LOW
+IO_IN = _glib.IO_IN
+IO_OUT = _glib.IO_OUT
+IO_PRI = _glib.IO_PRI
+IO_ERR = _glib.IO_ERR
+IO_HUP = _glib.IO_HUP
+IO_NVAL = _glib.IO_NVAL
+IO_STATUS_ERROR = _glib.IO_STATUS_ERROR
+IO_STATUS_NORMAL = _glib.IO_STATUS_NORMAL
+IO_STATUS_EOF = _glib.IO_STATUS_EOF
+IO_STATUS_AGAIN = _glib.IO_STATUS_AGAIN
+IO_FLAG_APPEND = _glib.IO_FLAG_APPEND
+IO_FLAG_NONBLOCK = _glib.IO_FLAG_NONBLOCK
+IO_FLAG_IS_READABLE = _glib.IO_FLAG_IS_READABLE
+IO_FLAG_IS_WRITEABLE = _glib.IO_FLAG_IS_WRITEABLE
+IO_FLAG_IS_SEEKABLE = _glib.IO_FLAG_IS_SEEKABLE
+IO_FLAG_MASK = _glib.IO_FLAG_MASK
+IO_FLAG_GET_MASK = _glib.IO_FLAG_GET_MASK
+IO_FLAG_SET_MASK = _glib.IO_FLAG_SET_MASK
+OPTION_FLAG_HIDDEN = _glib.OPTION_FLAG_HIDDEN
+OPTION_FLAG_IN_MAIN = _glib.OPTION_FLAG_IN_MAIN
+OPTION_FLAG_REVERSE = _glib.OPTION_FLAG_REVERSE
+OPTION_FLAG_NO_ARG = _glib.OPTION_FLAG_NO_ARG
+OPTION_FLAG_FILENAME = _glib.OPTION_FLAG_FILENAME
+OPTION_FLAG_OPTIONAL_ARG = _glib.OPTION_FLAG_OPTIONAL_ARG
+OPTION_FLAG_NOALIAS = _glib.OPTION_FLAG_NOALIAS
+OPTION_ERROR_UNKNOWN_OPTION = _glib.OPTION_ERROR_UNKNOWN_OPTION
+OPTION_ERROR_BAD_VALUE = _glib.OPTION_ERROR_BAD_VALUE
+OPTION_ERROR_FAILED = _glib.OPTION_ERROR_FAILED
+OPTION_REMAINING = _glib.OPTION_REMAINING
+OPTION_ERROR = _glib.OPTION_ERROR
+
+TYPE_NONE = constants.TYPE_NONE
+TYPE_INTERFACE = constants.TYPE_INTERFACE
+TYPE_CHAR = constants.TYPE_CHAR
+TYPE_UCHAR = constants.TYPE_UCHAR
+TYPE_BOOLEAN = constants.TYPE_BOOLEAN
+TYPE_INT = constants.TYPE_INT
+TYPE_UINT = constants.TYPE_UINT
+TYPE_LONG = constants.TYPE_LONG
+TYPE_ULONG = constants.TYPE_ULONG
+TYPE_INT64 = constants.TYPE_INT64
+TYPE_UINT64 = constants.TYPE_UINT64
+TYPE_ENUM = constants.TYPE_ENUM
+TYPE_FLAGS = constants.TYPE_FLAGS
+TYPE_FLOAT = constants.TYPE_FLOAT
+TYPE_DOUBLE = constants.TYPE_DOUBLE
+TYPE_STRING = constants.TYPE_STRING
+TYPE_POINTER = constants.TYPE_POINTER
+TYPE_BOXED = constants.TYPE_BOXED
+TYPE_PARAM = constants.TYPE_PARAM
+TYPE_OBJECT = constants.TYPE_OBJECT
+TYPE_PYOBJECT = constants.TYPE_PYOBJECT
+TYPE_UNICHAR = constants.TYPE_UNICHAR
+G_MINFLOAT = constants.G_MINFLOAT
+G_MAXFLOAT = constants.G_MAXFLOAT
+G_MINDOUBLE = constants.G_MINDOUBLE
+G_MAXDOUBLE = constants.G_MAXDOUBLE
+G_MINSHORT = constants.G_MINSHORT
+G_MAXSHORT = constants.G_MAXSHORT
+G_MAXUSHORT = constants.G_MAXUSHORT
+G_MININT = constants.G_MININT
+G_MAXINT = constants.G_MAXINT
+G_MAXUINT = constants.G_MAXUINT
+G_MINLONG = constants.G_MINLONG
+G_MAXLONG = constants.G_MAXLONG
+G_MAXULONG = constants.G_MAXULONG
+G_MININT8 = constants.G_MININT8
+G_MAXINT8 = constants.G_MAXINT8
+G_MAXUINT8 = constants.G_MAXUINT8
+G_MININT16 = constants.G_MININT16
+G_MAXINT16 = constants.G_MAXINT16
+G_MAXUINT16 = constants.G_MAXUINT16
+G_MININT32 = constants.G_MININT32
+G_MAXINT32 = constants.G_MAXINT32
+G_MAXUINT32 = constants.G_MAXUINT32
+G_MININT64 = constants.G_MININT64
+G_MAXINT64 = constants.G_MAXINT64
+G_MAXUINT64 = constants.G_MAXUINT64
+G_MAXSIZE = constants.G_MAXSIZE
+G_MAXSSIZE = constants.G_MAXSSIZE
+G_MINOFFSET = constants.G_MINOFFSET
+G_MAXOFFSET = constants.G_MAXOFFSET
 
+from .._glib import option
 sys.modules['gi._gobject.option'] = option
 
 class GObjectMeta(type):
diff --git a/gi/_gobject/constants.py b/gi/_gobject/constants.py
index ff970ae..ded3513 100644
--- a/gi/_gobject/constants.py
+++ b/gi/_gobject/constants.py
@@ -19,8 +19,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 # USA
 
-import sys
-
 from . import _gobject
 
 # TYPE_INVALID defined in gobjectmodule.c
diff --git a/gi/_gobject/propertyhelper.py b/gi/_gobject/propertyhelper.py
index 8042d26..80fe46b 100644
--- a/gi/_gobject/propertyhelper.py
+++ b/gi/_gobject/propertyhelper.py
@@ -27,11 +27,11 @@ from .constants import \
      TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, \
      TYPE_BOOLEAN, TYPE_INT, TYPE_UINT, TYPE_LONG, \
      TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_ENUM, \
-     TYPE_FLAGS, TYPE_FLOAT, TYPE_DOUBLE, TYPE_STRING, \
+     TYPE_FLOAT, TYPE_DOUBLE, TYPE_STRING, \
      TYPE_POINTER, TYPE_BOXED, TYPE_PARAM, TYPE_OBJECT, \
      TYPE_PYOBJECT
 from .constants import \
-     G_MINFLOAT, G_MAXFLOAT, G_MINDOUBLE, G_MAXDOUBLE, \
+     G_MAXFLOAT, G_MAXDOUBLE, \
      G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \
      G_MAXULONG
 
diff --git a/gi/importer.py b/gi/importer.py
index 62555b1..8065136 100644
--- a/gi/importer.py
+++ b/gi/importer.py
@@ -24,7 +24,7 @@ from __future__ import absolute_import
 import logging
 import sys
 
-from ._gi import Repository, RepositoryError
+from ._gi import Repository
 from .module import DynamicModule, DynamicGObjectModule, DynamicGLibModule
 
 
diff --git a/gi/module.py b/gi/module.py
index b749491..4ee9b80 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -22,7 +22,6 @@
 
 from __future__ import absolute_import
 
-import os
 from . import _glib, _gobject
 try:
     maketrans = ''.maketrans
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 4018b32..1909ca5 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -20,7 +20,6 @@
 # USA
 
 import sys
-from gi import _gobject
 from gi.repository import GObject
 from ..overrides import override
 from ..importer import modules
diff --git a/gi/overrides/__init__.py b/gi/overrides/__init__.py
index ce98538..513ad31 100644
--- a/gi/overrides/__init__.py
+++ b/gi/overrides/__init__.py
@@ -1,4 +1,3 @@
-import sys
 import types
 
 from gi import _gobject
diff --git a/gi/pygtkcompat.py b/gi/pygtkcompat.py
index 26f803a..f18bdfa 100644
--- a/gi/pygtkcompat.py
+++ b/gi/pygtkcompat.py
@@ -39,9 +39,11 @@ try:
     # Python 3 
     from collections import UserList
     from imp import reload
+    UserList  # pyflakes
 except ImportError:
     # Python 2 ships that in a different module
     from UserList import UserList
+    UserList  # pyflakes
 
 import gi
 from gi.repository import GObject
diff --git a/gi/types.py b/gi/types.py
index f767e3c..2cd5ab4 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -33,6 +33,9 @@ from ._gi import \
     register_interface_info, \
     hook_up_vfunc_implementation
 
+
+StructInfo  # pyflakes
+
 if sys.version_info > (3, 0):
     def callable(obj):
         return hasattr(obj, '__call__')
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e666696..4924a87 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -110,10 +110,15 @@ RUN_TESTS_ENV_VARS= \
 	TESTS_BUILDDIR=$(builddir)
 RUN_TESTS_LAUNCH=$(RUN_TESTS_ENV_VARS) $(DBUS_LAUNCH) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py
 
+check-local: check-pyflakes
 check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib gschemas.compiled
 	TEST_FILES="$(TEST_FILES_STATIC)" $(RUN_TESTS_LAUNCH)
 	TEST_FILES="$(TEST_FILES_GI)" $(RUN_TESTS_LAUNCH)
 
+check-pyflakes:
+	@echo "  CHECK Pyflakes"
+	@pyflakes $(top_srcdir)
+
 check.gdb:
 	EXEC_NAME="gdb --args" $(MAKE) check
 
diff --git a/tests/test_everything.py b/tests/test_everything.py
index 86ddb42..3b06cb9 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -246,7 +246,8 @@ class TestCallbacks(unittest.TestCase):
         """
         def callback():
             x = 1 / 0
-            
+            print x
+
         try:
             Everything.test_simple_callback(callback)
         except ZeroDivisionError:
@@ -259,6 +260,7 @@ class TestCallbacks(unittest.TestCase):
         """
         def badcallback():
             x = 1 / 0
+            print x
 
         def callback():
             Everything.test_boolean(True)
@@ -373,7 +375,7 @@ class TestCallbacks(unittest.TestCase):
             return 42
 
         TestCallbacks.called = False
-        obj_ = Everything.TestObj.new_callback(callbackWithUserData, None)
+        Everything.TestObj.new_callback(callbackWithUserData, None)
         self.assertTrue(TestCallbacks.called)
 
     def test_callback_none(self):
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 98bd361..000264b 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -764,9 +764,6 @@ class TestArray(unittest.TestCase):
     def test_array_zero_terminated_out(self):
         self.assertEquals(['0', '1', '2'], GIMarshallingTests.array_zero_terminated_out())
 
-    def test_array_zero_terminated_out(self):
-        self.assertEquals(['0', '1', '2'], GIMarshallingTests.array_zero_terminated_out())
-
     def test_array_zero_terminated_inout(self):
         self.assertEquals(['-1', '0', '1', '2'], GIMarshallingTests.array_zero_terminated_inout(['0', '1', '2']))
 
@@ -782,9 +779,6 @@ class TestGStrv(unittest.TestCase):
     def test_gstrv_out(self):
         self.assertEquals(['0', '1', '2'], GIMarshallingTests.gstrv_out())
 
-    def test_gstrv_out(self):
-        self.assertEquals(['0', '1', '2'], GIMarshallingTests.gstrv_out())
-
     def test_gstrv_inout(self):
         self.assertEquals(['-1', '0', '1', '2'], GIMarshallingTests.gstrv_inout(['0', '1', '2']))
 
@@ -981,7 +975,7 @@ class TestGHashTable(unittest.TestCase):
     def test_ghashtable_int_none_return(self):
         self.assertEquals({-1: 1, 0: 0, 1: -1, 2: -2}, GIMarshallingTests.ghashtable_int_none_return())
 
-    def test_ghashtable_int_none_return(self):
+    def test_ghashtable_int_none_return2(self):
         self.assertEquals({'-1': '1', '0': '0', '1': '-1', '2': '-2'}, GIMarshallingTests.ghashtable_utf8_none_return())
 
     def test_ghashtable_int_container_return(self):
diff --git a/tests/test_option.py b/tests/test_option.py
index 9233eed..55f651d 100644
--- a/tests/test_option.py
+++ b/tests/test_option.py
@@ -6,6 +6,7 @@ import sys
 # py3k has StringIO in a different module
 try:
     from StringIO import StringIO
+    StringIO  # pyflakes
 except ImportError:
     from io import StringIO
 
@@ -13,8 +14,6 @@ except ImportError:
 from gi._glib.option import OptionParser, OptionGroup, OptionValueError, \
      make_option, BadOptionError
 
-from compathelper import _bytes
-
 class TestOption(unittest.TestCase):
     EXCEPTION_MESSAGE = "This callback fails"
 
@@ -64,20 +63,17 @@ class TestOption(unittest.TestCase):
 
         options, args = self.parser.parse_args(
             ["test_option.py", "foo"])
-        self.assertEquals(args, ["foo"])
+        self.assertEquals(args, [])
 
         options, args = self.parser.parse_args(
             ["test_option.py", "foo", "bar"])
-        self.assertEquals(args, ["foo", "bar"])
+        self.assertEquals(args, [])
 
     def testParseArgsDoubleDash(self):
         options, args = self.parser.parse_args(
             ["test_option.py", "--", "-xxx"])
         #self.assertEquals(args, ["-xxx"])
 
-    def testParseArgs(self):
-        options, args = self.parser.parse_args()
-
     def testParseArgsGroup(self):
         group = self._create_group()
 
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 63433ba..0d4a3b1 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -239,7 +239,7 @@ class TestGLib(unittest.TestCase):
         res = GLib.Variant('v', GLib.Variant.new_int32(-42)).unpack()
         self.assertEqual(res, -42)
 
-        variant = GLib.Variant('v', GLib.Variant('v', GLib.Variant('i', 42)))
+        GLib.Variant('v', GLib.Variant('v', GLib.Variant('i', 42)))
         self.assertEqual(res, -42)
 
         # tuple
@@ -1052,14 +1052,14 @@ class TestGtk(unittest.TestCase):
         for i in range(1, 93):
             label = 'this is row #%d' % i
             testobj = TestGtk.TestClass(self, i, label)
-            parent = list_store.append((i,
-                                        label,
-                                        testobj,
-                                        test_pyobj,
-                                        test_pydict,
-                                        test_pylist,
-                                        i % 2,
-                                        bool(i % 2)))
+            list_store.append((i,
+                               label,
+                               testobj,
+                               test_pyobj,
+                               test_pydict,
+                               test_pylist,
+                               i % 2,
+                               bool(i % 2)))
 
         i = 93
         label = _unicode('this is row #93')
@@ -1529,10 +1529,10 @@ class TestGtk(unittest.TestCase):
 
     def test_tree_view_column(self):
         cell = Gtk.CellRendererText()
-        column = Gtk.TreeViewColumn(title='This is just a test',
-                                    cell_renderer=cell,
-                                    text=0,
-                                    style=2)
+        Gtk.TreeViewColumn(title='This is just a test',
+                           cell_renderer=cell,
+                           text=0,
+                           style=2)
 
     def test_tree_selection(self):
         store = Gtk.ListStore(int, str)
@@ -1846,9 +1846,9 @@ class TestGtk(unittest.TestCase):
 
     def test_iconset(self):
         # PyGTK compat
-        iconset = Gtk.IconSet()
+        Gtk.IconSet()
         pixbuf = GdkPixbuf.Pixbuf()
-        iconset = Gtk.IconSet(pixbuf)
+        Gtk.IconSet(pixbuf)
 
     def test_viewport(self):
         # PyGTK compat
diff --git a/tests/test_properties.py b/tests/test_properties.py
index 7ecdf50..200fd96 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -5,7 +5,7 @@ import struct
 import unittest
 
 from gi.repository import GObject
-from  gi.repository.GObject import GType, GEnum, new, PARAM_READWRITE, \
+from  gi.repository.GObject import GType, new, PARAM_READWRITE, \
      PARAM_CONSTRUCT, PARAM_READABLE, PARAM_WRITABLE, PARAM_CONSTRUCT_ONLY
 from gi.repository.GObject import \
      TYPE_INT, TYPE_UINT, TYPE_LONG, \
@@ -317,7 +317,7 @@ class TestProperty(unittest.TestCase):
             def value(self):
                 return self._value
             @value.setter
-            def value(self, value):
+            def value_setter(self, value):
                 self._value = value
 
         o = C()
@@ -333,7 +333,7 @@ class TestProperty(unittest.TestCase):
             def typedValue(self):
                 return self._value
             @typedValue.setter
-            def typedValue(self, value):
+            def typedValue_setter(self, value):
                 self._value = value
 
         o = C()
@@ -357,8 +357,8 @@ class TestProperty(unittest.TestCase):
         self.assertRaises(TypeError, GObject.Property, flags=-10)
 
     def testDefaults(self):
-        p1 = GObject.Property(type=bool, default=True)
-        p2 = GObject.Property(type=bool, default=False)
+        GObject.Property(type=bool, default=True)
+        GObject.Property(type=bool, default=False)
 
     def testNameWithUnderscore(self):
         class C(GObject.GObject):
@@ -468,7 +468,7 @@ class TestProperty(unittest.TestCase):
         class PropertyObjectSubclass(GObject.GObject):
             obj = GObject.Property(type=ObjectSubclass)
 
-        obj1 = PropertyObjectSubclass(obj=ObjectSubclass())
+        PropertyObjectSubclass(obj=ObjectSubclass())
 
     def testPropertySubclass(self):
         # test for #470718
diff --git a/tests/test_pygtkcompat.py b/tests/test_pygtkcompat.py
index b9765c3..a0bfff6 100644
--- a/tests/test_pygtkcompat.py
+++ b/tests/test_pygtkcompat.py
@@ -4,7 +4,6 @@
 import unittest
 
 import sys
-import os
 sys.path.insert(0, "../")
 
 from gi.repository import Gdk
@@ -15,9 +14,6 @@ import gi.pygtkcompat
 gi.pygtkcompat.enable()
 gi.pygtkcompat.enable_gtk(version='3.0')
 
-import atk
-import pango
-import pangocairo
 import gtk
 import gtk.gdk
 
diff --git a/tests/test_signal.py b/tests/test_signal.py
index 8486adb..57c608d 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -48,7 +48,7 @@ class TestChaining(unittest.TestCase):
         self.inst.emit("my_signal", 42)
         assert self.inst.arg == 42
 
-    def testChaining(self):
+    def testChaining2(self):
         inst2 = D()
         inst2.emit("my_signal", 44)
         assert inst2.arg == 44
@@ -197,7 +197,7 @@ class TestEmissionHook(unittest.TestCase):
         def _emission_hook(obj):
             obj.status += 1
             return False
-        hook_id = GObject.add_emission_hook(obj, "signal", _emission_hook)
+        GObject.add_emission_hook(obj, "signal", _emission_hook)
         obj.emit('signal')
         obj.emit('signal')
         self.assertEqual(obj.status, 3)
diff --git a/tests/test_source.py b/tests/test_source.py
index ad052cc..3dc9c5f 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -90,9 +90,9 @@ class TestSource(unittest.TestCase):
 
 
 class TestTimeout(unittest.TestCase):
-     def test504337(self):
-        timeout_source = GLib.Timeout(20)
-        idle_source = GLib.Idle()
+    def test504337(self):
+        GLib.Timeout(20)
+        GLib.Idle()
 
 
 if __name__ == '__main__':



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]