diff --git a/CHANGELOG.md b/CHANGELOG.md index 710eccb1f..72b8caeb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Find out more about isort's release policy [here](https://pycqa.github.io/isort/ - Implemented #1648: Export MyPY type hints. - Implemented #1641: Identified import statements now return runnable code. - Implemented #1661: Added "wemake" profile. + - implemented #1669: Parallel (`-j`) now defaults to number of CPU cores if no value is provided. ### 5.7.0 December 30th 2020 - Fixed #1612: In rare circumstances an extra comma is added after import and before comment. diff --git a/isort/main.py b/isort/main.py index 6824bae73..c6f6737b5 100644 --- a/isort/main.py +++ b/isort/main.py @@ -2,6 +2,7 @@ import argparse import functools import json +import multiprocessing import os import sys from gettext import gettext as _ @@ -268,7 +269,13 @@ def _build_arg_parser() -> argparse.ArgumentParser: help="Use the old deprecated finder logic that relies on environment introspection magic.", ) general_group.add_argument( - "-j", "--jobs", help="Number of files to process in parallel.", dest="jobs", type=int + "-j", + "--jobs", + help="Number of files to process in parallel.", + dest="jobs", + type=int, + nargs="?", + const=multiprocessing.cpu_count(), ) general_group.add_argument( "--ac", @@ -844,6 +851,7 @@ def parse_args(argv: Optional[Sequence[str]] = None) -> Dict[str, Any]: arguments["multi_line_output"] = WrapModes(int(multi_line_output)) else: arguments["multi_line_output"] = WrapModes[multi_line_output] + return arguments