Skip to content

Commit

Permalink
Remove redundant 3.6 code and bump mypy's python_version to 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Oct 6, 2022
1 parent 27d2014 commit acef2f1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions autoload/black.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def _get_virtualenv_site_packages(venv_path, pyver):

def _initialize_black_env(upgrade=False):
pyver = sys.version_info[:3]
if pyver < (3, 6, 2):
print("Sorry, Black requires Python 3.6.2+ to run.")
if pyver < (3, 7):
print("Sorry, Black requires Python 3.7+ to run.")
return False

from pathlib import Path
Expand Down
7 changes: 1 addition & 6 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Specify the target platform details in config, so your developers are
# free to run mypy on Windows, Linux, or macOS and get consistent
# results.
python_version=3.6
python_version=3.7

mypy_path=src

Expand All @@ -19,11 +19,6 @@ no_implicit_reexport = False
# to avoid 'em in the first place.
warn_unreachable=True

[mypy-black]
# The following is because of `patch_click()`. Remove when
# we drop Python 3.6 support.
warn_unused_ignores=False

[mypy-blib2to3.driver.*]
ignore_missing_imports = True

Expand Down
4 changes: 2 additions & 2 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1382,9 +1382,9 @@ def patch_click() -> None:

for module in modules:
if hasattr(module, "_verify_python3_env"):
module._verify_python3_env = lambda: None # type: ignore
module._verify_python3_env = lambda: None
if hasattr(module, "_verify_python_env"):
module._verify_python_env = lambda: None # type: ignore
module._verify_python_env = lambda: None


def patched_main() -> None:
Expand Down
6 changes: 1 addition & 5 deletions src/black/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ def cancel(tasks: Iterable["asyncio.Task[Any]"]) -> None:
def shutdown(loop: asyncio.AbstractEventLoop) -> None:
"""Cancel all pending tasks on `loop`, wait for them, and close the loop."""
try:
if sys.version_info[:2] >= (3, 7):
all_tasks = asyncio.all_tasks
else:
all_tasks = asyncio.Task.all_tasks
# This part is borrowed from asyncio/runners.py in Python 3.7b2.
to_cancel = [task for task in all_tasks(loop) if not task.done()]
to_cancel = [task for task in asyncio.all_tasks(loop) if not task.done()]
if not to_cancel:
return

Expand Down
3 changes: 1 addition & 2 deletions src/black/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
try:
from typed_ast import ast3
except ImportError:
# Either our python version is too low, or we're on pypy
if sys.version_info < (3, 7) or (sys.version_info < (3, 8) and not _IS_PYPY):
if sys.version_info < (3, 8) and not _IS_PYPY:
print(
"The typed_ast package is required but not installed.\n"
"You can upgrade to Python 3.8+ or install typed_ast with\n"
Expand Down

0 comments on commit acef2f1

Please sign in to comment.