From be16cfa0353f33adf0ee5f026d9b46f9ca6ac7ac Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Tue, 22 Jun 2021 18:58:49 +0300 Subject: [PATCH] Get `click` types from main repo (#2344) Click types have been moved to click repo itself. See pallets/click#1856 I've had some issues with typeshed types being outdated in another project so might be good to avoid that here. Commit history before merge: * Get `click` types from main repo * Fix mypy errors * Require click v8 for type annotations * Update Pipfile --- .pre-commit-config.yaml | 2 +- Pipfile | 3 +-- Pipfile.lock | 10 +--------- tests/test_black.py | 9 ++++++--- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 920ae66..79795d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - types-dataclasses >= 0.1.3 - types-toml >= 0.1.1 - types-typed-ast >= 1.4.1 - - types-click >= 7.1.2 + - click >= 8.0.0 - repo: https://github.com/pre-commit/mirrors-prettier rev: v2.3.1 diff --git a/Pipfile b/Pipfile index f617fdc..a27614c 100644 --- a/Pipfile +++ b/Pipfile @@ -10,7 +10,6 @@ docutils = "==0.15" # not a direct dependency, see https://github.com/pypa/pipe flake8 = "*" flake8-bugbear = "*" mypy = ">=0.812" -types-click = ">=7.1.2" types-dataclasses = ">=0.1.3" types-toml = ">=0.1.1" types-typed-ast = ">=1.4.1" @@ -29,7 +28,7 @@ black = {editable = true, extras = ["d"], path = "."} aiohttp = ">=3.6.0" aiohttp-cors = ">=0.4.0" appdirs = "*" -click = ">=7.1.2" +click = ">=8.0.0" mypy_extensions = ">=0.4.3" pathspec = ">=0.8.1" regex = ">=2020.1.8" diff --git a/Pipfile.lock b/Pipfile.lock index 17140de..d22131e 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "18ff16725509d6d14f44e3a96fe620730c9adfdaa87cbeee74aa397913dedaab" + "sha256": "0c126694d1a1cd1c4dc875a99f330f6b9a5994e51a1f870a98dbacd0185dae53" }, "pipfile-spec": 6, "requires": {}, @@ -1188,14 +1188,6 @@ "index": "pypi", "version": "==3.4.1" }, - "types-click": { - "hashes": [ - "sha256:040897284e4f9466825c3865f708a985a8e7ba4d8e22cb9198ffb7b522160850", - "sha256:4722746f1ec9fd3fc8b1d7fb8c840604dc22f9e32bcc7a31a36d6d85cc2bce24" - ], - "index": "pypi", - "version": "==7.1.2" - }, "types-dataclasses": { "hashes": [ "sha256:7b5f4099fb21c209f2df3a83c2b64308c29955769d610a457244dc0eebe1cafc", diff --git a/tests/test_black.py b/tests/test_black.py index 455cb33..5262c0e 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -119,6 +119,8 @@ class BlackTestCase(BlackBaseTestCase): if ignore_config: args = ["--verbose", "--config", str(THIS_DIR / "empty.toml"), *args] result = runner.invoke(black.main, args) + assert result.stdout_bytes is not None + assert result.stderr_bytes is not None self.assertEqual( result.exit_code, exit_code, @@ -465,6 +467,7 @@ class BlackTestCase(BlackBaseTestCase): self.assertEqual(result.exit_code, 123) finally: os.unlink(tmp_file) + assert result.stderr_bytes is not None actual = ( result.stderr_bytes.decode() .replace("\n", "") @@ -1892,7 +1895,7 @@ class BlackTestCase(BlackBaseTestCase): def test_shhh_click(self) -> None: try: - from click import _unicodefun # type: ignore + from click import _unicodefun except ModuleNotFoundError: self.skipTest("Incompatible Click version") if not hasattr(_unicodefun, "_verify_python3_env"): @@ -1901,14 +1904,14 @@ class BlackTestCase(BlackBaseTestCase): with patch("locale.getpreferredencoding") as gpe: gpe.return_value = "ASCII" with self.assertRaises(RuntimeError): - _unicodefun._verify_python3_env() + _unicodefun._verify_python3_env() # type: ignore # Now, let's silence Click... black.patch_click() # ...and confirm it's silent. with patch("locale.getpreferredencoding") as gpe: gpe.return_value = "ASCII" try: - _unicodefun._verify_python3_env() + _unicodefun._verify_python3_env() # type: ignore except RuntimeError as re: self.fail(f"`patch_click()` failed, exception still raised: {re}") -- 2.39.2