Skip to content

Commit c85c4e7

Browse files
committed
Fix PEP8 issues
1 parent 0ff009e commit c85c4e7

11 files changed

+113
-87
lines changed

bpython/_internal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __repr__(self):
2727
def __call__(self, *args, **kwargs):
2828
self.helper(*args, **kwargs)
2929

30+
3031
_help = _Helper()
3132

3233

bpython/_py3compat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,3 @@ def is_main_thread():
7676
else:
7777
def is_main_thread():
7878
return isinstance(threading.current_thread(), threading._MainThread)
79-

bpython/cli.py

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252

5353
import struct
5454
if platform.system() != 'Windows':
55-
import signal #Windows does not have job control
56-
import termios #Windows uses curses
57-
import fcntl #Windows uses curses
55+
import signal # Windows does not have job control
56+
import termios # Windows uses curses
57+
import fcntl # Windows uses curses
5858
import unicodedata
5959
import errno
6060

@@ -112,6 +112,7 @@ def calculate_screen_lines(tokens, width, cursor=0):
112112
pos %= width
113113
return lines
114114

115+
115116
def forward_if_not_current(func):
116117
@functools.wraps(func)
117118
def newfunc(self, *args, **kwargs):
@@ -202,7 +203,7 @@ def readline(self, size=-1):
202203
# C-d
203204
return ''
204205
elif (key not in ('\n', '\r') and
205-
(len(key) > 1 or unicodedata.category(key) == 'Cc')):
206+
(len(key) > 1 or unicodedata.category(key) == 'Cc')):
206207
continue
207208
sys.stdout.write(key)
208209
# Include the \n in the buffer - raw_input() seems to deal with trailing
@@ -281,7 +282,7 @@ def make_colors(config):
281282

282283
if platform.system() == 'Windows':
283284
c = dict(list(c.items()) +
284-
[
285+
[
285286
('K', 8),
286287
('R', 9),
287288
('G', 10),
@@ -290,8 +291,8 @@ def make_colors(config):
290291
('M', 13),
291292
('C', 14),
292293
('W', 15),
293-
]
294-
)
294+
]
295+
)
295296

296297
for i in range(63):
297298
if i > 7:
@@ -316,7 +317,6 @@ def confirm(self, q):
316317

317318
return reply.lower() in (_('y'), _('yes'))
318319

319-
320320
def notify(self, s, n=10, wait_for_keypress=False):
321321
return self.statusbar.message(s, n)
322322

@@ -350,6 +350,7 @@ def __init__(self, scr, interp, statusbar, config, idle=None):
350350

