From 2189bcaac01d9b6289411a75557a23cf4a06b783 Mon Sep 17 00:00:00 2001 From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Sun, 25 Sep 2022 20:24:18 -0400 Subject: [PATCH 1/1] Fix outdated references to 3.6 and run pyupgrade (#3286) I also missed the accidental removal of the 3.11 classifier in the PR. --- README.md | 5 ++--- docs/getting_started.md | 5 ++--- docs/integrations/editors.md | 2 +- pyproject.toml | 1 + src/black/comments.py | 3 +-- src/black/concurrency.py | 12 ++---------- src/black/trans.py | 2 +- 7 files changed, 10 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 4c76160..b259302 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,8 @@ Try it out now using the [Black Playground](https://black.vercel.app). Watch the ### Installation -_Black_ can be installed by running `pip install black`. It requires Python 3.6.2+ to -run. If you want to format Jupyter Notebooks, install with -`pip install 'black[jupyter]'`. +_Black_ can be installed by running `pip install black`. It requires Python 3.7+ to run. +If you want to format Jupyter Notebooks, install with `pip install 'black[jupyter]'`. If you can't wait for the latest _hotness_ and want to install from GitHub, use: diff --git a/docs/getting_started.md b/docs/getting_started.md index fca9609..1825f3b 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -16,9 +16,8 @@ Also, you can try out _Black_ online for minimal fuss on the ## Installation -_Black_ can be installed by running `pip install black`. It requires Python 3.6.2+ to -run. If you want to format Jupyter Notebooks, install with -`pip install 'black[jupyter]'`. +_Black_ can be installed by running `pip install black`. It requires Python 3.7+ to run. +If you want to format Jupyter Notebooks, install with `pip install 'black[jupyter]'`. If you can't wait for the latest _hotness_ and want to install from GitHub, use: diff --git a/docs/integrations/editors.md b/docs/integrations/editors.md index 318e0e2..28c9f48 100644 --- a/docs/integrations/editors.md +++ b/docs/integrations/editors.md @@ -148,7 +148,7 @@ curl https://raw.githubusercontent.com/psf/black/stable/autoload/black.vim -o ~/ Let me know if this requires any changes to work with Vim 8's builtin `packadd`, or Pathogen, and so on. -This plugin **requires Vim 7.0+ built with Python 3.6+ support**. It needs Python 3.6 to +This plugin **requires Vim 7.0+ built with Python 3.7+ support**. It needs Python 3.7 to be able to run _Black_ inside the Vim process which is much faster than calling an external command. diff --git a/pyproject.toml b/pyproject.toml index c377026..412e46c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance", ] diff --git a/src/black/comments.py b/src/black/comments.py index 2a4c254..dce83ab 100644 --- a/src/black/comments.py +++ b/src/black/comments.py @@ -270,8 +270,7 @@ def _generate_ignored_nodes_from_fmt_skip( while "\n" not in prev_sibling.prefix and prev_sibling.prev_sibling is not None: prev_sibling = prev_sibling.prev_sibling siblings.insert(0, prev_sibling) - for sibling in siblings: - yield sibling + yield from siblings elif ( parent is not None and parent.type == syms.suite and leaf.type == token.NEWLINE ): diff --git a/src/black/concurrency.py b/src/black/concurrency.py index bdc368d..10e288f 100644 --- a/src/black/concurrency.py +++ b/src/black/concurrency.py @@ -58,12 +58,7 @@ def shutdown(loop: asyncio.AbstractEventLoop) -> None: for task in to_cancel: task.cancel() - if sys.version_info >= (3, 7): - loop.run_until_complete(asyncio.gather(*to_cancel, return_exceptions=True)) - else: - loop.run_until_complete( - asyncio.gather(*to_cancel, loop=loop, return_exceptions=True) - ) + loop.run_until_complete(asyncio.gather(*to_cancel, return_exceptions=True)) finally: # `concurrent.futures.Future` objects cannot be cancelled once they # are already running. There might be some when the `shutdown()` happened. @@ -191,9 +186,6 @@ async def schedule_formatting( sources_to_cache.append(src) report.done(src, changed) if cancelled: - if sys.version_info >= (3, 7): - await asyncio.gather(*cancelled, return_exceptions=True) - else: - await asyncio.gather(*cancelled, loop=loop, return_exceptions=True) + await asyncio.gather(*cancelled, return_exceptions=True) if sources_to_cache: write_cache(cache, sources_to_cache, mode) diff --git a/src/black/trans.py b/src/black/trans.py index 74b932b..7e2d8e6 100644 --- a/src/black/trans.py +++ b/src/black/trans.py @@ -1256,7 +1256,7 @@ class StringSplitter(BaseStringSplitter, CustomSplitMapMixin): string_op_leaves = self._get_string_operator_leaves(LL) string_op_leaves_length = ( - sum([len(str(prefix_leaf)) for prefix_leaf in string_op_leaves]) + 1 + sum(len(str(prefix_leaf)) for prefix_leaf in string_op_leaves) + 1 if string_op_leaves else 0 ) -- 2.39.5