Skip to content

Commit a3e60b5

Browse files
committed
flake8
1 parent 2d9b463 commit a3e60b5

24 files changed

+200
-210
lines changed

tmuxp/cli.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def load_workspace(config_file, args):
260260
logger.error('%s is empty or parsed no config data' % config_file)
261261
return
262262

263-
tmux_bin = util.which('tmux')
263+
util.which('tmux')
264264

265265
try:
266266
logger.info('Loading %s.' % config_file)
@@ -575,11 +575,12 @@ def command_import_tmuxinator(args):
575575
else:
576576
sys.exit('Unknown config format.')
577577

578-
print(newconfig)
579-
print(
580-
'---------------------------------------------------------------')
581578
print(
582-
'Configuration import does its best to convert tmuxinator files.\n')
579+
newconfig,
580+
'---------------------------------------------------------------'
581+
'Configuration import does its best to convert tmuxinator files.'
582+
'\n'
583+
)
583584
if args.answer_yes or prompt_yes_no(
584585
'The new config *WILL* require adjusting afterwards. Save config?'
585586
):
@@ -667,7 +668,6 @@ def command_convert(args):
667668

668669
def command_attach_session(args):
669670
"""Command to attach / switch client to a tmux session."""
670-
commands = []
671671
ctext = ' '.join(args.session_name)
672672