351351
def _get_cursor_offset(self):
352352
return len(self.s) - self.cpos
353+
353354
def _set_cursor_offset(self, offset):
354355
self.cpos = len(self.s) - offset
355356
cursor_offset = property(_get_cursor_offset, _set_cursor_offset, None,
@@ -427,7 +428,7 @@ def check(self):
427428
it and force syntax highlighting."""
428429

429430
if (self.paste_mode
430-
and time.time() - self.last_key_press > self.config.paste_time):
431+
and time.time() - self.last_key_press > self.config.paste_time):
431432
self.paste_mode = False
432433
self.print_line(self.s)
433434

@@ -454,7 +455,7 @@ def complete(self, tab=False):
454455
with tab
455456
"""
456457
if self.paste_mode:
457-
self.scr.touchwin() #TODO necessary?
458+
self.scr.touchwin() # TODO necessary?
458459
return
459460

460461
list_win_visible = repl.Repl.complete(self, tab)
@@ -489,6 +490,7 @@ def clrtobol(self):
489490

490491
def _get_current_line(self):
491492
return self.s
493+
492494
def _set_current_line(self, line):
493495
self.s = line
494496
current_line = property(_get_current_line, _set_current_line, None,
@@ -716,7 +718,7 @@ def mkargspec(self, topline, in_arg, down):
716718

717719
self.list_win.addstr('\n ')
718720
self.list_win.addstr(fn,
719-
get_colpair(self.config, 'name') | curses.A_BOLD)
721+
get_colpair(self.config, 'name') | curses.A_BOLD)
720722
self.list_win.addstr(': (', get_colpair(self.config, 'name'))
721723
maxh = self.scr.getmaxyx()[0]
722724

@@ -765,7 +767,7 @@ def mkargspec(self, topline, in_arg, down):
765767
if kw is not None:
766768
self.list_win.addstr('=', punctuation_colpair)
767769
self.list_win.addstr(kw, get_colpair(self.config, 'token'))
768-
if k != len(args) -1:
770+
if k != len(args) - 1:
769771
self.list_win.addstr(', ', punctuation_colpair)
770772

771773
if _args:
@@ -854,7 +856,7 @@ def p_key(self, key):
854856
key = '\n'
855857
# Don't return; let it get handled
856858

857-
if key == chr(27): #Escape Key
859+
if key == chr(27): # Escape Key
858860
return ''
859861

860862
if key in (BACKSP, 'KEY_BACKSPACE'):
@@ -894,7 +896,7 @@ def p_key(self, key):
894896
self.fwd()
895897
return ''
896898

897-
elif key in ("KEY_LEFT",' ^B', chr(2)): # Cursor Left or ^B
899+
elif key in ("KEY_LEFT", ' ^B', chr(2)): # Cursor Left or ^B
898900
self.mvc(1)
899901
# Redraw (as there might have been highlighted parens)
900902
self.print_line(self.s)
@@ -914,11 +916,11 @@ def p_key(self, key):
914916
# Redraw (as there might have been highlighted parens)
915917
self.print_line(self.s)
916918

917-
elif key in ("KEY_NPAGE", '\T'): # page_down or \T
919+
elif key in ("KEY_NPAGE", '\T'): # page_down or \T
918920
self.hend()
919921
self.print_line(self.s)
920922

921-
elif key in ("KEY_PPAGE", '\S'): # page_up or \S
923+
elif key in ("KEY_PPAGE", '\S'): # page_up or \S
922924
self.hbegin()
923925
self.print_line(self.s)
924926

@@ -1065,7 +1067,8 @@ def print_line(self, s, clr=False, newline=False):
10651067
def prompt(self, more):
10661068
"""Show the appropriate Python prompt"""
10671069
if not more:
1068-
self.echo("\x01%s\x03%s" % (self.config.color_scheme['prompt'], self.ps1))
1070+
self.echo("\x01%s\x03%s" %
1071+
(self.config.color_scheme['prompt'], self.ps1))
10691072
if py3:
10701073
self.stdout_hist += self.ps1
10711074
else:
@@ -1079,7 +1082,8 @@ def prompt(self, more):
10791082
self.stdout_hist += self.ps2
10801083
else:
10811084
self.stdout_hist += self.ps2.encode(getpreferredencoding())
1082-
self.s_hist.append('\x01%s\x03%s\x04' % (prompt_more_color, self.ps2))
1085+
self.s_hist.append('\x01%s\x03%s\x04' %
1086+
(prompt_more_color, self.ps2))
10831087

10841088
def push(self, s, insert_into_history=True):
10851089
# curses.raw(True) prevents C-c from causing a SIGINT
@@ -1103,7 +1107,7 @@ def redraw(self):
11031107
self.iy, self.ix = self.scr.getyx()
11041108
for i in s.split('\x04'):
11051109
self.echo(i, redraw=False)
1106-
if k < len(self.s_hist) -1:
1110+
if k < len(self.s_hist) - 1:
11071111
self.scr.addstr('\n')
11081112
self.iy, self.ix = self.scr.getyx()
11091113
self.print_line(self.s)
@@ -1186,14 +1190,12 @@ def resize(self):
11861190
self.statusbar.resize(refresh=False)
11871191
self.redraw()
11881192

1189-
11901193
def getstdout(self):
11911194
"""This method returns the 'spoofed' stdout buffer, for writing to a
11921195
file or sending to a pastebin or whatever."""
11931196

11941197
return self.stdout_hist + '\n'
11951198

1196-
11971199
def reevaluate(self):
11981200
"""Clear the buffer, redraw the screen and re-evaluate the history"""
11991201

@@ -1234,7 +1236,7 @@ def reevaluate(self):
12341236

12351237
self.evaluating = False
12361238
#map(self.push, self.history)
1237-
#^-- That's how simple this method was at first :(
1239+
# ^-- That's how simple this method was at first :(
12381240

12391241
def write(self, s):
12401242
"""For overriding stdout defaults"""
@@ -1258,7 +1260,6 @@ def write(self, s):
12581260
self.echo(s)
12591261
self.s_hist.append(s.rstrip())
12601262

1261-
12621263
def show_list(self, items, arg_pos, topline=None, formatter=None, current_item=None):
12631264

12641265
shared = Struct()
@@ -1345,7 +1346,7 @@ def lsize():
13451346
self.list_win.resize(rows + 2, w)
13461347
else:
13471348
docstring = self.format_docstring(self.docstring, max_w - 2,
1348-
max_h - height_offset)
1349+
max_h - height_offset)
13491350
docstring_string = ''.join(docstring)
13501351
rows += len(docstring)
13511352
self.list_win.resize(rows, max_w)
@@ -1445,7 +1446,7 @@ def tab(self, back=False):
14451446

