Skip to content

Commit 5c8b6f5

Browse files
authored
Merge pull request kivy#4827 from kivy/styleissues
pep8 fixes
2 parents 7779e38 + 4c6690b commit 5c8b6f5

File tree

18 files changed

+70
-62
lines changed

18 files changed

+70
-62
lines changed

examples/android/takepicture/main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
.. author:: Mathieu Virbel <[email protected]>
66
77
Little example to demonstrate how to start an Intent, and get the result.
8-
When you use the Android.startActivityForResult(), the result will be dispatched
9-
into onActivityResult. You can catch the event with the android.activity API
10-
from python-for-android project.
8+
When you use the Android.startActivityForResult(), the result will be
9+
dispatched into onActivityResult. You can catch the event with the
10+
android.activity API from python-for-android project.
1111
1212
If you want to compile it, don't forget to add the CAMERA permission::
1313

examples/demo/kivycatalog/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def keyboard_on_key_down(self, window, keycode, text, modifiers):
8181
ctrl, cmd = 64, 1024
8282
key, key_str = keycode
8383

84-
if text and not key in (list(self.interesting_keys.keys()) + [27]):
84+
if text and key not in (list(self.interesting_keys.keys()) + [27]):
8585
# This allows *either* ctrl *or* cmd, but not both.
8686
if modifiers == ['ctrl'] or (is_osx and modifiers == ['meta']):
8787
if key == ord('s'):

examples/demo/multistroke/gesturedatabase.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def unload_gestures(self, *l):
134134
if i.ids.select.state == 'down':
135135
self.selected_count -= 1
136136
for g in i.gesture_list:
137-
# if g in self.recognizer.db: # not needed, for testing
137+
# if g in self.recognizer.db: # not needed, for testing
138138
self.recognizer.db.remove(g)
139139
self.ids.gesture_list.remove_widget(i)
140140

