Skip to content

Commit

Permalink
Get click types from main repo (#2344)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hukkin committed Jun 22, 2021
1 parent 3980b4b commit be16cfa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Pipfile
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 1 addition & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions tests/test_black.py
Expand Up @@ -119,6 +119,8 @@ def invokeBlack(
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,
Expand Down Expand Up @@ -465,6 +467,7 @@ def test_python2_should_fail_without_optional_install(self) -> None:
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", "")
Expand Down Expand Up @@ -1892,7 +1895,7 @@ def test_symlink_out_of_root_directory(self) -> None:

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"):
Expand All @@ -1901,14 +1904,14 @@ def test_shhh_click(self) -> None:
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}")

Expand Down

0 comments on commit be16cfa

Please sign in to comment.