14461447
# 3. check to see if we can expand the current word
14471448
if self.matches_iter.is_cseq():
1448-
#TODO resolve this error-prone situation:
1449+
# TODO resolve this error-prone situation:
14491450
# can't assign at same time to self.s and self.cursor_offset
14501451
# because for cursor_offset
14511452
# property to work correctly, self.s must already be set
@@ -1458,7 +1459,7 @@ def tab(self, back=False):
14581459
# 4. swap current word for a match list item
14591460
elif self.matches_iter.matches:
14601461
current_match = back and self.matches_iter.previous() \
1461-
or next(self.matches_iter)
1462+
or next(self.matches_iter)
14621463
try:
14631464
self.show_list(self.matches_iter.matches, self.arg_pos,
14641465
topline=self.funcprops,
@@ -1500,7 +1501,7 @@ def send_current_line_to_editor(self):
15001501
return ''
15011502

15021503
self.f_string = ''
1503-
self.cpos = -1 # Set cursor position to -1 to prevent paren matching
1504+
self.cpos = -1 # Set cursor position to -1 to prevent paren matching
15041505

15051506
self.iy, self.ix = self.scr.getyx()
15061507
self.evaluating = True
@@ -1531,6 +1532,7 @@ def send_current_line_to_editor(self):
15311532
self.scr.redrawwin()
15321533
return ''
15331534

1535+
15341536
class Statusbar(object):
15351537
"""This class provides the status bar at the bottom of the screen.
15361538
It has message() and prompt() methods for user interactivity, as
@@ -1687,7 +1689,7 @@ def clear(self):
16871689
def init_wins(scr, config):
16881690
"""Initialise the two windows (the main repl interface and the little
16891691
status bar at the bottom with some stuff in it)"""
1690-
#TODO: Document better what stuff is on the status bar.
1692+
# TODO: Document better what stuff is on the status bar.
16911693

16921694
background = get_colpair(config, 'background')
16931695
h, w = gethw()
@@ -1719,11 +1721,13 @@ def sigwinch(unused_scr):
17191721
global DO_RESIZE
17201722
DO_RESIZE = True
17211723

1724+
17221725
def sigcont(unused_scr):
17231726
sigwinch(unused_scr)
17241727
# Forces the redraw
17251728
curses.ungetch('\x00')
17261729

1730+
17271731
def gethw():
17281732
"""I found this code on a usenet post, and snipped out the bit I needed,
17291733
so thanks to whoever wrote that, sorry I forgot your name, I'm sure you're
@@ -1761,7 +1765,8 @@ def gethw():
17611765
sizex = right - left + 1
17621766
sizey = bottom - top + 1
17631767
else:
1764-
sizex, sizey = stdscr.getmaxyx()# can't determine actual size - return default values
1768+
# can't determine actual size - return default values
1769+
sizex, sizey = stdscr.getmaxyx()
17651770

17661771
h, w = sizey, sizex
17671772
return h, w
@@ -1796,7 +1801,7 @@ def do_resize(caller):
17961801
global DO_RESIZE
17971802
h, w = gethw()
17981803
if not h:
1799-
# Hopefully this shouldn't happen. :)
1804+
# Hopefully this shouldn't happen. :)
18001805
return
18011806

18021807
curses.endwin()
@@ -1878,7 +1883,8 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
18781883
old_sigwinch_handler = signal.signal(signal.SIGWINCH,
18791884
lambda *_: sigwinch(scr))
18801885
# redraw window after being suspended
1881-
old_sigcont_handler = signal.signal(signal.SIGCONT, lambda *_: sigcont(scr))
1886+
old_sigcont_handler = signal.signal(
1887+
signal.SIGCONT, lambda *_: sigcont(scr))
18821888

18831889
stdscr = scr
18841890
try:
@@ -1951,7 +1957,6 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
19511957
def main(args=None, locals_=None, banner=None):
19521958
translations.init()
19531959

1954-
19551960
config, options, exec_args = argsparse(args)
19561961

19571962
# Save stdin, stdout and stderr for later restoration
@@ -1975,6 +1980,7 @@ def main(args=None, locals_=None, banner=None):
19751980
sys.stdout.flush()
19761981
return repl.extract_exit_value(exit_value)
19771982

1983+
19781984
if __name__ == '__main__':
19791985
sys.exit(main())
19801986

bpython/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ def get_key_no_doublebind(command):
183183
struct.hist_length = config.getint('general', 'hist_length')
184184
struct.hist_duplicates = config.getboolean('general', 'hist_duplicates')
185185
struct.flush_output = config.getboolean('general', 'flush_output')
186-
struct.default_autoreload = config.getboolean('general', 'default_autoreload')
186+
struct.default_autoreload = config.getboolean(
187+
'general', 'default_autoreload')
187188

188189
struct.pastebin_key = get_key_no_doublebind('pastebin')
189190
struct.copy_clipboard_key = get_key_no_doublebind('copy_clipboard')

bpython/curtsies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def main(args=None, locals_=None, banner=None, welcome_message=None):
139139
help=_("log debug messages to bpython.log")),
140140
Option('--paste', '-p', action='store_true',
141141
help=_("start by pasting lines of a file into session")),
142-
]))
142+
]))
143143
if options.log is None:
144144
options.log = 0
145145
logging_levels = [logging.ERROR, logging.INFO, logging.DEBUG]

