diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..2bcd70e3 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 88 diff --git a/examples/tron/bike.svg b/examples/tron/bike.svg index a2ab1a38..fe408fa9 100644 --- a/examples/tron/bike.svg +++ b/examples/tron/bike.svg @@ -50,9 +50,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="2.8284271" - inkscape:cx="80.429719" - inkscape:cy="43.353281" + inkscape:zoom="2.6588565" + inkscape:cx="88.327844" + inkscape:cy="34.818811" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" diff --git a/pgzero/animation.py b/pgzero/animation.py index 1a1a81e1..a48f6060 100644 --- a/pgzero/animation.py +++ b/pgzero/animation.py @@ -157,7 +157,10 @@ def __init__(self, object, tween='linear', duration=1, on_finished=None, except KeyError: suggested_tween = suggest(tween, TWEEN_FUNCTIONS.keys()) if len(suggested_tween) > 0: - raise KeyError('No tween called %s found, did you mean %s?' % (tween, suggested_tween[0])) + raise KeyError( + 'No tween called %s found, did you mean %s?' + % (tween, suggested_tween[0]) + ) else: raise KeyError('No tween called %s found.' % tween) self.duration = duration @@ -170,7 +173,9 @@ def __init__(self, object, tween='linear', duration=1, on_finished=None, try: a = getattr(object, k) except AttributeError: - raise ValueError('object %r has no attribute %s to animate' % (object, k)) + raise ValueError( + 'object %r has no attribute %s to animate' % (object, k) + ) self.initial[k] = a key = id(object), k previous_animation = self._animation_dict.get(key) diff --git a/pgzero/clock.py b/pgzero/clock.py index 0c967778..20c3bf1e 100644 --- a/pgzero/clock.py +++ b/pgzero/clock.py @@ -131,7 +131,11 @@ def unschedule(self, callback): If scheduled multiple times all instances will be unscheduled. """ - self.events = [e for e in self.events if e.callback != callback and e.callback is not None] + self.events = [ + e for e in self.events + if e.callback != callback + if e.callback is not None + ] heapq.heapify(self.events) self._each_tick = [e for e in self._each_tick if e() != callback] diff --git a/pgzero/ptext.py b/pgzero/ptext.py index 5aef51fd..30c2c8c9 100644 --- a/pgzero/ptext.py +++ b/pgzero/ptext.py @@ -15,6 +15,7 @@ # Please see README.md for explanation of options. # https://github.com/cosmologicon/pygame-text +# flake8: noqa: E501 from __future__ import division from math import ceil, sin, cos, radians diff --git a/pgzero/rect.py b/pgzero/rect.py index 82f40c3d..6212fb66 100644 --- a/pgzero/rect.py +++ b/pgzero/rect.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pygame.rect +import operator class Rect(pygame.rect.Rect): @@ -27,6 +28,7 @@ def __setattr__(self, key, value): msg += "; did you mean {!r}?".format(suggestions[0]) raise AttributeError(msg) from None + Rect.__doc__ = pygame.rect.Rect.__doc__ @@ -69,7 +71,10 @@ def __init__(self, *args): elif len(args) == 1: self.x, self.y, self.w, self.h = args[0] else: - raise TypeError("%s should be called with one, two or four arguments" % (self.__class__.__name__)) + raise TypeError( + "%s should be called with one, two or four arguments" + % (self.__class__.__name__) + ) self.rect = self @@ -108,7 +113,8 @@ def _handle_one_arg(self, arg): return arg def __repr__(self): - return "<%s (x: %s, y: %s, w: %s, h: %s)>" % (self.__class__.__name__, self.x, self.y, self.w, self.h) + return "<%s (x: %s, y: %s, w: %s, h: %s)>" % ( + self.__class__.__name__, self.x, self.y, self.w, self.h) def __reduce__(self): return self.__class__, (self.x, self.y, self.w, self.h) @@ -492,7 +498,8 @@ def collidedict(self, dict, use_values=True): return k, v def collidedictall(self, dict, use_values=True): - return [(k, v) for (k, v) in dict.items() if self.colliderect(v if use_values else k)] + val = operator.itemgetter(1 if use_values else 0) + return [i for i in dict.items() if self.colliderect(val(i))] RECT_CLASSES = (pygame.rect.Rect, ZRect) diff --git a/update_ptext.py b/update_ptext.py index 2f74d987..f49b889f 100644 --- a/update_ptext.py +++ b/update_ptext.py @@ -25,6 +25,7 @@ and used under CC0. """ +# flake8: noqa: E501 '''