Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix outdated references to 3.6 and run pyupgrade #3286

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 2 additions & 3 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]'`.
Comment on lines +19 to +20
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wish we could remove the copy pasta somehow ...


If you can't wait for the latest _hotness_ and want to install from GitHub, use:

Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
3 changes: 1 addition & 2 deletions src/black/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this require typing change ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the code is equivalent (IIRC there are subtle differences around exception handling but those don't matter here).

elif (
parent is not None and parent.type == syms.suite and leaf.type == token.NEWLINE
):
Expand Down
12 changes: 2 additions & 10 deletions src/black/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner.

finally:
# `concurrent.futures.Future` objects cannot be cancelled once they
# are already running. There might be some when the `shutdown()` happened.
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/black/trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def do_transform(self, line: Line, string_idx: int) -> Iterator[TResult[Line]]:

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this has to do with 3.6 but I'll take it.

if string_op_leaves
else 0
)
Expand Down