Skip to content

Commit

Permalink
Fix flake8 errors from long lines
Browse files Browse the repository at this point in the history
  • Loading branch information
lordmauve committed Nov 15, 2019
1 parent 31b4e4b commit 92909ee
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 88
6 changes: 3 additions & 3 deletions examples/tron/bike.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions pgzero/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion pgzero/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions pgzero/ptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions pgzero/rect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import pygame.rect
import operator


class Rect(pygame.rect.Rect):
Expand Down Expand Up @@ -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__


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions update_ptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
and used under CC0.
"""
# flake8: noqa: E501
'''


Expand Down

0 comments on commit 92909ee

Please sign in to comment.