|
1 | 1 | import asyncio
|
2 |
| -from json.decoder import JSONDecodeError |
3 |
| -import json |
4 |
| -from contextlib import contextmanager |
5 |
| -from datetime import datetime |
6 |
| -from enum import Enum |
7 | 2 | import io
|
8 |
| -from multiprocessing import Manager, freeze_support |
| 3 | +import json |
9 | 4 | import os
|
10 |
| -from pathlib import Path |
11 |
| -from pathspec.patterns.gitwildmatch import GitWildMatchPatternError |
12 | 5 | import platform
|
13 | 6 | import re
|
14 | 7 | import signal
|
15 | 8 | import sys
|
16 | 9 | import tokenize
|
17 | 10 | import traceback
|
| 11 | +from contextlib import contextmanager |
| 12 | +from dataclasses import replace |
| 13 | +from datetime import datetime |
| 14 | +from enum import Enum |
| 15 | +from json.decoder import JSONDecodeError |
| 16 | +from multiprocessing import Manager, freeze_support |
| 17 | +from pathlib import Path |
18 | 18 | from typing import (
|
19 | 19 | TYPE_CHECKING,
|
20 | 20 | Any,
|
|
34 | 34 |
|
35 | 35 | import click
|
36 | 36 | from click.core import ParameterSource
|
37 |
| -from dataclasses import replace |
38 | 37 | from mypy_extensions import mypyc_attr
|
| 38 | +from pathspec.patterns.gitwildmatch import GitWildMatchPatternError |
39 | 39 |
|
40 |
| -from black.const import DEFAULT_LINE_LENGTH, DEFAULT_INCLUDES, DEFAULT_EXCLUDES |
41 |
| -from black.const import STDIN_PLACEHOLDER |
42 |
| -from black.nodes import STARS, syms, is_simple_decorator_expression |
43 |
| -from black.nodes import is_string_token, is_number_token |
44 |
| -from black.lines import Line, EmptyLineTracker |
45 |
| -from black.linegen import transform_line, LineGenerator, LN |
| 40 | +from _black_version import version as __version__ |
| 41 | +from black.cache import Cache, filter_cached, get_cache_info, read_cache, write_cache |
46 | 42 | from black.comments import normalize_fmt_off
|
47 |
| -from black.mode import FUTURE_FLAG_TO_FEATURE, Mode, TargetVersion |
48 |
| -from black.mode import Feature, supports_feature, VERSION_TO_FEATURES |
49 |
| -from black.cache import read_cache, write_cache, get_cache_info, filter_cached, Cache |
50 |
| -from black.concurrency import cancel, shutdown, maybe_install_uvloop |
51 |
| -from black.output import dump_to_file, ipynb_diff, diff, color_diff, out, err |
52 |
| -from black.report import Report, Changed, NothingChanged |
| 43 | +from black.concurrency import cancel, maybe_install_uvloop, shutdown |
| 44 | +from black.const import ( |
| 45 | + DEFAULT_EXCLUDES, |
| 46 | + DEFAULT_INCLUDES, |
| 47 | + DEFAULT_LINE_LENGTH, |
| 48 | + STDIN_PLACEHOLDER, |
| 49 | +) |
53 | 50 | from black.files import (
|
54 | 51 | find_project_root,
|
55 | 52 | find_pyproject_toml,
|
56 |
| - parse_pyproject_toml, |
57 | 53 | find_user_pyproject_toml,
|
| 54 | + gen_python_files, |
| 55 | + get_gitignore, |
| 56 | + normalize_path_maybe_ignore, |
| 57 | + parse_pyproject_toml, |
| 58 | + wrap_stream_for_windows, |
58 | 59 | )
|
59 |
| -from black.files import gen_python_files, get_gitignore, normalize_path_maybe_ignore |
60 |
| -from black.files import wrap_stream_for_windows |
61 |
| -from black.parsing import InvalidInput # noqa F401 |
62 |
| -from black.parsing import lib2to3_parse, parse_ast, stringify_ast |
63 | 60 | from black.handle_ipynb_magics import (
|
64 |
| - mask_cell, |
65 |
| - unmask_cell, |
66 |
| - remove_trailing_semicolon, |
67 |
| - put_trailing_semicolon_back, |
68 |
| - TRANSFORMED_MAGICS, |
69 | 61 | PYTHON_CELL_MAGICS,
|
| 62 | + TRANSFORMED_MAGICS, |
70 | 63 | jupyter_dependencies_are_installed,
|
| 64 | + mask_cell, |
| 65 | + put_trailing_semicolon_back, |
| 66 | + remove_trailing_semicolon, |
| 67 | + unmask_cell, |
71 | 68 | )
|
72 |
| - |
73 |
| - |
74 |
| -# lib2to3 fork |
75 |
| -from blib2to3.pytree import Node, Leaf |
| 69 | +from black.linegen import LN, LineGenerator, transform_line |
| 70 | +from black.lines import EmptyLineTracker, Line |
| 71 | +from black.mode import ( |
| 72 | + FUTURE_FLAG_TO_FEATURE, |
| 73 | + VERSION_TO_FEATURES, |
| 74 | + Feature, |
| 75 | + Mode, |
| 76 | + TargetVersion, |
| 77 | + supports_feature, |
| 78 | +) |
| 79 | +from black.nodes import ( |
| 80 | + STARS, |
| 81 | + is_number_token, |
| 82 | + is_simple_decorator_expression, |
| 83 | + is_string_token, |
| 84 | + syms, |
| 85 | +) |
| 86 | +from black.output import color_diff, diff, dump_to_file, err, ipynb_diff, out |
| 87 | +from black.parsing import InvalidInput # noqa F401 |
| 88 | +from black.parsing import lib2to3_parse, parse_ast, stringify_ast |
| 89 | +from black.report import Changed, NothingChanged, Report |
76 | 90 | from blib2to3.pgen2 import token
|
77 |
| - |
78 |
| -from _black_version import version as __version__ |
| 91 | +from blib2to3.pytree import Leaf, Node |
79 | 92 |
|
80 | 93 | if TYPE_CHECKING:
|
81 | 94 | from concurrent.futures import Executor
|
@@ -770,7 +783,7 @@ def reformat_many(
|
770 | 783 | workers: Optional[int],
|
771 | 784 | ) -> None:
|
772 | 785 | """Reformat multiple files using a ProcessPoolExecutor."""
|
773 |
| - from concurrent.futures import Executor, ThreadPoolExecutor, ProcessPoolExecutor |
| 786 | + from concurrent.futures import Executor, ProcessPoolExecutor, ThreadPoolExecutor |
774 | 787 |
|
775 | 788 | executor: Executor
|
776 | 789 | worker_count = workers if workers is not None else DEFAULT_WORKERS
|
|
0 commit comments