Skip to content

Commit 59c4cb8

Browse files
Black, removed six usage.
1 parent f4a4675 commit 59c4cb8

34 files changed

+1693
-1413
lines changed

pymux/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
from __future__ import unicode_literals

pymux/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""
22
Make sure `python -m pymux` works.
33
"""
4-
from __future__ import unicode_literals
54
from .entry_points.run_pymux import run
65

7-
if __name__ == '__main__':
6+
if __name__ == "__main__":
87
run()

pymux/arrangement.py

Lines changed: 76 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,46 @@
77
An arrangement consists of a list of windows. And a window has a list of panes,
88
arranged by ordering them in HSplit/VSplit instances.
99
"""
10-
from __future__ import unicode_literals
11-
12-
from ptterm import Terminal
13-
from prompt_toolkit.application.current import get_app, get_app_or_none, set_app
14-
from prompt_toolkit.buffer import Buffer
15-
1610
import math
1711
import os
1812
import weakref
19-
import six
13+
from typing import Optional
14+
15+
from prompt_toolkit.application.current import get_app, get_app_or_none, set_app
16+
from prompt_toolkit.buffer import Buffer
17+
from ptterm import Terminal
2018

2119
__all__ = (
22-
'LayoutTypes',
23-
'Pane',
24-
'HSplit',
25-
'VSplit',
26-
'Window',
27-
'Arrangement',
20+
"LayoutTypes",
21+
"Pane",
22+
"HSplit",
23+
"VSplit",
24+
"Window",
25+
"Arrangement",
2826
)
2927

3028

3129
class LayoutTypes:
3230
# The values are in lowercase with dashes, because that is what users can
3331
# use at the command line.
34-
EVEN_HORIZONTAL = 'even-horizontal'
35-
EVEN_VERTICAL = 'even-vertical'
36-
MAIN_HORIZONTAL = 'main-horizontal'
37-
MAIN_VERTICAL = 'main-vertical'
38-
TILED = 'tiled'
32+
EVEN_HORIZONTAL = "even-horizontal"
33+
EVEN_VERTICAL = "even-vertical"
34+
MAIN_HORIZONTAL = "main-horizontal"
35+
MAIN_VERTICAL = "main-vertical"
36+
TILED = "tiled"
3937

4038
_ALL = [EVEN_HORIZONTAL, EVEN_VERTICAL, MAIN_HORIZONTAL, MAIN_VERTICAL, TILED]
4139

4240

43-
class Pane(object):
41+
class Pane:
4442
"""
4543
One pane, containing one process and a search buffer for going into copy
4644
mode or displaying the help.
4745
"""
48-
_pane_counter = 1000 # Start at 1000, to be sure to not confuse this with pane indexes.
46+
47+
_pane_counter = (
48+
1000 # Start at 1000, to be sure to not confuse this with pane indexes.
49+
)
4950

5051
def __init__(self, terminal=None):
5152
assert isinstance(terminal, Terminal)
@@ -68,7 +69,7 @@ def __init__(self, terminal=None):
6869
self.scroll_buffer = Buffer(read_only=True)
6970
self.copy_get_tokens_for_line = lambda lineno: []
7071
self.display_scroll_buffer = False
71-
self.scroll_buffer_title = ''
72+
self.scroll_buffer_title = ""
7273

7374
@property
7475
def process(self):
@@ -88,7 +89,7 @@ def name(self):
8889
if name:
8990
return os.path.basename(name)
9091

91-
return ''
92+
return ""
9293

9394
def enter_copy_mode(self):
9495
"""
@@ -114,6 +115,7 @@ class _WeightsDictionary(weakref.WeakKeyDictionary):
114115
This dictionary maps the child (another HSplit/VSplit or Pane), to the
115116
size. (Integer.)
116117
"""
118+
117119
def __getitem__(self, key):
118120
try:
119121
# (Don't use 'super' here. This is a classobj in Python2.)
@@ -127,6 +129,7 @@ class _Split(list):
127129
Base class for horizontal and vertical splits. (This is a higher level
128130
split than prompt_toolkit.layout.HSplit.)
129131
"""
132+
130133
def __init__(self, *a, **kw):
131134
list.__init__(self, *a, **kw)
132135

@@ -138,7 +141,7 @@ def __hash__(self):
138141
return id(self)
139142

140143
def __repr__(self):
141-
return '%s(%s)' % (self.__class__.__name__, list.__repr__(self))
144+
return "%s(%s)" % (self.__class__.__name__, list.__repr__(self))
142145

143146

144147
class HSplit(_Split):
@@ -153,6 +156,7 @@ class Window(object):
153156
"""
154157
Pymux window.
155158
"""
159+
156160
_window_counter = 1000 # Start here, to avoid confusion with window index.
157161

158162
def __init__(self, index=0):
@@ -178,24 +182,27 @@ def invalidation_hash(self):
178182
Return a hash (string) that can be used to determine when the layout
179183
has to be rebuild.
180184
"""
181-
# if not self.root:
182-
# return '<empty-window>'
185+
# if not self.root:
186+
# return '<empty-window>'
183187

