Skip to content

Commit d700c11

Browse files
authored
Merge pull request #6692 from oliver-sanders/flake8++
flake8++
2 parents 49f4045 + aea8673 commit d700c11

31 files changed

+8
-68
lines changed

cylc/flow/async_util.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ def my_pipe_step(x, *args, *kwargs): pass
393393
if preproc and not func:
394394
# @pipe(preproc=x)
395395
def _pipe(func):
396-
nonlocal preproc
397396
return _PipeFunction(func, preproc)
398397
return _pipe
399398
elif func:
@@ -433,7 +432,6 @@ def wrap_exception(coroutine):
433432
434433
"""
435434
async def _inner(*args, **kwargs):
436-
nonlocal coroutine
437435
try:
438436
return await coroutine(*args, **kwargs)
439437
except Exception as exc:
@@ -503,7 +501,6 @@ def make_async(fcn):
503501
"""
504502
@wraps(fcn)
505503
async def _fcn(*args, executor=None, **kwargs):
506-
nonlocal fcn
507504
return await asyncio.get_event_loop().run_in_executor(
508505
executor,
509506
partial(fcn, *args, **kwargs),

cylc/flow/commands.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
def _command(name: str):
104104
"""Decorator to register a command."""
105105
def _command(fcn: '_TCommand') -> '_TCommand':
106-
nonlocal name
107106
COMMANDS[name] = fcn
108107
fcn.command_name = name # type: ignore[attr-defined]
109108
return fcn

cylc/flow/main_loop/log_db.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def _patch_db_connect(db_connect_method):
6363
are also patched.
6464
"""
6565
def _inner(*args, **kwargs):
66-
nonlocal db_connect_method
6766
conn = db_connect_method(*args, **kwargs)
6867
conn.set_trace_callback(_log)
6968
return conn

cylc/flow/parsec/include.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,23 @@
1616

1717
import os
1818
import re
19+
from typing import List
1920

2021
from cylc.flow.parsec.exceptions import (
2122
FileParseError, IncludeFileNotFoundError)
2223

2324

24-
done = []
25-
flist = []
25+
done: List[str] = []
26+
flist: List[str] = []
2627

2728
include_re = re.compile(r'\s*%include\s+([\'"]?)(.*?)([\'"]?)\s*$')
2829

2930

3031
def inline(lines, dir_, filename, for_grep=False, viewcfg=None, level=None):
3132
"""Recursive inlining of parsec include-files"""
32-
33-
global flist
3433
if level is None:
3534
# avoid being affected by multiple *different* calls to this function
36-
flist = [filename]
35+
flist[:] = [filename]
3736
else:
3837
flist.append(filename)
3938
single = False
@@ -46,8 +45,6 @@ def inline(lines, dir_, filename, for_grep=False, viewcfg=None, level=None):
4645
else:
4746
viewcfg = {}
4847

49-
global done
50-
5148
outf = []
5249
initial_line_index = 0
5350

cylc/flow/pipe_poller.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def pipe_poller(proc, *files, chunk_size=4096):
5858

5959
def _read(timeout=1.0):
6060
# read any data from files
61-
nonlocal chunk_size, files
6261
for file in select(list(files), [], [], timeout)[0]:
6362
buffer = file.read(chunk_size)
6463
if len(buffer) > 0:

cylc/flow/task_outputs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ def format_completion_status(
548548
_gutter: str = ' ' * gutter
549549

550550
def color_wrap(string, is_complete):
551-
nonlocal ansimarkup
552551
if ansimarkup == 0:
553552
return string
554553
if is_complete:

cylc/flow/tui/overlay.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ def filter_workflow_state(app):
107107
workflow_id_prompt = 'id (regex)'
108108

109109
def update_id_filter(widget, value):
110-
nonlocal app
111110
try:
112111
# ensure the filter is value before updating the filter
113112
re.compile(value)
@@ -301,8 +300,6 @@ def context(app):
301300
is_running = False
302301

303302
def _mutate(mutation, _):
304-
nonlocal app, selection
305-
306303
app.open_overlay(partial(progress, text='Running Command'))
307304
overlay_fcn = None
308305
try:
@@ -381,12 +378,10 @@ def log(app, id_=None, list_files=None, get_log=None):
381378

382379
def open_menu(*_args, **_kwargs):
383380
"""Open an overlay for selecting a log file."""
384-
nonlocal app, id_
385381
app.open_overlay(select_log)
386382

387383
def select_log(*_args, **_kwargs):
388384
"""Create an overlay for selecting a log file."""
389-
nonlocal list_files, id_
390385
try:
391386
files = list_files()
392387
except Exception as exc:
@@ -424,8 +419,6 @@ def open_log(*_, filename=None, close=False):
424419
selected. Use this to close the "select_log" overlay.
425420
426421
"""
427-
428-
nonlocal host_widget, file_widget, text_widget
429422
try:
430423
host, path, text = get_log(filename)
431424
except Exception as exc:

cylc/flow/util.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ def restricted_evaluator(
288288
visitor = RestrictedNodeVisitor(whitelist)
289289

290290
def _eval(expr, **variables):
291-
nonlocal visitor
292-
293291
# parse the expression
294292
try:
295293
expr_node = ast.parse(expr.strip(), mode='eval')

tests/conftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,12 @@ def test_something(mock_glbl_cfg):
8282
"""
8383
# TODO: modify Parsec so we can use StringIO rather than a temp file.
8484
def _mock_glbl_cfg(pypath: str, global_config: str) -> None:
85-
nonlocal tmp_path, monkeypatch
8685
global_config_path = tmp_path / 'global.cylc'
8786
global_config_path.write_text(global_config)
8887
glbl_cfg = ParsecConfig(SPEC, validator=cylc_config_validate)
8988
glbl_cfg.loadcfg(global_config_path)
9089

9190
def _inner(cached=False):
92-
nonlocal glbl_cfg
9391
return glbl_cfg
9492

9593
monkeypatch.setattr(pypath, _inner)
@@ -196,8 +194,6 @@ def _capcall(function_string, substitute_function=None):
196194
calls = []
197195

198196
def _call(*args, **kwargs):
199-
nonlocal calls
200-
nonlocal substitute_function
201197
calls.append((args, kwargs))
202198
if substitute_function:
203199
return substitute_function(*args, **kwargs)

tests/integration/conftest.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ def _disable_submission(schd: 'Scheduler') -> 'Set[TaskProxy]':
424424
submitted_tasks: 'Set[TaskProxy]' = set()
425425

426426
def _submit_task_jobs(itasks):
427-
nonlocal submitted_tasks
428427
for itask in itasks:
429428
itask.state_reset(TASK_STATUS_SUBMITTED)
430429
submitted_tasks.update(itasks)
@@ -457,7 +456,6 @@ def _disable_polling(schd: 'Scheduler') -> 'Set[TaskProxy]':
457456
def run_job_cmd(
458457
_1, _2, itasks, _3, _4=None
459458
):
460-
nonlocal polled_tasks
461459
polled_tasks.update(itasks)
462460
return itasks
463461

@@ -567,7 +565,6 @@ def _reflog(schd: 'Scheduler', flow_nums: bool = False) -> Set[tuple]:
567565
triggers = set()
568566

569567
def _submit_task_jobs(*args, **kwargs):
570-
nonlocal submit_task_jobs, triggers, flow_nums
571568
itasks = submit_task_jobs(*args, **kwargs)
572569
for itask in itasks:
573570
deps = tuple(sorted(itask.state.get_resolved_dependencies()))
@@ -631,7 +628,6 @@ async def _complete(
631628
remove_if_complete = schd.pool.remove_if_complete
632629

633630
def _remove_if_complete(itask, output=None):
634-
nonlocal tokens_list
635631
ret = remove_if_complete(itask)
636632
if ret and itask.tokens.task in tokens_list:
637633
tokens_list.remove(itask.tokens.task)
@@ -642,7 +638,7 @@ def _remove_if_complete(itask, output=None):
642638
stop_requested = False
643639

644640
def _set_stop(mode=None):
645-
nonlocal stop_requested, stop_mode
641+
nonlocal stop_requested
646642
if mode == stop_mode:
647643
stop_requested = True
648644
return set_stop(mode)
@@ -760,7 +756,6 @@ def fake_submit(self, _workflow, itasks, *_):
760756

761757

762758
def get_submissions():
763-
nonlocal submit_live_calls
764759
return {
765760
itask.identity
766761
for ((_self, _workflow, itasks, *_), _kwargs) in submit_live_calls

0 commit comments

Comments
 (0)