X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/2082a325fdd14f0aabd88f7f12a20f9fb085c538..97060a4f18341cdd7deb908cfd6bcf0fd7f302c8:/src/black/__init__.py?ds=sidebyside diff --git a/src/black/__init__.py b/src/black/__init__.py index 3ab4bc7..77dda2b 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -662,9 +662,9 @@ def reformat_many( worker_count = min(worker_count, 61) try: executor = ProcessPoolExecutor(max_workers=worker_count) - except OSError: + except (ImportError, OSError): # we arrive here if the underlying system does not support multi-processing - # like in AWS Lambda, in which case we gracefully fallback to + # like in AWS Lambda or Termux, in which case we gracefully fallback to # a ThreadPollExecutor with just a single worker (more workers would not do us # any good due to the Global Interpreter Lock) executor = ThreadPoolExecutor(max_workers=1) @@ -6006,13 +6006,14 @@ def _stringify_ast( else: # Constant strings may be indented across newlines, if they are - # docstrings; fold spaces after newlines when comparing + # docstrings; fold spaces after newlines when comparing. Similarly, + # trailing and leading space may be removed. if ( isinstance(node, ast.Constant) and field == "value" and isinstance(value, str) ): - normalized = re.sub(r"\n[ \t]+", "\n ", value) + normalized = re.sub(r" *\n[ \t]+", "\n ", value).strip() else: normalized = value yield f"{' ' * (depth+2)}{normalized!r}, # {value.__class__.__name__}"