184188
def _hash_for_split(split):
185189
result = []
186190
for item in split:
187191
if isinstance(item, (VSplit, HSplit)):
188192
result.append(_hash_for_split(item))
189193
elif isinstance(item, Pane):
190-
result.append('p%s' % item.pane_id)
194+
result.append("p%s" % item.pane_id)
191195

192196
if isinstance(split, HSplit):
193-
return 'HSplit(%s)' % (','.join(result))
197+
return "HSplit(%s)" % (",".join(result))
194198
else:
195-
return 'VSplit(%s)' % (','.join(result))
199+
return "VSplit(%s)" % (",".join(result))
196200

197-
return '<window_id=%s,zoom=%s,children=%s>' % (
198-
self.window_id, self.zoom, _hash_for_split(self.root))
201+
return "<window_id=%s,zoom=%s,children=%s>" % (
202+
self.window_id,
203+
self.zoom,
204+
_hash_for_split(self.root),
205+
)
199206

200207
@property
201208
def active_pane(self):
@@ -240,7 +247,7 @@ def name(self):
240247
if pane:
241248
return pane.name
242249

243-
return ''
250+
return ""
244251

245252
def add_pane(self, pane, vsplit=False):
246253
"""
@@ -354,7 +361,9 @@ def focus_next(self, count=1):
354361
" Focus the next pane. "
355362
panes = self.panes
356363
if panes:
357-
self.active_pane = panes[(panes.index(self.active_pane) + count) % len(panes)]
364+
self.active_pane = panes[
365+
(panes.index(self.active_pane) + count) % len(panes)
366+
]
358367
else:
359368
self.active_pane = None # No panes left.
360369

@@ -381,10 +390,10 @@ def rotate(self, count=1, with_pane_before_only=False, with_pane_after_only=Fals
381390

382391
# Only before after? Reduce list of panes.
383392
if with_pane_before_only:
384-
items = items[current_pane_index - 1:current_pane_index + 1]
393+
items = items[current_pane_index - 1 : current_pane_index + 1]
385394

386395
elif with_pane_after_only:
387-
items = items[current_pane_index:current_pane_index + 2]
396+
items = items[current_pane_index : current_pane_index + 2]
388397

389398
# Rotate positions.
390399
for i, triple in enumerate(items):
@@ -417,22 +426,26 @@ def select_layout(self, layout_type):
417426

418427
# main-horizontal.
419428
elif layout_type == LayoutTypes.MAIN_HORIZONTAL:
420-
self.root = HSplit([
421-
self.active_pane,
422-
VSplit([p for p in self.panes if p != self.active_pane])
423-
])
429+
self.root = HSplit(
430+
[
431+
self.active_pane,
432+
VSplit([p for p in self.panes if p != self.active_pane]),
433+
]
434+
)
424435

425436
# main-vertical.
426437
elif layout_type == LayoutTypes.MAIN_VERTICAL:
427-
self.root = VSplit([
428-
self.active_pane,
429-
HSplit([p for p in self.panes if p != self.active_pane])
430-
])
438+
self.root = VSplit(
439+
[
440+
self.active_pane,
441+
HSplit([p for p in self.panes if p != self.active_pane]),
442+
]
443+
)
431444

432445
# tiled.
433446
elif layout_type == LayoutTypes.TILED:
434447
panes = self.panes
435-
column_count = math.ceil(len(panes) ** .5)
448+
column_count = math.ceil(len(panes) ** 0.5)
436449

437450
rows = HSplit()
438451
current_row = VSplit()
@@ -495,9 +508,11 @@ def find_split_and_child(split_cls, is_before):
495508
split = self._get_parent(child)
496509

497510
def found():
498-
return isinstance(split, split_cls) and (
499-
not is_before or split.index(child) > 0) and (
500-
is_before or split.index(child) < len(split) - 1)
511+
return (
512+
isinstance(split, split_cls)
513+
and (not is_before or split.index(child) > 0)
514+
and (is_before or split.index(child) < len(split) - 1)
515+
)
501516

502517
while split and not found():
503518
child = split
@@ -532,8 +547,9 @@ def handle_side(split_cls, is_before, amount, trying_other_side=False):
532547
# case it's logical to move the left border to the right
533548
# instead.
534549
if not trying_other_side:
535-
handle_side(split_cls, not is_before, -amount,
536-
trying_other_side=True)
550+
handle_side(
551+
split_cls, not is_before, -amount, trying_other_side=True
552+
)
537553

538554
handle_side(VSplit, True, left)
539555
handle_side(VSplit, False, right)
@@ -553,6 +569,7 @@ class Arrangement(object):
553569
window. All the clients share the same Arrangement instance, but they can
554570
have different windows active.
555571
"""
572+
556573
def __init__(self):
557574
self.windows = []
558575
self.base_index = 0
@@ -569,7 +586,7 @@ def invalidation_hash(self):
569586
When this changes, the layout needs to be rebuild.
570587
"""
571588
if not self.windows:
572-
return '<no-windows>'
589+
return "<no-windows>"
573590

574591
w = self.get_active_window()
575592
return w.invalidation_hash()
@@ -583,7 +600,9 @@ def get_active_window(self):
583600
try:
584601
return self._active_window_for_cli[app]
585602
except KeyError:
586-
self._active_window_for_cli[app] = self._last_active_window or self.windows[0]
603+
self._active_window_for_cli[app] = (
604+
self._last_active_window or self.windows[0]
605+
)
587606
return self.windows[0]
588607

589608
def set_active_window(self, window):
@@ -621,17 +640,14 @@ def get_window_by_index(self, index):
621640
if w.index == index:
622641
return w
623642

624-
def create_window(self, pane, name=None, set_active=True):
643+
def create_window(self, pane: Pane, name: Optional[str] = None, set_active=True):
625644
"""
626645
Create a new window that contains just this pane.
627646
628647
:param pane: The :class:`.Pane` instance to put in the new window.
629648
:param name: If given, name for the new window.
630649
:param set_active: When True, focus the new window.
631650
"""
632-
assert isinstance(pane, Pane)
633-
assert name is None or isinstance(name, six.text_type)
634-
635651
# Take the first available index.
636652
taken_indexes = [w.index for w in self.windows]
637653

@@ -700,14 +716,16 @@ def remove_pane(self, pane):
700716
def focus_previous_window(self):
701717
w = self.get_active_window()
702718

703-
self.set_active_window(self.windows[
704-
(self.windows.index(w) - 1) % len(self.windows)])
719+
self.set_active_window(
720+
self.windows[(self.windows.index(w) - 1) % len(self.windows)]
721+
)
705722

706723
def focus_next_window(self):
707724
w = self.get_active_window()
708725

709-
self.set_active_window(self.windows[
710-
(self.windows.index(w) + 1) % len(self.windows)])
726+
self.set_active_window(
727+
self.windows[(self.windows.index(w) + 1) % len(self.windows)]
728+
)
711729

712730
def break_pane(self, set_active=True):
713731
"""

