Skip to content

Commit 2c3c84f

Browse files
committed
Simplify parsekeywordpairs
1 parent bd880f9 commit 2c3c84f

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

bpython/inspection.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
class AttrCleaner:
5353
"""A context manager that tries to make an object not exhibit side-effects
54-
on attribute lookup."""
54+
on attribute lookup."""
5555

5656
def __init__(self, obj):
5757
self.obj = obj
@@ -126,9 +126,9 @@ def parsekeywordpairs(signature):
126126
continue
127127

128128
if token is Token.Punctuation:
129-
if value in ["(", "{", "["]:
129+
if value in ("(", "{", "["):
130130
parendepth += 1
131-
elif value in [")", "}", "]"]:
131+
elif value in (")", "}", "]"):
132132
parendepth -= 1
133133
elif value == ":" and parendepth == -1:
134134
# End of signature reached
@@ -143,11 +143,7 @@ def parsekeywordpairs(signature):
143143
if value and (parendepth > 0 or value.strip()):
144144
substack.append(value)
145145

146-
d = {}
147-
for item in stack:
148-
if len(item) >= 3:
149-
d[item[0]] = "".join(item[2:])
150-
return d
146+
return {item[0]: "".join(item[2:] for item in stack if len(item) >= 3)}
151147

152148

153149
def fixlongargs(f, argspec):

0 commit comments

Comments
 (0)