Skip to content

Commit 23d2a85

Browse files
authored
Merge pull request #1987 from PyCQA/dogfood
adjust global variable definition for new pyflakes
2 parents c48217e + 628aece commit 23d2a85

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/flake8/checker.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,39 @@
4545
# noise in diffs.
4646
}
4747

48-
_mp_plugins: Checkers
49-
_mp_options: argparse.Namespace
48+
_mp: tuple[Checkers, argparse.Namespace] | None = None
5049

5150

5251
@contextlib.contextmanager
5352
def _mp_prefork(
5453
plugins: Checkers, options: argparse.Namespace
5554
) -> Generator[None]:
5655
# we can save significant startup work w/ `fork` multiprocessing
57-
global _mp_plugins, _mp_options
58-
_mp_plugins, _mp_options = plugins, options
56+
global _mp
57+
_mp = plugins, options
5958
try:
6059
yield
6160
finally:
62-
del _mp_plugins, _mp_options
61+
_mp = None
6362

6463

6564
def _mp_init(argv: Sequence[str]) -> None:
66-
global _mp_plugins, _mp_options
65+
global _mp
6766

6867
# Ensure correct signaling of ^C using multiprocessing.Pool.
6968
signal.signal(signal.SIGINT, signal.SIG_IGN)
7069

71-
try:
72-
# for `fork` this'll already be set
73-
_mp_plugins, _mp_options # noqa: B018
74-
except NameError:
70+
# for `fork` this'll already be set
71+
if _mp is None:
7572
plugins, options = parse_args(argv)
76-
_mp_plugins, _mp_options = plugins.checkers, options
73+
_mp = plugins.checkers, options
7774

7875

7976
def _mp_run(filename: str) -> tuple[str, Results, dict[str, int]]:
77+
assert _mp is not None, _mp
78+
plugins, options = _mp
8079
return FileChecker(
81-
filename=filename, plugins=_mp_plugins, options=_mp_options
80+
filename=filename, plugins=plugins, options=options
8281
).run_checks()
8382

8483

0 commit comments

Comments
 (0)