Commit 6695931a authored by Christoph Reiter's avatar Christoph Reiter 🐍

Fix new PEP8 errors

Two new errors popped up:

* E305 expected 2 blank lines after class or function definition
* E741 ambiguous variable name

https://bugzilla.gnome.org/show_bug.cgi?id=776009
parent 3f68e0a3
......@@ -126,5 +126,6 @@ def main():
win.show_all()
Gtk.main()
if __name__ == '__main__':
main()
......@@ -13,6 +13,7 @@ class MyObject(GObject.GObject):
def readonly(self):
return 'readonly'
GObject.type_register(MyObject)
print("MyObject properties: ", list(MyObject.props))
......
......@@ -368,4 +368,5 @@ class OptionParser(optparse.OptionParser):
args = args[2:-len(old_args)]
return options, args
make_option = Option
......@@ -41,6 +41,7 @@ class OverridesStruct(GIMarshallingTests.OverridesStruct):
def method(self):
return GIMarshallingTests.OverridesStruct.method(self) / 7
OverridesStruct = override(OverridesStruct)
__all__.append('OverridesStruct')
......@@ -66,5 +67,6 @@ class OverridesObject(GIMarshallingTests.OverridesObject):
"""Overridden doc string."""
return GIMarshallingTests.OverridesObject.method(self) / 7
OverridesObject = override(OverridesObject)
__all__.append('OverridesObject')
......@@ -477,6 +477,7 @@ def get_string(self):
value, length = GLib.Variant.get_string(self)
return value
setattr(Variant, 'get_string', get_string)
__all__.append('Variant')
......@@ -487,6 +488,8 @@ def markup_escape_text(text, length=-1):
return GLib.markup_escape_text(text.decode('UTF-8'), length)
else:
return GLib.markup_escape_text(text, length)
__all__.append('markup_escape_text')
......@@ -585,6 +588,7 @@ class MainLoop(GLib.MainLoop):
# caught by _main_loop_sigint_handler()
raise KeyboardInterrupt
MainLoop = override(MainLoop)
__all__.append('MainLoop')
......@@ -594,6 +598,7 @@ class MainContext(GLib.MainContext):
def iteration(self, may_block=True):
return super(MainContext, self).iteration(may_block)
MainContext = override(MainContext)
__all__.append('MainContext')
......@@ -643,6 +648,7 @@ class Source(GLib.Source):
can_recurse = property(__get_can_recurse, __set_can_recurse)
Source = override(Source)
__all__.append('Source')
......@@ -658,6 +664,7 @@ class Idle(Source):
if priority != GLib.PRIORITY_DEFAULT:
self.set_priority(priority)
__all__.append('Idle')
......@@ -671,6 +678,7 @@ class Timeout(Source):
if priority != GLib.PRIORITY_DEFAULT:
self.set_priority(priority)
__all__.append('Timeout')
......@@ -679,6 +687,7 @@ def idle_add(function, *user_data, **kwargs):
priority = kwargs.get('priority', GLib.PRIORITY_DEFAULT_IDLE)
return GLib.idle_add(priority, function, *user_data)
__all__.append('idle_add')
......@@ -686,6 +695,7 @@ def timeout_add(interval, function, *user_data, **kwargs):
priority = kwargs.get('priority', GLib.PRIORITY_DEFAULT)
return GLib.timeout_add(priority, interval, function, *user_data)
__all__.append('timeout_add')
......@@ -693,6 +703,7 @@ def timeout_add_seconds(interval, function, *user_data, **kwargs):
priority = kwargs.get('priority', GLib.PRIORITY_DEFAULT)
return GLib.timeout_add_seconds(priority, interval, function, *user_data)
__all__.append('timeout_add_seconds')
......@@ -750,6 +761,7 @@ def _io_add_watch_get_args(channel, priority_, condition, *cb_and_user_data, **k
return real_channel, priority_, condition, func_fdtransform, user_data
__all__.append('_io_add_watch_get_args')
......@@ -758,6 +770,7 @@ def io_add_watch(*args, **kwargs):
channel, priority, condition, func, user_data = _io_add_watch_get_args(*args, **kwargs)
return GLib.io_add_watch(channel, priority, condition, func, *user_data)
__all__.append('io_add_watch')
......@@ -839,6 +852,7 @@ class IOChannel(GLib.IOChannel):
# Python 2.x compatibility
next = __next__
IOChannel = override(IOChannel)
__all__.append('IOChannel')
......@@ -853,6 +867,7 @@ class PollFD(GLib.PollFD):
self.fd = fd
self.events = events
PollFD = override(PollFD)
__all__.append('PollFD')
......@@ -900,6 +915,7 @@ def _child_watch_add_get_args(priority_or_pid, pid_or_callback, *args, **kwargs)
return priority, pid, callback, user_data
# we need this to be accessible for unit testing
__all__.append('_child_watch_add_get_args')
......@@ -909,12 +925,14 @@ def child_watch_add(*args, **kwargs):
priority, pid, function, data = _child_watch_add_get_args(*args, **kwargs)
return GLib.child_watch_add(priority, pid, function, *data)
__all__.append('child_watch_add')
def get_current_time():
return GLib.get_real_time() * 0.000001
get_current_time = deprecated(get_current_time, 'GLib.get_real_time()')
__all__.append('get_current_time')
......@@ -925,6 +943,7 @@ __all__.append('get_current_time')
def filename_from_utf8(utf8string, len=-1):
return GLib.filename_from_utf8(utf8string, len)[0]
__all__.append('filename_from_utf8')
......
......@@ -351,6 +351,7 @@ class Value(GObjectModule.Value):
def __repr__(self):
return '<Value (%s) %s>' % (self.g_type.name, self.get_value())
Value = override(Value)
__all__.append('Value')
......@@ -361,6 +362,7 @@ def type_from_name(name):
raise RuntimeError('unknown type name: %s' % name)
return type_
__all__.append('type_from_name')
......@@ -370,6 +372,7 @@ def type_parent(type_):
raise RuntimeError('no parent for type')
return parent
__all__.append('type_parent')
......@@ -384,6 +387,7 @@ def signal_list_ids(type_):
_validate_type_for_signal_method(type_)
return GObjectModule.signal_list_ids(type_)
__all__.append('signal_list_ids')
......@@ -391,6 +395,7 @@ def signal_list_names(type_):
ids = signal_list_ids(type_)
return tuple(GObjectModule.signal_name(i) for i in ids)
__all__.append('signal_list_names')
......@@ -398,6 +403,7 @@ def signal_lookup(name, type_):
_validate_type_for_signal_method(type_)
return GObjectModule.signal_lookup(name, type_)
__all__.append('signal_lookup')
......@@ -430,6 +436,7 @@ def signal_query(id_or_name, type_=None):
res.signal_flags, res.return_type,
tuple(res.param_types))
__all__.append('signal_query')
......@@ -465,6 +472,7 @@ def signal_handler_block(obj, handler_id):
GObjectModule.signal_handler_block(obj, handler_id)
return _HandlerBlockManager(obj, handler_id)
__all__.append('signal_handler_block')
......@@ -486,6 +494,7 @@ def signal_parse_name(detailed_signal, itype, force_detail_quark):
else:
raise ValueError('%s: unknown signal name: %s' % (itype, detailed_signal))
__all__.append('signal_parse_name')
......@@ -493,6 +502,7 @@ def remove_emission_hook(obj, detailed_signal, hook_id):
signal_id, detail = signal_parse_name(detailed_signal, obj, True)
GObjectModule.signal_remove_emission_hook(signal_id, hook_id)
__all__.append('remove_emission_hook')
......@@ -503,6 +513,7 @@ def signal_accumulator_first_wins(ihint, return_accu, handler_return, user_data=
# Stop emission but return the result of the last handler
return (False, handler_return)
__all__.append('signal_accumulator_first_wins')
......@@ -510,6 +521,7 @@ def signal_accumulator_true_handled(ihint, return_accu, handler_return, user_dat
# Stop emission if the last handler returns True
return (not handler_return, handler_return)
__all__.append('signal_accumulator_true_handled')
......
......@@ -77,6 +77,7 @@ class Color(Gdk.Color):
int(green * Color.MAX_VALUE),
int(blue * Color.MAX_VALUE))
Color = override(Color)
__all__.append('Color')
......@@ -243,6 +244,7 @@ class Event(Gdk.Event):
base_repr = Gdk.Event.__repr__(self).strip("><")
return "<%s type=%r>" % (base_repr, self.type)
Event = override(Event)
__all__.append('Event')
......@@ -312,6 +314,7 @@ class DragContext(Gdk.DragContext):
Gtk = get_introspection_module('Gtk')
Gtk.drag_finish(self, success, del_, time)
DragContext = override(DragContext)
__all__.append('DragContext')
......
......@@ -116,6 +116,7 @@ class Settings(Gio.Settings):
def keys(self):
return self.list_keys()
Settings = override(Settings)
__all__.append('Settings')
......@@ -235,5 +236,6 @@ class DBusProxy(Gio.DBusProxy):
def __getattr__(self, name):
return _DBusProxyMethodCall(self, name)
DBusProxy = override(DBusProxy)
__all__.append('DBusProxy')
......@@ -53,6 +53,7 @@ python module to use with Gtk 2.0"
class PyGTKDeprecationWarning(PyGIDeprecationWarning):
pass
__all__.append('PyGTKDeprecationWarning')
......@@ -69,6 +70,7 @@ def _construct_target_list(targets):
target_entries.append(entry)
return target_entries
__all__.append('_construct_target_list')
......@@ -404,6 +406,7 @@ if Gtk._version in ("2.0", "3.0"):
class ComboBox(Gtk.ComboBox, Container):
get_active_iter = strip_boolean_result(Gtk.ComboBox.get_active_iter)
ComboBox = override(ComboBox)
__all__.append('ComboBox')
......@@ -413,6 +416,7 @@ class Box(Gtk.Box):
arg_names=('homogeneous', 'spacing'),
category=PyGTKDeprecationWarning)
Box = override(Box)
__all__.append('Box')
......@@ -423,6 +427,7 @@ class SizeGroup(Gtk.SizeGroup):
deprecated_defaults={'mode': Gtk.SizeGroupMode.VERTICAL},
category=PyGTKDeprecationWarning)
SizeGroup = override(SizeGroup)
__all__.append('SizeGroup')
......@@ -432,6 +437,7 @@ class MenuItem(Gtk.MenuItem):
arg_names=('label',),
category=PyGTKDeprecationWarning)
MenuItem = override(MenuItem)
__all__.append('MenuItem')
......@@ -467,6 +473,7 @@ class Builder(Gtk.Builder):
return Gtk.Builder.add_objects_from_string(self, buffer, length, object_ids)
Builder = override(Builder)
__all__.append('Builder')
......@@ -480,6 +487,7 @@ class Window(Gtk.Window):
arg_names=('type',),
category=PyGTKDeprecationWarning)
Window = override(Window)
__all__.append('Window')
......@@ -566,6 +574,7 @@ class Dialog(Gtk.Dialog, Container):
except (IndexError):
raise TypeError('Must pass an even number of arguments')
Dialog = override(Dialog)
__all__.append('Dialog')
......@@ -586,6 +595,7 @@ class MessageDialog(Gtk.MessageDialog, Dialog):
self.set_property('secondary-use-markup', True)
self.set_property('secondary-text', message_format)
MessageDialog = override(MessageDialog)
__all__.append('MessageDialog')
......@@ -605,6 +615,7 @@ class FileChooserDialog(Gtk.FileChooserDialog):
arg_names=('title', 'parent', 'action', 'buttons'),
category=PyGTKDeprecationWarning)
FileChooserDialog = override(FileChooserDialog)
__all__.append('FileChooserDialog')
......@@ -627,6 +638,7 @@ class RecentChooserDialog(Gtk.RecentChooserDialog):
deprecated_aliases={'recent_manager': 'manager'},
category=PyGTKDeprecationWarning)
RecentChooserDialog = override(RecentChooserDialog)
__all__.append('RecentChooserDialog')
......@@ -640,6 +652,7 @@ class IconView(Gtk.IconView):
get_visible_range = strip_boolean_result(Gtk.IconView.get_visible_range)
get_dest_item_at_pos = strip_boolean_result(Gtk.IconView.get_dest_item_at_pos)
IconView = override(IconView)
__all__.append('IconView')
......@@ -649,6 +662,7 @@ class ToolButton(Gtk.ToolButton):
arg_names=('stock_id',),
category=PyGTKDeprecationWarning)
ToolButton = override(ToolButton)
__all__.append('ToolButton')
......@@ -656,6 +670,7 @@ __all__.append('ToolButton')
class IMContext(Gtk.IMContext):
get_surrounding = strip_boolean_result(Gtk.IMContext.get_surrounding)
IMContext = override(IMContext)
__all__.append('IMContext')
......@@ -663,6 +678,7 @@ __all__.append('IMContext')
class RecentInfo(Gtk.RecentInfo):
get_application_info = strip_boolean_result(Gtk.RecentInfo.get_application_info)
RecentInfo = override(RecentInfo)
__all__.append('RecentInfo')
......@@ -750,6 +766,7 @@ class TextBuffer(Gtk.TextBuffer):
get_selection_bounds = strip_boolean_result(Gtk.TextBuffer.get_selection_bounds, fail_ret=())
TextBuffer = override(TextBuffer)
__all__.append('TextBuffer')
......@@ -758,6 +775,7 @@ class TextIter(Gtk.TextIter):
forward_search = strip_boolean_result(Gtk.TextIter.forward_search)
backward_search = strip_boolean_result(Gtk.TextIter.backward_search)
TextIter = override(TextIter)
__all__.append('TextIter')
......@@ -924,6 +942,7 @@ class TreeSortable(Gtk.TreeSortable, ):
def set_default_sort_func(self, sort_func, user_data=None):
super(TreeSortable, self).set_default_sort_func(sort_func, user_data)
TreeSortable = override(TreeSortable)
__all__.append('TreeSortable')
......@@ -933,6 +952,7 @@ class TreeModelSort(Gtk.TreeModelSort):
arg_names=('model',),
category=PyGTKDeprecationWarning)
TreeModelSort = override(TreeModelSort)
__all__.append('TreeModelSort')
......@@ -1017,6 +1037,7 @@ class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
else:
raise TypeError('Argument list must be in the form of (column, value, ...), ((columns,...), (values, ...)) or {column: value}. No -1 termination is needed.')
ListStore = override(ListStore)
__all__.append('ListStore')
......@@ -1123,6 +1144,7 @@ class TreeModelRow(object):
child_iter = self.model.iter_children(self.iter)
return TreeModelRowIter(self.model, child_iter)
__all__.append('TreeModelRow')
......@@ -1145,6 +1167,7 @@ class TreeModelRowIter(object):
def __iter__(self):
return self
__all__.append('TreeModelRowIter')
......@@ -1196,6 +1219,7 @@ class TreePath(Gtk.TreePath):
def __getitem__(self, index):
return self.get_indices()[index]
TreePath = override(TreePath)
__all__.append('TreePath')
......@@ -1275,6 +1299,7 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
else:
raise TypeError('Argument list must be in the form of (column, value, ...), ((columns,...), (values, ...)) or {column: value}. No -1 termination is needed.')
TreeStore = override(TreeStore)
__all__.append('TreeStore')
......@@ -1321,6 +1346,7 @@ class TreeView(Gtk.TreeView, Container):
self.insert_column(column, position)
column.set_attributes(cell, **kwargs)
TreeView = override(TreeView)
__all__.append('TreeView')
......@@ -1402,6 +1428,7 @@ class Button(Gtk.Button, Container):
else:
self._init(*args, **kwargs)
Button = override(Button)
__all__.append('Button')
......@@ -1411,6 +1438,7 @@ class LinkButton(Gtk.LinkButton):
arg_names=('uri', 'label'),
category=PyGTKDeprecationWarning)
LinkButton = override(LinkButton)
__all__.append('LinkButton')
......@@ -1420,6 +1448,7 @@ class Label(Gtk.Label):
arg_names=('label',),
category=PyGTKDeprecationWarning)
Label = override(Label)
__all__.append('Label')
......@@ -1442,6 +1471,7 @@ class Adjustment(Gtk.Adjustment):
if 'value' in kwargs:
self.set_value(kwargs['value'])
Adjustment = override(Adjustment)
__all__.append('Adjustment')
......@@ -1465,6 +1495,7 @@ class ScrolledWindow(Gtk.ScrolledWindow):
arg_names=('hadjustment', 'vadjustment'),
category=PyGTKDeprecationWarning)
ScrolledWindow = override(ScrolledWindow)
__all__.append('ScrolledWindow')
......@@ -1494,6 +1525,7 @@ class Paned(Gtk.Paned):
def pack2(self, child, resize=True, shrink=True):
super(Paned, self).pack2(child, resize, shrink)
Paned = override(Paned)
__all__.append('Paned')
......@@ -1530,6 +1562,7 @@ class Viewport(Gtk.Viewport):
arg_names=('hadjustment', 'vadjustment'),
category=PyGTKDeprecationWarning)
Viewport = override(Viewport)
__all__.append('Viewport')
......@@ -1543,6 +1576,7 @@ class TreeModelFilter(Gtk.TreeModelFilter):
iter = self.convert_iter_to_child_iter(iter)
self.get_model().set_value(iter, column, value)
TreeModelFilter = override(TreeModelFilter)
__all__.append('TreeModelFilter')
......@@ -1560,6 +1594,7 @@ _Gtk_main_quit = Gtk.main_quit
def main_quit(*args):
_Gtk_main_quit()
if Gtk._version in ("2.0", "3.0"):
stock_lookup = strip_boolean_result(Gtk.stock_lookup)
__all__.append('stock_lookup')
......
......@@ -37,6 +37,7 @@ class FontDescription(Pango.FontDescription):
def __init__(self, *args, **kwargs):
return super(FontDescription, self).__init__()
FontDescription = override(FontDescription)
__all__.append('FontDescription')
......@@ -49,5 +50,6 @@ class Layout(Pango.Layout):
def set_markup(self, text, length=-1):
super(Layout, self).set_markup(text, length)
Layout = override(Layout)
__all__.append('Layout')
......@@ -204,6 +204,7 @@ class _GObjectMetaBase(type):
_gobject.type_register(cls, namespace.get('__gtype_name__'))
_gobject._install_metaclass(_GObjectMetaBase)
......
......@@ -99,6 +99,7 @@ def enable():
from gi.repository import Gio
sys.modules['gio'] = Gio
_unset = object()
......
......@@ -415,5 +415,6 @@ class TestReturnsAfterError(unittest.TestCase):
res = self.model.iter_parent(child)
self.assertEqual(res, None)
if __name__ == '__main__':
unittest.main()
......@@ -20,6 +20,8 @@ class MyUnknown(Unknown, testhelper.Interface):
def do_iface_method(self):
self.called = True
Unknown.do_iface_method(self)
GObject.type_register(MyUnknown)
......@@ -32,6 +34,8 @@ class MyObject(GObject.GObject, testhelper.Interface):
def do_iface_method(self):
self.called = True
GObject.type_register(MyObject)
......
......@@ -423,5 +423,6 @@ second line
self.assertEqual(GLib.IOFlags.IS_SEEKABLE, GLib.IO_FLAG_IS_SEEKABLE)
self.assertEqual(GLib.IOStatus.NORMAL, GLib.IO_STATUS_NORMAL)
if __name__ == '__main__':
unittest.main()
......@@ -76,8 +76,8 @@ class TestGtk(unittest.TestCase):
self.assertTrue(label2 in box)
self.assertEqual(len(box), 2)
self.assertTrue(box)
l = [x for x in box]
self.assertEqual(l, [label, label2])
labels = [x for x in box]
self.assertEqual(labels, [label, label2])
def test_actions(self):
self.assertEqual(Gtk.Action, gi.overrides.Gtk.Action)
......@@ -615,9 +615,9 @@ class TestGtk(unittest.TestCase):
self.assertEqual(viewport.props.hadjustment, hadjustment)
def test_stock_lookup(self):
l = Gtk.stock_lookup('gtk-ok')
self.assertEqual(type(l), Gtk.StockItem)
self.assertEqual(l.stock_id, 'gtk-ok')
stock_item = Gtk.stock_lookup('gtk-ok')
self.assertEqual(type(stock_item), Gtk.StockItem)
self.assertEqual(stock_item.stock_id, 'gtk-ok')
self.assertEqual(Gtk.stock_lookup('nosuchthing'), None)
def test_gtk_main(self):
......
......@@ -1137,9 +1137,9 @@ class CPropertiesTestBase(object):
def test_boxed_glist(self):
self.assertEqual(self.get_prop(self.obj, 'some-boxed-glist'), [])
l = [GLib.MININT, 42, GLib.MAXINT]
self.set_prop(self.obj, 'some-boxed-glist', l)
self.assertEqual(self.get_prop(self.obj, 'some-boxed-glist'), l)
list_ = [GLib.MININT, 42, GLib.MAXINT]
self.set_prop(self.obj, 'some-boxed-glist', list_)
self.assertEqual(self.get_prop(self.obj, 'some-boxed-glist'), list_)
self.set_prop(self.obj, 'some-boxed-glist', [])
self.assertEqual(self.get_prop(self.obj, 'some-boxed-glist'), [])
......@@ -1158,9 +1158,9 @@ class CPropertiesTestBase(object):
@unittest.expectedFailure
def test_boxed_glist_ctor(self):
l = [GLib.MININT, 42, GLib.MAXINT]
obj = GIMarshallingTests.PropertiesObject(some_boxed_glist=l)
self.assertEqual(self.get_prop(obj, 'some-boxed-glist'), l)
list_ = [GLib.MININT, 42, GLib.MAXINT]
obj = GIMarshallingTests.PropertiesObject(some_boxed_glist=list_)
self.assertEqual(self.get_prop(obj, 'some-boxed-glist'), list_)
def test_variant(self):
self.assertEqual(self.get_prop(self.obj, 'some-variant'), None)
......
......@@ -659,6 +659,7 @@ class _TestCMarshaller:
self.assertEqual(self.obj.emit("test-gvalue-ret", GObject.TYPE_STRING),
"hello")
if 'generic-c-marshaller' in GObject.features:
class TestCMarshaller(_TestCMarshaller, unittest.TestCase):
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment