Skip to content

Commit 8b2c97f

Browse files
committed
Apply black
1 parent 30d8562 commit 8b2c97f

File tree

11 files changed

+49
-40
lines changed

11 files changed

+49
-40
lines changed

bpython/autocomplete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def matches(self, cursor_offset, line, **kwargs):
537537
except EvaluationError:
538538
return set()
539539

540-
# strips leading dot
540+
# strips leading dot
541541
matches = [m[1:] for m in self.attr_lookup(obj, "", attr.word)]
542542
return set(m for m in matches if few_enough_underscores(attr.word, m))
543543

bpython/curtsiesfrontend/repl.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ def find_spec(self, fullname, path, target=None):
297297
if spec is not None:
298298
if getattr(spec, "__loader__", None) is not None:
299299
# Patch the loader to enable reloading
300-
spec.__loader__ = ImportLoader(self.watcher, spec.__loader__)
300+
spec.__loader__ = ImportLoader(
301+
self.watcher, spec.__loader__
302+
)
301303
return spec
302304

303305
def find_module(self, fullname, path=None):
@@ -1040,7 +1042,9 @@ def send_session_to_external_editor(self, filename=None):
10401042
current_line = lines[-1][4:]
10411043
else:
10421044
current_line = ""
1043-
from_editor = [line for line in lines if line[:6] != "# OUT:" and line[:3] != "###"]
1045+
from_editor = [
1046+
line for line in lines if line[:6] != "# OUT:" and line[:3] != "###"
1047+
]
10441048
if all(not line.strip() for line in from_editor):
10451049
self.status_bar.message(
10461050
_("Session not reevaluated because saved file was blank")

bpython/curtsiesfrontend/replpainter.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,22 @@ def display_linize(msg, columns, blank_line=False):
2727
2828
Warning: if msg is empty, returns an empty list of lines"""
2929
if not msg:
30-
return [''] if blank_line else []
30+
return [""] if blank_line else []
3131
msg = fmtstr(msg)
3232
try:
3333
display_lines = list(msg.width_aware_splitlines(columns))
3434
# use old method if wcwidth can't determine width of msg
3535
except ValueError:
36-
display_lines = (
37-
[
38-
msg[start:end]
39-
for start, end in zip(
40-
range(0, len(msg), columns),
41-
range(columns, len(msg) + columns, columns),
42-
)
43-
]
44-
)
36+
display_lines = [
37+
msg[start:end]
38+
for start, end in zip(
39+
range(0, len(msg), columns),
40+
range(columns, len(msg) + columns, columns),
41+
)
42+
]
4543
return display_lines
4644

45+
4746
def paint_history(rows, columns, display_lines):
4847
lines = []
4948
for r, line in zip(range(rows), display_lines[-rows:]):

bpython/repl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ class SourceNotFound(Exception):
391391
class LineTypeTranslator(object):
392392
""" Used when adding a tuple to all_logical_lines, to get input / output values
393393
having to actually type/know the strings """
394+
394395
# TODO use Enum once we drop support for Python 2
395396

396397
INPUT = "input"

bpython/simpleeval.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ def _convert(node):
155155
obj = _convert(node.value)
156156
index = _convert(node.slice.value)
157157
return safe_getitem(obj, index)
158-
elif sys.version_info[:2] >= (3, 9) and isinstance(node, ast.Subscript) and isinstance(
159-
node.slice, (ast.Constant, ast.Name)
158+
elif (
159+
sys.version_info[:2] >= (3, 9)
160+
and isinstance(node, ast.Subscript)
161+
and isinstance(node.slice, (ast.Constant, ast.Name))
160162
):
161163
obj = _convert(node.value)
162164
index = _convert(node.slice)

bpython/test/test_args.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ def test_exec_dunder_file(self):
3434
)
3535
f.flush()
3636
p = subprocess.Popen(
37-
[sys.executable]
38-
+ ["-m", "bpython.curtsies", f.name],
37+
[sys.executable] + ["-m", "bpython.curtsies", f.name],
3938
stderr=subprocess.PIPE,
4039
universal_newlines=True,
4140
)

bpython/test/test_autocomplete.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,12 @@ def asserts_when_called(self):
251251
class Slots(object):
252252
__slots__ = ["a", "b"]
253253

254+
254255
class OverriddenGetattribute(Foo):
255-
def __getattribute__(self,name):
256+
def __getattribute__(self, name):
256257
raise AssertionError("custom get attribute invoked")
257258

259+
258260
class TestAttrCompletion(unittest.TestCase):
259261
@classmethod
260262
def setUpClass(cls):
@@ -301,20 +303,18 @@ def test_descriptor_attributes_not_run(self):
301303
com.matches(2, "a.", locals_={"a": Properties()}),
302304
set(["a.b", "a.a", "a.method", "a.asserts_when_called"]),
303305
)
304-
306+
305307
def test_custom_get_attribute_not_invoked(self):
306308
com = autocomplete.AttrCompletion()
307309
self.assertSetEqual(
308310
com.matches(2, "a.", locals_={"a": OverriddenGetattribute()}),
309311
set(["a.b", "a.a", "a.method"]),
310312
)
311313

312-
313314
def test_slots_not_crash(self):
314315
com = autocomplete.AttrCompletion()
315316
self.assertSetEqual(
316-
com.matches(2, "A.", locals_={"A": Slots}),
317-
set(["A.b", "A.a"]),
317+
com.matches(2, "A.", locals_={"A": Slots}), set(["A.b", "A.a"]),
318318
)
319319

320320

bpython/test/test_curtsies_painting.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,32 +271,31 @@ def send_key(self, key):
271271
self.repl.process_event("<SPACE>" if key == " " else key)
272272
self.repl.paint() # has some side effects we need to be wary of
273273

274-
class TestWidthAwareness(HigherLevelCurtsiesPaintingTest):
275274

275+
class TestWidthAwareness(HigherLevelCurtsiesPaintingTest):
276276
def test_cursor_position_with_fullwidth_char(self):
277277
self.repl.add_normal_character("間")
278278

279279
cursor_pos = self.repl.paint()[1]
280-
self.assertEqual(cursor_pos, (0,6))
280+
self.assertEqual(cursor_pos, (0, 6))
281281

282282
def test_cursor_position_with_padding_char(self):
283283
# odd numbered so fullwidth chars don't wrap evenly
284-
self.repl.width = 11
284+
self.repl.width = 11
285285
[self.repl.add_normal_character(c) for c in "width"]
286286

287287
cursor_pos = self.repl.paint()[1]
288-
self.assertEqual(cursor_pos, (1,4))
288+
self.assertEqual(cursor_pos, (1, 4))
289289

290290
def test_display_of_padding_chars(self):
291-
self.repl.width = 11
291+
self.repl.width = 11
292292
[self.repl.add_normal_character(c) for c in "width"]
293293

294294
self.enter()
295-
expected = [
296-
'>>> wid ', # <--- note the added trailing space
297-
'th']
295+
expected = [">>> wid ", "th"] # <--- note the added trailing space
298296
result = [d.s for d in self.repl.display_lines[0:2]]
299-
self.assertEqual(result, expected)
297+
self.assertEqual(result, expected)
298+
300299

301300
class TestCurtsiesRewindRedraw(HigherLevelCurtsiesPaintingTest):
302301
def test_rewind(self):

bpython/test/test_import_not_cyclical.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def setUp(self):
6767
True,
6868
)
6969

70-
self.modules = list(find_modules(os.path.abspath(import_test_folder)))
70+
self.modules = list(
71+
find_modules(os.path.abspath(import_test_folder))
72+
)
7173
self.filepaths = [
7274
"Left.toRight.toLeft",
7375
"Left.toRight",

bpython/test/test_inspection.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,11 @@ def __mro__(self):
204204
raise AssertionError("custom mro executed")
205205

206206
a = 1
207-
207+
208+
208209
member_descriptor = type(Slots.s1)
209210

211+
210212
class TestSafeGetAttribute(unittest.TestCase):
211213
def test_lookup_on_object(self):
212214
a = A()
@@ -222,12 +224,11 @@ def test_lookup_on_object(self):
222224
self.assertEqual(inspection.hasattr_safe(b, "y"), True)
223225
self.assertEqual(inspection.hasattr_safe(b, "b"), True)
224226

225-
226227
def test_avoid_running_properties(self):
227228
p = Property()
228229
self.assertEqual(inspection.getattr_safe(p, "prop"), Property.prop)
229230
self.assertEqual(inspection.hasattr_safe(p, "prop"), True)
230-
231+
231232
def test_lookup_with_slots(self):
232233
s = Slots()
233234
s.s1 = "s1"
@@ -269,10 +270,14 @@ def test_lookup_on_overridden_methods(self):
269270
with self.assertRaises(AttributeError):
270271
sga(OverriddenMRO(), "b")
271272

272-
self.assertEqual(inspection.hasattr_safe(OverriddenGetattr(), "b"), False)
273-
self.assertEqual(inspection.hasattr_safe(OverriddenGetattribute(), "b"), False)
273+
self.assertEqual(
274+
inspection.hasattr_safe(OverriddenGetattr(), "b"), False
275+
)
276+
self.assertEqual(
277+
inspection.hasattr_safe(OverriddenGetattribute(), "b"), False
278+
)
274279
self.assertEqual(inspection.hasattr_safe(OverriddenMRO(), "b"), False)
275-
280+
276281

277282
if __name__ == "__main__":
278283
unittest.main()

bpython/test/test_simpleeval.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,5 @@ def test_with_namespace(self):
133133
self.assertCannotEval("a[1].a|bc", {})
134134

135135

136-
137-
138136
if __name__ == "__main__":
139137
unittest.main()

0 commit comments

Comments
 (0)