From 90426f84d8c95d0ef40327784a67a6c7f9a9c8c1 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Fri, 14 Jan 2022 23:35:59 -0500 Subject: [PATCH 1/6] Unpin mypy --- setup.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 6695ab18782e..3658a6b28266 100644 --- a/setup.py +++ b/setup.py @@ -38,10 +38,6 @@ upnp_dependencies = [ "miniupnpc==2.2.2", # Allows users to open ports on their router ] -# TODO: unpin mypy and types-click after mypy's next release. types-click >=0.1.13 -# depends on changes made to typeshed after the version used in the most recent -# release of mypy, 0.910. -# https://github.com/python/typeshed/commit/7a9a107a63c5f4b938563ed6f8d934dc4b1de2c3 dev_dependencies = [ "pre-commit", "pytest", @@ -49,7 +45,7 @@ dev_dependencies = [ "pytest-monitor; sys_platform == 'linux'", "pytest-xdist", "flake8", - "mypy==0.910", + "mypy", "black", "aiohttp_cors", # For blackd "ipython", # For asyncio debugging From 690d94555d92f81eb2c794ba01e291dc5856cadb Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 15 Jan 2022 00:29:07 -0500 Subject: [PATCH 2/6] unpin types-click as well --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3658a6b28266..6d7aaa87d1e5 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ dev_dependencies = [ "aiohttp_cors", # For blackd "ipython", # For asyncio debugging "types-aiofiles", - "types-click==0.1.12", + "types-click~=7.1", "types-cryptography", "types-pkg_resources", "types-pyyaml", From 1e682b2b3f968486beed95236e30fb73fc3b33b9 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 15 Jan 2022 00:47:07 -0500 Subject: [PATCH 3/6] from _typeshed import IdentityFunction --- chia/cmds/data.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/chia/cmds/data.py b/chia/cmds/data.py index 13ebb5de0c92..7e04bccce2e1 100644 --- a/chia/cmds/data.py +++ b/chia/cmds/data.py @@ -6,9 +6,7 @@ import click if TYPE_CHECKING: - # Will be located here in the next mypy release - # from _typeshed import IdentityFunction - from click.decorators import _IdentityFunction as IdentityFunction + from _typeshed import IdentityFunction logger = logging.getLogger(__name__) From 4711f344cae9fdf080cc59b0765a4aad342cec68 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 15 Jan 2022 00:52:16 -0500 Subject: [PATCH 4/6] provide our own IdentityFunction for clicky decorators --- chia/cmds/data.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/chia/cmds/data.py b/chia/cmds/data.py index 7e04bccce2e1..20b2963695e8 100644 --- a/chia/cmds/data.py +++ b/chia/cmds/data.py @@ -1,12 +1,16 @@ import json import logging -from typing import Any, Coroutine, Dict, Optional, TYPE_CHECKING +from typing import Any, Coroutine, Dict, Optional, TYPE_CHECKING, TypeVar import click +from typing_extensions import Protocol -if TYPE_CHECKING: - from _typeshed import IdentityFunction +_T = TypeVar("_T") + + +class IdentityFunction(Protocol): + def __call__(self, __x: _T) -> _T: ... logger = logging.getLogger(__name__) @@ -34,7 +38,7 @@ def data_cmd() -> None: # malformed inputs. -def create_changelist_option() -> "IdentityFunction": +def create_changelist_option() -> IdentityFunction: return click.option( "-d", "--changelist", @@ -45,7 +49,7 @@ def create_changelist_option() -> "IdentityFunction": ) -def create_key_option() -> "IdentityFunction": +def create_key_option() -> IdentityFunction: return click.option( "-h", "--key", @@ -56,7 +60,7 @@ def create_key_option() -> "IdentityFunction": ) -def create_kv_store_id_option() -> "IdentityFunction": +def create_kv_store_id_option() -> IdentityFunction: return click.option( "-store", "-id", @@ -66,7 +70,7 @@ def create_kv_store_id_option() -> "IdentityFunction": ) -def create_kv_store_name_option() -> "IdentityFunction": +def create_kv_store_name_option() -> IdentityFunction: return click.option( "-n", "--table_name", @@ -77,7 +81,7 @@ def create_kv_store_name_option() -> "IdentityFunction": ) -def create_rpc_port_option() -> "IdentityFunction": +def create_rpc_port_option() -> IdentityFunction: return click.option( "-dp", "--data-rpc-port", From 9eeeb2be0a0674ccf5d6a8e2c45ca2dc51f361f5 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 15 Jan 2022 09:45:27 -0500 Subject: [PATCH 5/6] black --- chia/cmds/data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chia/cmds/data.py b/chia/cmds/data.py index 20b2963695e8..55fe1edf8c46 100644 --- a/chia/cmds/data.py +++ b/chia/cmds/data.py @@ -10,7 +10,8 @@ _T = TypeVar("_T") class IdentityFunction(Protocol): - def __call__(self, __x: _T) -> _T: ... + def __call__(self, __x: _T) -> _T: + ... logger = logging.getLogger(__name__) From 1c591361e552a0292d623ed4734eb785c2b378db Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 15 Jan 2022 09:48:58 -0500 Subject: [PATCH 6/6] flake8 --- chia/cmds/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chia/cmds/data.py b/chia/cmds/data.py index 55fe1edf8c46..2e8b6965ebb1 100644 --- a/chia/cmds/data.py +++ b/chia/cmds/data.py @@ -1,6 +1,6 @@ import json import logging -from typing import Any, Coroutine, Dict, Optional, TYPE_CHECKING, TypeVar +from typing import Any, Coroutine, Dict, Optional, TypeVar import click from typing_extensions import Protocol