Skip to content

Commit

Permalink
Fix for Black 8.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Mar 28, 2022
1 parent ac7402c commit 0605166
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

<!-- Changes to how Black is packaged, such as dependency requirements -->

- Fix Black to work with Click 8.1.0 (#2966)
- On Python 3.11 and newer, use the standard library's `tomllib` instead of `tomli`
(#2903)
- `black-primer`, the deprecated internal devtool, has been removed and copied to a
Expand Down
14 changes: 11 additions & 3 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,13 +1427,21 @@ def patch_click() -> None:
file paths is minimal since it's Python source code. Moreover, this crash was
spurious on Python 3.7 thanks to PEP 538 and PEP 540.
"""
modules: List[Any] = []
try:
from click import core
except ImportError:
pass
else:
modules.append(core)
try:
from click import _unicodefun
except ModuleNotFoundError:
return
except ImportError:
pass
else:
modules.append(_unicodefun)

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

0 comments on commit 0605166

Please sign in to comment.