bpython/importcompletion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,5 @@ def reload():
205205
for _ in find_all_modules():
206206
pass
207207

208+
208209
find_iterator = find_all_modules()

bpython/line.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
LinePart = namedtuple('LinePart', ['start', 'stop', 'word'])
1616

1717
current_word_re = LazyReCompile(
18-
r'(?<![)\]\w_.])'
19-
r'([\w_][\w0-9._]*[(]?)')
18+
r'(?<![)\]\w_.])'
19+
r'([\w_][\w0-9._]*[(]?)')
2020

2121

2222
def current_word(cursor_offset, line):
@@ -222,7 +222,7 @@ def current_dotted_attribute(cursor_offset, line):
222222

223223

224224
current_expression_attribute_re = LazyReCompile(
225-
r'[.]\s*((?:[\w_][\w0-9_]*)|(?:))')
225+
r'[.]\s*((?:[\w_][\w0-9_]*)|(?:))')
226226

227227

228228
def current_expression_attribute(cursor_offset, line):

bpython/patch_linecache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def remember_bpython_input(self, source):
3434
a fake filename to use to retrieve it later."""
3535
filename = '<bpython-input-%s>' % len(self.bpython_history)
3636
self.bpython_history.append((len(source), None,
37-
source.splitlines(True), filename))
37+
source.splitlines(True), filename))
3838
return filename
3939

4040
def __getitem__(self, key):

0 commit comments

Comments
 (0)