From 8b54df31efb1eba3948933c6a7e48b8c466cca42 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 23 Oct 2017 17:33:57 +0530 Subject: [PATCH] Fix new pep8 ambiguous name warning --- kitty/tabs.py | 4 +- kitty_tests/datatypes.py | 102 +++++++++++++++++++-------------------- kitty_tests/graphics.py | 20 ++++---- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/kitty/tabs.py b/kitty/tabs.py index 7e267cb6c..3d569cb30 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -49,8 +49,8 @@ class Tab: # {{{ setattr(self, which + '_window', partial(self.nth_window, num=i)) if session_tab is None: self.cwd = args.directory - l = self.enabled_layouts[0] - self.current_layout = all_layouts[l](opts, borders.border_width, self.windows) + sl = self.enabled_layouts[0] + self.current_layout = all_layouts[sl](opts, borders.border_width, self.windows) if special_window is None: self.new_window() else: diff --git a/kitty_tests/datatypes.py b/kitty_tests/datatypes.py index ba3aa9e1f..12a044f16 100644 --- a/kitty_tests/datatypes.py +++ b/kitty_tests/datatypes.py @@ -62,9 +62,9 @@ class TestDataTypes(BaseTest): self.ae(lb.line(3), lb2.line(1)) self.ae(lb.line(4), lb2.line(4)) self.ae(lb.create_line_copy(1), lb2.line(2)) - l = lb.create_line_copy(2) - lb.copy_line_to(1, l) - self.ae(l, lb2.line(2)) + l2 = lb.create_line_copy(2) + lb.copy_line_to(1, l2) + self.ae(l2, lb2.line(2)) lb.clear_line(0) self.ae(lb.line(0), LineBuf(1, lb.xnum).create_line_copy(0)) lb = filled_line_buf(5, 5, filled_cursor()) @@ -124,11 +124,11 @@ class TestDataTypes(BaseTest): self.ae(lb.line(4), clb.line(4)) lb = filled_line_buf(5, 5, filled_cursor()) - l = lb.line(0) - l.add_combining_char(1, 'a') - l.clear_text(1, 2) - self.ae(str(l), '0 00') - self.assertEqualAttributes(l.cursor_from(1), l.cursor_from(0)) + l0 = lb.line(0) + l0.add_combining_char(1, 'a') + l0.clear_text(1, 2) + self.ae(str(l0), '0 00') + self.assertEqualAttributes(l0.cursor_from(1), l0.cursor_from(0)) lb = filled_line_buf(10, 10, filled_cursor()) lb.clear() @@ -187,68 +187,68 @@ class TestDataTypes(BaseTest): t = '0123456789' lb = LineBuf(1, len(t)) - l = lb.line(0) - l.set_text(t, 0, len(t), C()) - self.ae(t, str(l)) - l.right_shift(4, 2) - self.ae('0123454567', str(l)) - l.set_text(t, 0, len(t), C()) - l.right_shift(0, 0) - self.ae(t, str(l)) - l.right_shift(0, 1) - self.ae(str(l), '0' + t[:-1]) - l.set_text(t, 0, len(t), C()) - l.left_shift(0, 2) - self.ae(str(l), t[2:] + '89') - l.set_text(t, 0, len(t), C()) - l.left_shift(7, 3) - self.ae(str(l), t) + l3 = lb.line(0) + l3.set_text(t, 0, len(t), C()) + self.ae(t, str(l3)) + l3.right_shift(4, 2) + self.ae('0123454567', str(l3)) + l3.set_text(t, 0, len(t), C()) + l3.right_shift(0, 0) + self.ae(t, str(l3)) + l3.right_shift(0, 1) + self.ae(str(l3), '0' + t[:-1]) + l3.set_text(t, 0, len(t), C()) + l3.left_shift(0, 2) + self.ae(str(l3), t[2:] + '89') + l3.set_text(t, 0, len(t), C()) + l3.left_shift(7, 3) + self.ae(str(l3), t) - l.set_text(t, 0, len(t), C()) + l3.set_text(t, 0, len(t), C()) q = C() q.bold = q.italic = q.reverse = q.strikethrough = True q.decoration = 2 c = C() c.x = 3 - l.set_text('axyb', 1, 2, c) - self.ae(str(l), '012xy56789') - l.set_char(0, 'x', 1, q) - self.assertEqualAttributes(l.cursor_from(0), q) + l3.set_text('axyb', 1, 2, c) + self.ae(str(l3), '012xy56789') + l3.set_char(0, 'x', 1, q) + self.assertEqualAttributes(l3.cursor_from(0), q) def test_url_at(self): def create(t): lb = create.lb = LineBuf(1, len(t)) - l = lb.line(0) - l.set_text(t, 0, len(t), C()) - return l + lf = lb.line(0) + lf.set_text(t, 0, len(t), C()) + return lf for trail in '.,]>)\\': - l = create("http://xyz.com" + trail) - self.ae(l.url_end_at(0), len(l) - 2) + lx = create("http://xyz.com" + trail) + self.ae(lx.url_end_at(0), len(lx) - 2) l = create("ftp://abc/") self.ae(l.url_end_at(0), len(l) - 1) - l = create("http://-abcd] ") - self.ae(l.url_end_at(0), len(l) - 3) + l2 = create("http://-abcd] ") + self.ae(l2.url_end_at(0), len(l2) - 3) def lspace_test(n, scheme='http'): - l = create(' ' * n + scheme + '://acme.com') + lf = create(' ' * n + scheme + '://acme.com') for i in range(0, n): - self.ae(l.url_start_at(i), len(l)) - for i in range(n, len(l)): - self.ae(l.url_start_at(i), n) + self.ae(lf.url_start_at(i), len(lf)) + for i in range(n, len(lf)): + self.ae(lf.url_start_at(i), n) for i in range(7): for scheme in 'http https ftp file'.split(): lspace_test(i) - l = create('b https://testing.me a') - for s in (0, 1, len(l) - 1, len(l) - 2): - self.ae(l.url_start_at(s), len(l), 'failed with start at: %d' % s) - for s in range(2, len(l) - 2): - self.ae(l.url_start_at(s), 2, 'failed with start at: %d (%s)' % (s, str(l)[s:])) + l3 = create('b https://testing.me a') + for s in (0, 1, len(l3) - 1, len(l3) - 2): + self.ae(l3.url_start_at(s), len(l3), 'failed with start at: %d' % s) + for s in range(2, len(l3) - 2): + self.ae(l3.url_start_at(s), 2, 'failed with start at: %d (%s)' % (s, str(l3)[s:])) def no_url(t): - l = create(t) - for s in range(len(l)): - self.ae(l.url_start_at(s), len(l)) + lf = create(t) + for s in range(len(lf)): + self.ae(lf.url_start_at(s), len(lf)) no_url('https:// testing.me a') no_url('h ttp://acme.com') no_url('http: //acme.com') @@ -387,14 +387,14 @@ class TestDataTypes(BaseTest): a = [] lb.as_ansi(a.append) self.ae(a, ['\x1b[0m' + str(lb.line(i)) + '\n' for i in range(lb.ynum)]) - l = lb.line(0) + l2 = lb.line(0) c = C() c.bold = c.italic = c.reverse = c.strikethrough = True c.fg = (4 << 8) | 1 c.bg = (1 << 24) | (2 << 16) | (3 << 8) | 2 c.decoration_fg = (5 << 8) | 1 - l.set_text('1', 0, 1, c) - self.ae(l.as_ansi(), '\x1b[0m\x1b[1m\x1b[3m\x1b[7m\x1b[9m\x1b[38;5;4m\x1b[48;2;1;2;3m\x1b[58;5;5m' '1' + l2.set_text('1', 0, 1, c) + self.ae(l2.as_ansi(), '\x1b[0m\x1b[1m\x1b[3m\x1b[7m\x1b[9m\x1b[38;5;4m\x1b[48;2;1;2;3m\x1b[58;5;5m' '1' '\x1b[22m\x1b[23m\x1b[27m\x1b[29m\x1b[39m\x1b[49m\x1b[59m' '0000') lb = filled_line_buf() for i in range(lb.ynum): diff --git a/kitty_tests/graphics.py b/kitty_tests/graphics.py index 82da1915c..a4c316597 100644 --- a/kitty_tests/graphics.py +++ b/kitty_tests/graphics.py @@ -60,7 +60,7 @@ def load_helpers(self): s = self.create_screen() g = s.grman - def l(payload, **kw): + def pl(payload, **kw): kw.setdefault('i', 1) cmd = ','.join('%s=%s' % (k, v) for k, v in kw.items()) res = send_command(s, cmd, payload) @@ -71,7 +71,7 @@ def load_helpers(self): payload = payload.encode('utf-8') data = kw.pop('expecting_data', payload) cid = kw.setdefault('i', 1) - self.ae('OK', l(payload, **kw)) + self.ae('OK', pl(payload, **kw)) img = g.image_for_client_id(cid) self.ae(img['client_id'], cid) self.ae(img['data'], data) @@ -80,7 +80,7 @@ def load_helpers(self): self.ae(img['is_4byte_aligned'], kw.get('f') != 24) return img - return s, g, l, sl + return s, g, pl, sl def put_helpers(self, cw, ch): @@ -218,14 +218,14 @@ class TestGraphics(BaseTest): self.ae(l[0]['group_count'], 1) self.ae(s.cursor.x, 1), self.ae(s.cursor.y, 0) put_ref(s, num_cols=s.columns, x_off=2, y_off=1, width=3, height=5, cell_x_off=3, cell_y_off=1, z=-1) - l = layers(s) - self.ae(len(l), 2) - rect_eq(l[0]['src_rect'], 2 / 10, 1 / 20, (2 + 3) / 10, (1 + 5)/20) + l2 = layers(s) + self.ae(len(l2), 2) + rect_eq(l2[0]['src_rect'], 2 / 10, 1 / 20, (2 + 3) / 10, (1 + 5)/20) left, top = -1 + dx + 3 * dx / cw, 1 - 1 * dy / ch - rect_eq(l[0]['dest_rect'], left, top, -1 + (1 + s.columns) * dx, top - dy * 5 / ch) - rect_eq(l[1]['src_rect'], 0, 0, 1, 1) - rect_eq(l[1]['dest_rect'], -1, 1, -1 + dx, 1 - dy) - self.ae(l[0]['group_count'], 1), self.ae(l[1]['group_count'], 1) + rect_eq(l2[0]['dest_rect'], left, top, -1 + (1 + s.columns) * dx, top - dy * 5 / ch) + rect_eq(l2[1]['src_rect'], 0, 0, 1, 1) + rect_eq(l2[1]['dest_rect'], -1, 1, -1 + dx, 1 - dy) + self.ae(l2[0]['group_count'], 1), self.ae(l2[1]['group_count'], 1) self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 1) def test_gr_scroll(self):