examples/keyboard/main.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Custom Keyboards
33
================
44
5-
This demo shows how to create and display custom keyboards on screen. Note that
6-
the new "input_type" property of the TextInput means that this is rarely needed.
7-
We provide this demo for the sake of completeness.
5+
This demo shows how to create and display custom keyboards on screen.
6+
Note that the new "input_type" property of the TextInput means that this
7+
is rarely needed. We provide this demo for the sake of completeness.
88
"""
99
# Author: Zen-CODE
1010
from kivy.app import App
@@ -18,8 +18,8 @@
1818
from kivy.uix.screenmanager import Screen, ScreenManager
1919
from kivy import require
2020

21-
# This example uses features introduced in Kivy 1.8.0, namely being able to load
22-
# custom json files from the app folder
21+
# This example uses features introduced in Kivy 1.8.0, namely being able
22+
# to load custom json files from the app folder.
2323
require("1.8.0")
2424

2525
Builder.load_string('''
@@ -167,8 +167,8 @@ def _add_keyboards(self):
167167
""" Add a buttons for each available keyboard layout. When clicked,
168168
the buttons will change the keyboard layout to the one selected. """
169169
layouts = list(VKeyboard().available_layouts.keys())
170-
layouts.append("numeric.json") # Add the file in our app directory
171-
# Note the .json extension is required
170+
# Add the file in our app directory, the .json extension is required.
171+
layouts.append("numeric.json")
172172
for key in layouts:
173173
self.kbContainer.add_widget(
174174
Button(

examples/kinect/kinectviewer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@
123123
float dr = th / 10.;
124124
v = min(v, dr) / dr;
125125
126-
// calculate the distance between the center of the square and current pixel
127-
// display the pixel only if the distance is inside the circle
126+
// calculate the distance between the center of the square and current
127+
// pixel; display the pixel only if the distance is inside the circle
128128
float vdist = length(abs(tex_coord0 - center) * size / square);
129129
float value = 1 - v;
130130
if ( vdist < value ) {

examples/shader/shadertree.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def build(self):
196196

197197
def change(*largs):
198198
sw.fs = available_shaders[self.shader_index]
199-
self.shader_index = (self.shader_index + 1) % len(available_shaders)
199+
self.shader_index = ((self.shader_index + 1) %
200+
len(available_shaders))
200201
btn.bind(on_release=change)
201202
root.add_widget(btn)
202203
return root

examples/widgets/lists/fixtures.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
{
6060
'name': 'Cantaloupe',
6161
'Serving Size': '1/4 medium (134 g/4.8 oz)',
62-
'data': [50, 0, 0, 0, 20, 1, 240, 7, 12, 4, 1, 4, 11, 1, 120, 80, 2, 2],
62+
'data': [50, 0, 0, 0, 20, 1, 240, 7, 12, 4, 1, 4, 11, 1, 120,
63+
80, 2, 2],
6364
'is_selected': False},
6465
{
6566
'name': 'Grapefruit',

examples/widgets/lists/fruit_detail_view.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def redraw(self, *args):
104104
container.add_widget(Label(text=self.fruit_name))
105105
for attribute in fruit_data_attributes:
106106
container.add_widget(Label(text="{0}:".format(attribute),
107-
halign='right'))
107+
halign='right'))
108108
container.add_widget(
109-
Label(text=str(fruit_data[self.fruit_name][attribute])))
109+
Label(text=str(fruit_data[self.fruit_name][attribute])))
110110
self.add_widget(container)
111111

112112
def fruit_changed(self, list_adapter, *args):
@@ -118,7 +118,8 @@ def fruit_changed(self, list_adapter, *args):
118118
# [TODO] Would we want touch events for the composite, as well as
119119
# the components? Just the components? Just the composite?
120120
#
121-
# Is selected_object an instance of ThumbnailedListItem (composite)?
121+
# Is selected_object an instance of ThumbnailedListItem
122+
# (composite)?
122123
#
123124
# Or is it a ListItemButton?
124125
#

examples/widgets/lists/list_ops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def update_sel_count_6(self, adapter, *args):
101101
self.sel_count_6 = len(adapter.selection)
102102

103103

104-
letters_dict = \
105-
{l: {'text': l, 'is_selected': False} for l in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
104+
letters_dict = {
105+
l: {'text': l, 'is_selected': False} for l in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
106106

107107
listview_selection_buttons = {}
108108

examples/widgets/unicode_textinput.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class LoadDialog(FloatLayout):
124124
class Unicode_TextInput(BoxLayout):
125125

126126
txt_input = ObjectProperty(None)
127-
unicode_string = StringProperty('''Latin-1 supplement: éé çç ßß
127+
unicode_string = StringProperty("""Latin-1 supplement: éé çç ßß
128128
129129
List of major languages taken from Google Translate
130130
____________________________________________________
@@ -150,11 +150,13 @@ class Unicode_TextInput(BoxLayout):
150150
Estonian: Kiire pruun rebane hüppab üle laisa vana koer.
151151
Filipino: Ang mabilis na brown soro jumps sa ang tamad lumang aso.
152152
Finnish: Nopea ruskea kettu hyppää yli laiska vanha koira.
153-
French: Le renard brun rapide saute par dessus le chien paresseux vieux.
153+
French: Le renard brun rapide saute par dessus le chien
154+
paresseux vieux.
154155
Galician: A lixeira raposo marrón ataca o can preguiceiro de idade.
155156
Gregorian: სწრაფი ყავისფერი მელა jumps გამო ზარმაცი წლის ძაღლი.
156157
German: Der schnelle braune Fuchs springt über den faulen alten Hund.
157-
Greek: Η γρήγορη καφέ αλεπού πηδάει πάνω από το τεμπέλικο γέρικο σκυλί.
158+
Greek: Η γρήγορη καφέ αλεπού πηδάει πάνω από το τεμπέλικο
159+
γέρικο σκυλί.
158160
Gujrati: આ ઝડપી ભુરો શિયાળ તે બેકાર જૂના કૂતરા પર કૂદકા.
159161
Gurmukhi: ਤੇਜ ਭੂਰੇ ਰੰਗ ਦੀ ਲੂੰਬੜੀ ਆਲਸੀ ਬੁੱਢੇ ਕੁੱਤੇ ਦੇ ਉਤੋਂ ਦੀ ਟੱਪਦੀ ਹੈ ।
160162
Hiation Creole: Rapid mawon Rena a so sou chen an parese fin vye granmoun.
@@ -186,15 +188,16 @@ class Unicode_TextInput(BoxLayout):
186188
Spanish: La cigüeña tocaba el saxofón en el viejo perro perezoso.
187189
Swahili: Haraka brown fox anaruka juu ya mbwa wavivu zamani.
188190
Swedish: Den snabba bruna räven hoppar över den lata gammal hund.
189-
Tamil: விரைவான பிரவுன் ஃபாக்ஸ் சோம்பேறி பழைய நாய் மீது தொடரப்படுகிறது
191+
Tamil: விரைவான பிரவுன் ஃபாக்ஸ் சோம்பேறி பழைய நாய் மீது
192+
தொடரப்படுகிறது
190193
Telugu: శీఘ్ర బ్రౌన్ ఫాక్స్ సోమరితనం పాత కుక్క కంటే హెచ్చుతగ్గుల.
191194
Thai: สีน้ำตาลอย่างรวดเร็วจิ้งจอกกระโดดมากกว่าสุนัขเก่าที่ขี้เกียจ
192195
Turkish: Hızlı kahverengi tilki tembel köpeğin üstünden atlar.
193196
Ukranian: Швидкий коричневий лис перестрибує через лінивий старий пес.
194197
Urdu: فوری بھوری لومڑی سست بوڑھے کتے پر کودتا.
195198
Vietnamese: Các con cáo nâu nhanh chóng nhảy qua con chó lười biếng cũ.
196-
Welsh: Mae\'r cyflym frown llwynog neidio dros y ci hen ddiog.
197-
Yiddish: דער גיך ברוין פוקס דזשאַמפּס איבער די פויל אַלט הונט.''')
199+
Welsh: Mae'r cyflym frown llwynog neidio dros y ci hen ddiog.
200+
Yiddish: דער גיך ברוין פוקס דזשאַמפּס איבער די פויל אַלט הונט.""")
198201

199202
def dismiss_popup(self):
200203
self._popup.dismiss()

kivy/adapters/args_converters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
'cls_dicts': [{'cls': ListItemButton,
3838
'kwargs': {'text': rec['text']}},
3939
{'cls': ListItemLabel,
40-
'kwargs': {'text': "Middle-{0}".format(rec['text']),
40+
'kwargs': {'text': rec['text'],
4141
'is_representing_cls': True}},
4242
{'cls': ListItemButton,
4343
'kwargs': {'text': rec['text']}}]}

kivy/adapters/listadapter.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ def create_view(self, index):
248248
if item['is_selected']:
249249
self.handle_selection(view_instance)
250250
elif hasattr(item, 'is_selected'):
251-
if (inspect.isfunction(item.is_selected)
252-
or inspect.ismethod(item.is_selected)):
251+
if (inspect.isfunction(item.is_selected) or
252+
inspect.ismethod(item.is_selected)):
253253
if item.is_selected():
254254
self.handle_selection(view_instance)
255255
else:
@@ -331,8 +331,8 @@ def set_data_item_selection(self, item, value):
331331
elif type(item) == dict:
332332
item['is_selected'] = value
333333
elif hasattr(item, 'is_selected'):
334-
if (inspect.isfunction(item.is_selected)
335-
or inspect.ismethod(item.is_selected)):
334+
if (inspect.isfunction(item.is_selected) or
335+
inspect.ismethod(item.is_selected)):
336336
item.is_selected()
337337
else:
338338
item.is_selected = value

kivy/clock.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,10 @@ def on_schedule(self, event):
642642
return
643643

644644
if not event.timeout or (
645-
not self.interupt_next_only and event.timeout
646-
<= 1 / fps # remaining time
647-
- (self.time() - self._last_tick) # elapsed time
648-
+ 4 / 5. * self.get_resolution()): # resolution fudge factor
645+
not self.interupt_next_only and event.timeout <=
646+
1 / fps - # remaining time
647+
(self.time() - self._last_tick) + # elapsed time
648+
4 / 5. * self.get_resolution()): # resolution fudge factor
649649
self._event.set()
650650

651651
def idle(self):

kivy/core/spelling/spelling_osxappkit.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def suggest(self, fragment):
5757
except AttributeError:
5858
# From 10.6 onwards you're supposed to do it like this:
5959
checkrange = NSMakeRange(0, len(fragment))
60-
g = l.guessesForWordRange_inString_language_inSpellDocumentWithTag_(
61-
checkrange, fragment, l.language(), 0)
60+
g = l.\
61+
guessesForWordRange_inString_language_inSpellDocumentWithTag_(
62+
checkrange, fragment, l.language(), 0)
6263
# Right, this was much easier, Apple! :-)
6364
return list(g)

kivy/geometry.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def circumcircle(a, b, c):
3535
mPQ = (P + Q) * .5
3636
mQR = (Q + R) * .5
3737

38-
numer = -(- mPQ.y * R.y + mPQ.y * Q.y + mQR.y * R.y - mQR.y * Q.y
39-
- mPQ.x * R.x + mPQ.x * Q.x + mQR.x * R.x - mQR.x * Q.x)
38+
numer = -(- mPQ.y * R.y + mPQ.y * Q.y + mQR.y * R.y - mQR.y * Q.y -
39+
mPQ.x * R.x + mPQ.x * Q.x + mQR.x * R.x - mQR.x * Q.x)
4040
denom = (-Q.x * R.y + P.x * R.y - P.x * Q.y +
4141
Q.y * R.x - P.y * R.x + P.y * Q.x)
4242

kivy/interactive.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ def __getattr__(self, attr, oga=object.__getattribute__):
242242
return SafeMembrane(r)
243243

244244
def __setattr__(self, attr, val, osa=object.__setattr__):
245-
if (attr == '_ref'
246-
or hasattr(type(self), attr) and not attr.startswith('__')):
245+
if (attr == '_ref' or
246+
hasattr(type(self), attr) and not attr.startswith('__')):
247247
osa(self, attr, val)
248248
else:
249249
self.safeIn()

kivy/lang/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ class MyWidget(Button):
857857
'''
858858