673673
t = Server(
@@ -696,7 +696,6 @@ def command_attach_session(args):
696696

697697
def command_kill_session(args):
698698
"""Command to kill a tmux session."""
699-
commands = []
700699
ctext = ' '.join(args.session_name)
701700

702701
t = Server(
@@ -909,7 +908,9 @@ def get_parser():
909908
required=True)
910909
import_tmuxinatorgroup.add_argument(
911910
'--list', dest='list', action='store_true',
912-
help='List yaml configs in ~/.tmuxinator and current working directory.'
911+
help=(
912+
'List yaml configs in ~/.tmuxinator and current working directory.'
913+
)
913914
)
914915

915916
import_tmuxinatorgroup.add_argument(
@@ -926,7 +927,9 @@ def get_parser():
926927
parser.add_argument(
927928
'--log-level', dest='log_level',
928929
default=None,
929-
help='Level of debug verbosity. DEBUG, INFO, WARNING, ERROR, CRITICAL.',
930+
help=(
931+
'Level of debug verbosity. DEBUG, INFO, WARNING, ERROR, CRITICAL.',
932+
)
930933
)
931934

932935
parser.add_argument(
@@ -963,7 +966,7 @@ def main():
963966

964967
util.oh_my_zsh_auto_title()
965968

966-
t = Server(
969+
t = Server( # noqa
967970
socket_name=args.socket_name,
968971
socket_path=args.socket_path,
969972
colors=args.colors
@@ -988,4 +991,3 @@ def main():
988991
command_kill_session(args)
989992
except KeyboardInterrupt:
990993
pass
991-

tmuxp/config.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,26 @@ def inline(sconf):
127127
"""
128128

129129
if (
130-
'shell_command' in sconf and
131-
isinstance(sconf['shell_command'], list) and
132-
len(sconf['shell_command']) == 1
130+
'shell_command' in sconf and
131+
isinstance(sconf['shell_command'], list) and
132+
len(sconf['shell_command']) == 1
133133
):
134134
sconf['shell_command'] = sconf['shell_command'][0]
135135

136136
if len(sconf.keys()) == int(1):
137137
sconf = sconf['shell_command']
138138
if (
139-
'shell_command_before' in sconf and
140-
isinstance(sconf['shell_command_before'], list) and
141-
len(sconf['shell_command_before']) == 1
139+
'shell_command_before' in sconf and
140+
isinstance(sconf['shell_command_before'], list) and
141+
len(sconf['shell_command_before']) == 1
142142
):
143143
sconf['shell_command_before'] = sconf['shell_command_before'][0]
144144

145145
# recurse into window and pane config items
146146
if 'windows' in sconf:
147147
sconf['windows'] = [
148148
inline(window) for window in sconf['windows']
149-
]
149+
]
150150
if 'panes' in sconf:
151151
sconf['panes'] = [inline(pane) for pane in sconf['panes']]
152152

@@ -223,30 +223,30 @@ def expand(sconf, cwd=None, parent=None):
223223
)
224224

225225
if (
226-
'shell_command' in sconf and
227-
isinstance(sconf['shell_command'], string_types)
226+
'shell_command' in sconf and
227+
isinstance(sconf['shell_command'], string_types)
228228
):
229229
sconf['shell_command'] = [sconf['shell_command']]
230230

231231
if (
232-
'shell_command_before' in sconf and
233-
isinstance(sconf['shell_command_before'], string_types)
232+
'shell_command_before' in sconf and
233+
isinstance(sconf['shell_command_before'], string_types)
234234
):
235235
sconf['shell_command_before'] = [sconf['shell_command_before']]
236236

237237
if (
238-
'shell_command_before' in sconf and
239-
isinstance(sconf['shell_command_before'], list)
238+
'shell_command_before' in sconf and
239+
isinstance(sconf['shell_command_before'], list)
240240
):
241241
sconf['shell_command_before'] = [
242242
expandshell(scmd) for scmd in sconf['shell_command_before']
243-
]
243+
]
244244

245245
# recurse into window and pane config items
246246
if 'windows' in sconf:
247247
sconf['windows'] = [
248248
expand(window, parent=sconf) for window in sconf['windows']
249-
]
249+
]
250250
elif 'panes' in sconf:
251251

252252
for pconf in sconf['panes']:
@@ -282,7 +282,9 @@ def expand(sconf, cwd=None, parent=None):
282282
p['shell_command'] = []
283283

284284
pconf.update(p)
285-
sconf['panes'] = [expand(pane, parent=sconf) for pane in sconf['panes']]
285+
sconf['panes'] = [
286+
expand(pane, parent=sconf) for pane in sconf['panes']
287+
]
286288

287289
return sconf
288290

@@ -320,21 +322,22 @@ def trickle(sconf):
320322

321323
# Prepend start_directory to relative window commands
322324
if session_start_directory:
323-
if not 'start_directory' in windowconfig:
325+
if 'start_directory' not in windowconfig:
324326
windowconfig['start_directory'] = session_start_directory
325327
else:
326328
if not any(
327329
windowconfig['start_directory'].startswith(a)
328330
for a in ['~', '/']
329331
):
330332
window_start_path = os.path.join(
331-
session_start_directory, windowconfig['start_directory']
333+
session_start_directory,
334+
windowconfig['start_directory']
332335
)
333336
windowconfig['start_directory'] = window_start_path
334337

335338
# We only need to trickle to the window, workspace builder checks wconf
336339
if suppress_history is not None:
337-
if not 'suppress_history' in windowconfig:
340+
if 'suppress_history' not in windowconfig:
338341
windowconfig['suppress_history'] = suppress_history
339342

340343
for paneconfig in windowconfig['panes']:

tmuxp/exc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class BeforeLoadScriptNotExists(OSError):
4343
def __init__(self, *args, **kwargs):
4444
super(BeforeLoadScriptNotExists, self).__init__(*args, **kwargs)
4545

46-
self.strerror = "before_script file '%s' doesn't exist." % self.strerror
46+
self.strerror = (
47+
"before_script file '%s' doesn't exist." % self.strerror
48+
)
4749

4850

4951
@implements_to_string

tmuxp/formats.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,3 @@
100100
'mouse_any_flag',
101101
'mouse_utf8_flag',
102102
]
103-

tmuxp/log.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ def default_log_template(self, record):
3434
reset = Style.RESET_ALL
3535
levelname = (
3636
LEVEL_COLORS.get(record.levelname) + Style.BRIGHT +
37-
'(%(levelname)s)'
38-
+ Style.RESET_ALL + ' '
37+
'(%(levelname)s)' + Style.RESET_ALL + ' '
3938
)
4039
asctime = (
4140
'[' + Fore.BLACK + Style.DIM + Style.BRIGHT +

tmuxp/pane.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,3 @@ def __repr__(self):
182182
self.get('pane_id'),
183183
self.window
184184
)
185-

tmuxp/server.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ def _list_sessions(self):
122122
*tmux_args
123123
)
124124

125-
if proc.stderr:
126-
raise exc.TmuxpException(proc.stderr)
127-
else:
128-
session_info = proc.stdout[0]
129-
130125
if proc.stderr:
131126
raise exc.TmuxpException(proc.stderr)
132127

@@ -310,8 +305,8 @@ def attached_sessions(self):
310305
continue
311306

312307
return [
313-
Session(server=self, **s) for s in attached_sessions
314-
] or None
308+
Session(server=self, **s) for s in attached_sessions
309+
] or None
315310

316311
def has_session(self, target_session):
317312
"""Return True if session exists. ``$ tmux has-session``.

tmuxp/session.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
logger = logging.getLogger(__name__)
1919

2020

21-
class Session(util.TmuxMappingObject, util.TmuxRelationalObject, EnvironmentMixin):
21+
class Session(
22+
util.TmuxMappingObject,
23+
util.TmuxRelationalObject,
24+
EnvironmentMixin
25+
):
2226
""":term:`tmux(1)` session.
2327
2428
Holds :class:`Window` objects.
@@ -218,8 +222,6 @@ def kill_window(self, target_window=None):
218222
219223
"""
220224

221-
tmux_args = list()
222-
223225
if target_window:
224226
if isinstance(target_window, int):
225227
target = '-t%s:%d' % (self.get('session_name'), target_window)
@@ -238,7 +240,7 @@ def _list_windows(self):
238240

239241
windows = [
240242
w for w in windows if w['session_id'] == self.get('session_id')
241-
]
243+
]
242244

243245
return windows
244246

@@ -256,7 +258,7 @@ def list_windows(self):
256258
"""
257259
windows = [
258260
w for w in self._windows if w['session_id'] == self._session_id
259-
]
261+
]
260262

261263
return [Window(session=self, **window) for window in windows]
262264

tmuxp/testsuite/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
t = Server()
2525
t.socket_name = 'tmuxp_test'
2626

27-
from tmuxp.testsuite import helpers
27+
from tmuxp.testsuite import helpers # NOQA
2828

29-
30-
# Logger functionality
31-
32-
logger = logging.getLogger()
29+
logger = logging.getLogger() # Logger functionality
3330

3431
if not logger.handlers:
3532
channel = logging.StreamHandler()

tmuxp/testsuite/cli.py

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -57,58 +57,40 @@ def test_in_dir_from_config_dir(self):
5757
"""config.in_dir() finds configs config dir."""
5858

5959
cli.startup(self.tmp_dir)
60-
config1 = tempfile.NamedTemporaryFile(
60+
with tempfile.NamedTemporaryFile(
6161
dir=self.tmp_dir,
6262
prefix='myconfig',
6363
suffix='.yaml'
64-
)
64+
):
65+
with tempfile.NamedTemporaryFile(
66+
dir=self.tmp_dir,
67+
prefix='myconfig',
68+
suffix='.json'
69+
):
70+
configs_found = config.in_dir(self.tmp_dir)
6571

66-
config2 = tempfile.NamedTemporaryFile(
67-
dir=self.tmp_dir,
68-
prefix='myconfig',
69-
suffix='.json'
70-
)
71-
configs_found = config.in_dir(self.tmp_dir)
72-
73-
self.assertEqual(len(configs_found), 2)
72+
self.assertEqual(len(configs_found), 2)
7473

7574
def test_in_dir_from_current_dir(self):
76-
"""config.in_dir() find configs config dir."""
77-
78-
cli.startup(self.tmp_dir)
79-
config1 = tempfile.NamedTemporaryFile(
80-
dir=self.tmp_dir,
81-
prefix='myconfig',
82-
suffix='.yaml'
83-
)
84-
85-
config2 = tempfile.NamedTemporaryFile(
86-
dir=self.tmp_dir,
87-
prefix='myconfig',
88-
suffix='.json'
89-
)
90-
configs_found = config.in_dir(self.tmp_dir)
91-
92-
self.assertEqual(len(configs_found), 2)
75+
"""config.in_dir() find configs current dir."""
76+
pass # TODO
9377

9478
def test_ignore_non_configs_from_current_dir(self):
9579
"""cli.in_dir() ignore non-config from config dir."""
9680

9781
cli.startup(self.tmp_dir)
98-
badconfig = tempfile.NamedTemporaryFile(
82+
with tempfile.NamedTemporaryFile(
9983
dir=self.tmp_dir,
10084
prefix='myconfig',
10185
suffix='.psd'
102-
)
103-
104-
config1 = tempfile.NamedTemporaryFile(
105-
dir=self.tmp_dir,
106-
prefix='watmyconfig',
107-
suffix='.json'
108-
)
109-
configs_found = config.in_dir(self.tmp_dir)
110-
111-
self.assertEqual(len(configs_found), 1)
86+
):
87+
with tempfile.NamedTemporaryFile(
88+
dir=self.tmp_dir,
89+
prefix='watmyconfig',
90+
suffix='.json'
91+
):
92+
configs_found = config.in_dir(self.tmp_dir)
93+
self.assertEqual(len(configs_found), 1)
11294

11395
def test_get_configs_cwd(self):
11496
"""config.in_cwd() find config in shell current working directory."""

0 commit comments

Comments
 (0)