pymux/client/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from __future__ import unicode_literals
21
from .base import Client
32
from .defaults import create_client, list_clients

pymux/client/base.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
from __future__ import unicode_literals
1+
from abc import ABC
22

33
from prompt_toolkit.output import ColorDepth
4-
from abc import ABCMeta
5-
from six import with_metaclass
6-
74

85
__all__ = [
9-
'Client',
6+
"Client",
107
]
118

129

13-
class Client(with_metaclass(ABCMeta, object)):
10+
class Client(ABC):
1411
def run_command(self, command, pane_id=None):
1512
"""
1613
Ask the server to run this command.

pymux/client/defaults.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
from __future__ import unicode_literals
21
from prompt_toolkit.utils import is_windows
2+
33
__all__ = [
4-
'create_client',
5-
'list_clients',
4+
"create_client",
5+
"list_clients",
66
]
77

88

99
def create_client(socket_name):
1010
if is_windows():
1111
from .windows import WindowsClient
12+
1213
return WindowsClient(socket_name)
1314
else:
1415
from .posix import PosixClient
16+
1517
return PosixClient(socket_name)
1618

1719

1820
def list_clients():
1921
if is_windows():
2022
from .windows import list_clients
23+
2124
return list_clients()
2225
else:
2326
from .posix import list_clients
27+
2428
return list_clients()

0 commit comments

Comments
 (0)