From e58afffff4b1ec80c8b1a1cba3859329bd6f919f Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 23 Aug 2021 15:37:50 -0700 Subject: [PATCH 1/4] Change sys.exit to Raise. --- src/blackd/__init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/blackd/__init__.py b/src/blackd/__init__.py index 3e2a7e7c30f..eddc3ea89e5 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,13 +10,11 @@ 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, + + "to obtain aiohttp_cors: `pip install black[d]`" ) - sys.exit(-1) import black from black.concurrency import maybe_install_uvloop From 3b151f4780b5e586cfeb6e46afa11180698346f0 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 23 Aug 2021 15:54:16 -0700 Subject: [PATCH 2/4] Add #2440 to changelog. --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 22ddc423e55..dbc32b01a9b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,9 @@ - The failsafe for accidentally added backslashes in f-string expressions has been hardened to handle more edge cases during quote normalization (#2437) +### _Blackd_ +- Replace sys.exit(-1) with raise ImportError (#2440) + ### Integrations - The provided pre-commit hooks no longer specify `language_version` to avoid overriding From caf519db1b398c7f5cd9a7d5b97d447753803da7 Mon Sep 17 00:00:00 2001 From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Mon, 23 Aug 2021 19:34:21 -0400 Subject: [PATCH 3/4] Fix lint error from prettier --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index dbc32b01a9b..ed08ab3b9ad 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ hardened to handle more edge cases during quote normalization (#2437) ### _Blackd_ + - Replace sys.exit(-1) with raise ImportError (#2440) ### Integrations From fe92eaf00f003c6178a761046213a7c46c6f9316 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Tue, 24 Aug 2021 07:59:08 -0700 Subject: [PATCH 4/4] Remove exception chain for more helpful user message. --- src/blackd/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blackd/__init__.py b/src/blackd/__init__.py index eddc3ea89e5..5fdec152226 100644 --- a/src/blackd/__init__.py +++ b/src/blackd/__init__.py @@ -14,7 +14,7 @@ f"aiohttp dependency is not installed: {ie}. " + "Please re-install black with the '[d]' extra install " + "to obtain aiohttp_cors: `pip install black[d]`" - ) + ) from None import black from black.concurrency import maybe_install_uvloop