Created
September 7, 2022 01:59
-
-
Save afonasev/5406dcfc4617b5db4086af6854170786 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Wrapper around Flake8 to enable multiprocessing on all operating systems. | |
As of Python 3.8, macOS's default "start method" for multiprocessing is `spawn`. Flake8 | |
requires a "start method" of `fork`, and disables multiprocessing if it detects `spawn` | |
or some other "start method". This script enables the `fork` start method before passing | |
along any command-line arguments to `flake8`. | |
This has never caused me any problems, but note that they disabled this for a reason: | |
Flake8's plugin interface doesn't work with `spawn`, and the maintainer says that `fork` | |
is "pretty broken" on macOS. | |
See: | |
- https://github.com/pycqa/flake8/issues/955 | |
- https://github.com/PyCQA/flake8/issues/1337 | |
- https://github.com/PyCQA/flake8/issues/342 | |
- https://github.com/PyCQA/flake8/pull/1621 | |
Example usage: python -m run_flake8 --select=E501 . | |
""" | |
import multiprocessing | |
import sys | |
from flake8.main import cli | |
if __name__ == "__main__": | |
multiprocessing.set_start_method("fork", force=True) | |
cli.main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment