Skip to content

Commit be8737c

Browse files
committed
Use tuples instead of lists
1 parent ea44aec commit be8737c

File tree

6 files changed

+17
-23
lines changed

6 files changed

+17
-23
lines changed

bpython/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def readline(self, size=-1):
190190
try:
191191
while not buffer.endswith(("\n", "\r")):
192192
key = self.interface.get_key()
193-
if key in [curses.erasechar(), "KEY_BACKSPACE"]:
193+
if key in (curses.erasechar(), "KEY_BACKSPACE"):
194194
y, x = self.interface.scr.getyx()
195195
if buffer:
196196
self.interface.scr.delch(y, x - 1)

bpython/curtsiesfrontend/interaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def process_event(self, e):
8787
for ee in e.events:
8888
# strip control seq
8989
self.add_normal_character(ee if len(ee) == 1 else ee[-1])
90-
elif e in ["<ESC>"] or isinstance(e, events.SigIntEvent):
90+
elif e == "<ESC>" or isinstance(e, events.SigIntEvent):
9191
self.request_context.switch(False)
9292
self.escape()
9393
elif e in edit_keys:

bpython/curtsiesfrontend/repl.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ def process_event(self, e):
136136
self.repl.run_code_and_maybe_finish()
137137
elif e in ("<Esc+.>",):
138138
self.get_last_word()
139-
140-
elif e in ["<ESC>"]:
139+
elif e in ("<ESC>",):
141140
pass
142-
elif e in ["<Ctrl-d>"]:
141+
elif e in ("<Ctrl-d>",):
143142
if self.current_line == "":
144143
self.repl.send_to_stdin("\n")
145144
self.has_focus = False
@@ -148,7 +147,7 @@ def process_event(self, e):
148147
self.repl.run_code_and_maybe_finish(for_code="")
149148
else:
150149
pass
151-
elif e in ["\n", "\r", "<Ctrl-j>", "<Ctrl-m>"]:
150+
elif e in ("\n", "\r", "<Ctrl-j>", "<Ctrl-m>"):
152151
line = self.current_line
153152
self.repl.send_to_stdin(line + "\n")
154153
self.has_focus = False
@@ -164,7 +163,7 @@ def process_event(self, e):
164163
self.repl.send_to_stdin(self.current_line)
165164

166165
def add_input_character(self, e):
167-
if e == "<SPACE>":
166+
if e in ("<SPACE>",):
168167
e = " "
169168
if e.startswith("<") and e.endswith(">"):
170169
return
@@ -763,7 +762,7 @@ def process_key_event(self, e):
763762
raise SystemExit()
764763
elif e in ("\n", "\r", "<PADENTER>", "<Ctrl-j>", "<Ctrl-m>"):
765764
self.on_enter()
766-
elif e == "<TAB>": # tab
765+
elif e in ("<TAB>",): # tab
767766
self.on_tab()
768767
elif e in ("<Shift-TAB>",):
769768
self.on_tab(back=True)
@@ -784,9 +783,9 @@ def process_key_event(self, e):
784783
# TODO add PAD keys hack as in bpython.cli
785784
elif e in key_dispatch[self.config.edit_current_block_key]:
786785
self.send_current_block_to_external_editor()
787-
elif e in ["<ESC>"]:
786+
elif e in ("<ESC>",):
788787
self.incr_search_mode = None
789-
elif e in ["<SPACE>"]:
788+
elif e in ("<SPACE>",):
790789
self.add_normal_character(" ")
791790
else:
792791
self.add_normal_character(e)
@@ -969,7 +968,7 @@ def process_simple_keypress(self, e):
969968
self.process_event(bpythonevents.RefreshRequestEvent())
970969
elif isinstance(e, events.Event):
971970
pass # ignore events
972-
elif e == "<SPACE>":
971+
elif e in ("<SPACE>",):
973972
self.add_normal_character(" ")
974973
else:
975974
self.add_normal_character(e)
@@ -2013,11 +2012,11 @@ def key_help_text(self):
20132012
["complete history suggestion", "right arrow at end of line"]
20142013
)
20152014
pairs.append(["previous match with current line", "up arrow"])
2016-
for functionality, key in [
2015+
for functionality, key in (
20172016
(attr[:-4].replace("_", " "), getattr(self.config, attr))
20182017
for attr in self.config.__dict__
20192018
if attr.endswith("key")
2020-
]:
2019+
):
20212020
if functionality in NOT_IMPLEMENTED:
20222021
key = "Not Implemented"
20232022
if key == "":
@@ -2070,7 +2069,7 @@ def just_simple_events(event_list):
20702069
simple_events.append("\n")
20712070
elif isinstance(e, events.Event):
20722071
pass # ignore events
2073-
elif e == "<SPACE>":
2072+
elif e in ("<SPACE>",):
20742073
simple_events.append(" ")
20752074
elif len(e) > 1:
20762075
pass # get rid of <Ctrl-a> etc.

bpython/lazyre.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23-
2423
import re
2524

2625

bpython/repl.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323

24-
2524
import code
2625
import inspect
2726
import os
@@ -40,9 +39,7 @@
4039

4140
from pygments.token import Token
4241
from pygments.lexers import Python3Lexer
43-
44-
from . import autocomplete
45-
from . import inspection
42+
from . import autocomplete, inspection, simpleeval
4643
from .clipboard import get_clipboard, CopyFailed
4744
from .config import getpreferredencoding
4845
from .formatter import Parenthesis
@@ -51,7 +48,6 @@
5148
from .paste import PasteHelper, PastePinnwand, PasteFailed
5249
from .patch_linecache import filename_for_console_input
5350
from .translations import _, ngettext
54-
from . import simpleeval
5551

5652

5753
class RuntimeTimer:
@@ -1206,7 +1202,7 @@ def next_token_inside_string(code_string, inside_string):
12061202
for token, value in Python3Lexer().get_tokens(code_string):
12071203
if token is Token.String:
12081204
value = value.lstrip("bBrRuU")
1209-
if value in ['"""', "'''", '"', "'"]:
1205+
if value in ('"""', "'''", '"', "'"):
12101206
if not inside_string:
12111207
inside_string = value
12121208
elif value == inside_string:

bpython/urwid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def move_cursor_to_coords(self, *args):
393393
return False
394394

395395
def keypress(self, size, key):
396-
if urwid.command_map[key] in ["cursor up", "cursor down"]:
396+
if urwid.command_map[key] in ("cursor up", "cursor down"):
397397
# Do not handle up/down arrow, leave them for the repl.
398398
return key
399399

@@ -452,7 +452,7 @@ class BPythonListBox(urwid.ListBox):
452452
"""
453453

454454
def keypress(self, size, key):
455-
if key not in ["up", "down"]:
455+
if key not in ("up", "down"):
456456
return urwid.ListBox.keypress(self, size, key)
457457
return key
458458

0 commit comments

Comments
 (0)