X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/f6188ce6dcde3fcad381c52ecc74374e7d0579c9..ba21a8569977d279f14251254d57d64d47979436:/src/black/__init__.py diff --git a/src/black/__init__.py b/src/black/__init__.py index 3a2d1cb..75321c3 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1,7 +1,6 @@ import asyncio from json.decoder import JSONDecodeError import json -from concurrent.futures import Executor, ThreadPoolExecutor, ProcessPoolExecutor from contextlib import contextmanager from datetime import datetime from enum import Enum @@ -17,6 +16,7 @@ import sys import tokenize import traceback from typing import ( + TYPE_CHECKING, Any, Dict, Generator, @@ -77,6 +77,9 @@ from blib2to3.pgen2 import token from _black_version import version as __version__ +if TYPE_CHECKING: + from concurrent.futures import Executor + COMPILED = Path(__file__).suffix in (".pyd", ".so") # types @@ -767,6 +770,8 @@ def reformat_many( workers: Optional[int], ) -> None: """Reformat multiple files using a ProcessPoolExecutor.""" + from concurrent.futures import Executor, ThreadPoolExecutor, ProcessPoolExecutor + executor: Executor loop = asyncio.get_event_loop() worker_count = workers if workers is not None else DEFAULT_WORKERS @@ -808,7 +813,7 @@ async def schedule_formatting( mode: Mode, report: "Report", loop: asyncio.AbstractEventLoop, - executor: Executor, + executor: "Executor", ) -> None: """Run formatting of `sources` in parallel using the provided `executor`. @@ -1296,6 +1301,13 @@ def get_features_used( # noqa: C901 ): features.add(Feature.ANN_ASSIGN_EXTENDED_RHS) + elif ( + n.type == syms.except_clause + and len(n.children) >= 2 + and n.children[1].type == token.STAR + ): + features.add(Feature.EXCEPT_STAR) + return features