diff --git a/chia/data_layer/data_layer.py b/chia/data_layer/data_layer.py index c0e8d8407ea9..034109e487f5 100644 --- a/chia/data_layer/data_layer.py +++ b/chia/data_layer/data_layer.py @@ -1036,7 +1036,13 @@ class DataLayer: coros = [get_plugin_info(plugin_remote=plugin) for plugin in {*self.uploaders, *self.downloaders}] results = dict(await asyncio.gather(*coros)) - uploader_status = {uploader.url: results.get(uploader.url, "unknown") for uploader in self.uploaders} - downloader_status = {downloader.url: results.get(downloader.url, "unknown") for downloader in self.downloaders} + unknown = { + "name": "unknown", + "version": "unknown", + "instance": "unknown", + } + + uploader_status = {uploader.url: results.get(uploader, unknown) for uploader in self.uploaders} + downloader_status = {downloader.url: results.get(downloader, unknown) for downloader in self.downloaders} return PluginStatus(uploaders=uploader_status, downloaders=downloader_status) diff --git a/chia/rpc/farmer_rpc_api.py b/chia/rpc/farmer_rpc_api.py index 0d5b79241eb6..24c6d64adad8 100644 --- a/chia/rpc/farmer_rpc_api.py +++ b/chia/rpc/farmer_rpc_api.py @@ -2,7 +2,7 @@ from __future__ import annotations import dataclasses import operator -from typing import Any, Callable, Dict, List, Optional +from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple from typing_extensions import Protocol @@ -18,19 +18,13 @@ from chia.util.streamable import Streamable, streamable from chia.util.ws_message import WsRpcMessage, create_payload_dict -@dataclasses.dataclass +@dataclasses.dataclass(frozen=True) class PaginatedRequestData(Protocol): - @property - def node_id(self) -> bytes32: - pass + node_id: bytes32 + page: uint32 + page_size: uint32 - @property - def page(self) -> uint32: - pass - - @property - def page_size(self) -> uint32: - pass + __match_args__: ClassVar[Tuple[str, ...]] = () @streamable @@ -50,6 +44,8 @@ class PlotInfoRequestData(Streamable): sort_key: str = "filename" reverse: bool = False + __match_args__: ClassVar[Tuple[str, ...]] = () + @streamable @dataclasses.dataclass(frozen=True) @@ -60,6 +56,8 @@ class PlotPathRequestData(Streamable): filter: List[str] = dataclasses.field(default_factory=list) reverse: bool = False + __match_args__: ClassVar[Tuple[str, ...]] = () + def paginated_plot_request(source: List[Any], request: PaginatedRequestData) -> Dict[str, object]: paginator: Paginator = Paginator(source, request.page_size) diff --git a/chia/util/keychain.py b/chia/util/keychain.py index f4baddfcfd7b..7e76635c896f 100644 --- a/chia/util/keychain.py +++ b/chia/util/keychain.py @@ -525,14 +525,14 @@ class Keychain: """ Returns whether a user-supplied passphrase is optional, as specified by the passphrase requirements. """ - return passphrase_requirements().get("is_optional", False) + return passphrase_requirements().get("is_optional", False) # type: ignore[no-any-return] @staticmethod def minimum_passphrase_length() -> int: """ Returns the minimum passphrase length, as specified by the passphrase requirements. """ - return passphrase_requirements().get("min_length", 0) + return passphrase_requirements().get("min_length", 0) # type: ignore[no-any-return] @staticmethod def passphrase_meets_requirements(passphrase: Optional[str]) -> bool: diff --git a/mypy.ini.template b/mypy.ini.template index a903d5c12fea..69f04397cc6c 100644 --- a/mypy.ini.template +++ b/mypy.ini.template @@ -16,7 +16,6 @@ warn_return_any = True no_implicit_reexport = True strict_equality = True warn_redundant_casts = True -enable_incomplete_feature = Unpack [mypy-chia-exclusions] disable_error_code = annotation-unchecked diff --git a/setup.py b/setup.py index 5ead9d698fbb..12c54a18dd02 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ dev_dependencies = [ "twine==4.0.2", "isort==5.12.0", "flake8==6.1.0", - "mypy==1.5.1", + "mypy==1.7.0", "black==23.10.1", "lxml==4.9.3", "aiohttp_cors==0.7.0", # For blackd diff --git a/tests/cmds/cmd_test_utils.py b/tests/cmds/cmd_test_utils.py index 9eb45a40ec15..c21c9f415b74 100644 --- a/tests/cmds/cmd_test_utils.py +++ b/tests/cmds/cmd_test_utils.py @@ -417,7 +417,7 @@ def create_service_and_wallet_client_generators(test_rpc_clients: TestRpcClients # For more information, read the docstring of this function. chia.cmds.cmds_util.get_any_service_client = test_get_any_service_client chia.cmds.cmds_util.get_wallet_client = test_get_wallet_client # type: ignore[assignment] - chia.cmds.wallet_funcs.get_wallet_client = test_get_wallet_client # type: ignore[attr-defined] + chia.cmds.wallet_funcs.get_wallet_client = test_get_wallet_client # type: ignore[assignment,attr-defined] # Monkey patches the confirm function to not ask for confirmation chia.cmds.cmds_util.cli_confirm = cli_confirm chia.cmds.wallet_funcs.cli_confirm = cli_confirm # type: ignore[attr-defined] diff --git a/tests/core/test_farmer_harvester_rpc.py b/tests/core/test_farmer_harvester_rpc.py index 48b8a8d5e130..4392af2c9729 100644 --- a/tests/core/test_farmer_harvester_rpc.py +++ b/tests/core/test_farmer_harvester_rpc.py @@ -440,18 +440,10 @@ async def test_farmer_get_harvester_plots_endpoints( await wait_for_plot_sync(receiver, last_sync_id) for page_size in [1, int(total_count / 2), total_count - 1, total_count, total_count + 1, 100]: - # TODO: figure out hinting of PaginatedRequestData that satisfies this with frozen attributes - request = dataclasses.replace( - request, - page_size=uint32(page_size), # type: ignore[call-arg] - ) + request = dataclasses.replace(request, page_size=uint32(page_size)) expected_page_count = ceil(total_count / page_size) for page in range(expected_page_count): - # TODO: figure out hinting of PaginatedRequestData that satisfies this with frozen attributes - request = dataclasses.replace( - request, - page=uint32(page), # type: ignore[call-arg] - ) + request = dataclasses.replace(request, page=uint32(page)) await wait_for_synced_receiver(farmer_service._api.farmer, harvester_id) page_result = await endpoint(farmer_rpc_client, request) offset = page * page_size