]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Fix _unicodefun patch code for Click 8.1.0 (#2966)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Mon, 28 Mar 2022 19:01:13 +0000 (12:01 -0700)
committerGitHub <noreply@github.com>
Mon, 28 Mar 2022 19:01:13 +0000 (12:01 -0700)
Fixes #2964

.github/workflows/diff_shades.yml
CHANGES.md
src/black/__init__.py
tests/test_black.py

index 51fcebcff6347a84bc476ccb27a3e794cbba298b..0529b137572ca3b64ca4e7a90a0c396b3815f52e 100644 (file)
@@ -24,7 +24,7 @@ jobs:
 
       - name: Install diff-shades and support dependencies
         run: |
-          python -m pip install click packaging urllib3
+          python -m pip install 'click<8.1.0' packaging urllib3
           python -m pip install https://github.com/ichard26/diff-shades/archive/stable.zip
 
       - name: Calculate run configuration & metadata
@@ -59,7 +59,7 @@ jobs:
       - name: Install diff-shades and support dependencies
         run: |
           python -m pip install https://github.com/ichard26/diff-shades/archive/stable.zip
-          python -m pip install click packaging urllib3
+          python -m pip install 'click<8.1.0' packaging urllib3
           python -m pip install -r .github/mypyc-requirements.txt
           # After checking out old revisions, this might not exist so we'll use a copy.
           cat scripts/diff_shades_gha_helper.py > helper.py
index d34bd4ead58a7ccea253b23338d05dfedaea524b..02327fcbee9c5f872c48c5ebd84eb5763aed4fd1 100644 (file)
@@ -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
index a82cf6a6cd782644df4d0aa922a48f9c1b810a24..e9d3c1b795a8fa167a9c3bcb69320e9d5a39a302 100644 (file)
@@ -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"):
index b1bf1772550588d32fc6d5a8c2a630628542f1ad..ce7bab2f440ca770cd37964e2ff48f383fa07638 100644 (file)
@@ -1257,7 +1257,7 @@ class BlackTestCase(BlackBaseTestCase):
     def test_shhh_click(self) -> None:
         try:
             from click import _unicodefun
-        except ModuleNotFoundError:
+        except ImportError:
             self.skipTest("Incompatible Click version")
         if not hasattr(_unicodefun, "_verify_python3_env"):
             self.skipTest("Incompatible Click version")