859859

860-
from kivy.lang.builder import Observable, Builder, BuilderBase, BuilderException
860+
from kivy.lang.builder import (Observable, Builder, BuilderBase,
861+
BuilderException)
861862
from kivy.lang.parser import Parser, ParserException, global_idmap
862863

863864
__all__ = ('Observable', 'Builder', 'BuilderBase', 'BuilderException',

kivy/lang/builder.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -707,25 +707,25 @@ def unbind_widget(self, uid):
707707
708708
.. code-block:: python
709709
710-
>>> w = Builder.load_string(\'''
711-
... Widget:
712-
... height: self.width / 2. if self.disabled else self.width
713-
... x: self.y + 50
714-
... \''')
715-
>>> w.size
716-
[100, 100]
717-
>>> w.pos
718-
[50, 0]
719-
>>> w.width = 500
720-
>>> w.size
721-
[500, 500]
722-
>>> Builder.unbind_widget(w.uid)
723-
>>> w.width = 222
724-
>>> w.y = 500
725-
>>> w.size
726-
[222, 500]
727-
>>> w.pos
728-
[50, 500]
710+
>>> w = Builder.load_string(\'''
711+
... Widget:
712+
... height: self.width / 2. if self.disabled else self.width
713+
... x: self.y + 50
714+
... \''')
715+
>>> w.size
716+
[100, 100]
717+
>>> w.pos
718+
[50, 0]
719+
>>> w.width = 500
720+
>>> w.size
721+
[500, 500]
722+
>>> Builder.unbind_widget(w.uid)
723+
>>> w.width = 222
724+
>>> w.y = 500
725+
>>> w.size
726+
[222, 500]
727+
>>> w.pos
728+
[50, 500]
729729
730730
.. versionadded:: 1.7.2
731731
'''

0 commit comments

Comments
 (0)