X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/754eecf69eed0bdc75fe224c19a702a4f0676807..8b0680533420c2ea367860fcbb08df99317a6b44:/src/blackd/__init__.py?ds=sidebyside diff --git a/src/blackd/__init__.py b/src/blackd/__init__.py index 10b6168..5fdec15 100644 --- a/src/blackd/__init__.py +++ b/src/blackd/__init__.py @@ -1,6 +1,5 @@ import asyncio import logging -import sys from concurrent.futures import Executor, ProcessPoolExecutor from datetime import datetime from functools import partial @@ -11,25 +10,16 @@ try: from aiohttp import web import aiohttp_cors except ImportError as ie: - print( + raise ImportError( f"aiohttp dependency is not installed: {ie}. " + "Please re-install black with the '[d]' extra install " - + "to obtain aiohttp_cors: `pip install black[d]`", - file=sys.stderr, - ) - sys.exit(-1) + + "to obtain aiohttp_cors: `pip install black[d]`" + ) from None import black +from black.concurrency import maybe_install_uvloop import click -# If our environment has uvloop installed lets use it -try: - import uvloop - - uvloop.install() -except ImportError: - pass - from _black_version import version as __version__ # This is used internally by tests to shut down the server prematurely @@ -210,6 +200,7 @@ def parse_python_variant_header(value: str) -> Tuple[bool, Set[black.TargetVersi def patched_main() -> None: + maybe_install_uvloop() freeze_support() black.patch_click() main()