diff --git a/bittensor_cli/src/bittensor/chain_data.py b/bittensor_cli/src/bittensor/chain_data.py index 8d9723e05..b5df2bd37 100644 --- a/bittensor_cli/src/bittensor/chain_data.py +++ b/bittensor_cli/src/bittensor/chain_data.py @@ -17,6 +17,11 @@ get_netuid_and_subuid_by_storage_index, ) +try: + from typing import Self +except ImportError: + from typing_extensions import Self + class ChainDataType(Enum): NeuronInfo = 1 @@ -134,17 +139,17 @@ class InfoBase: """Base dataclass for info objects.""" @abstractmethod - def _fix_decoded(self, decoded: Any) -> "InfoBase": + def _fix_decoded(self, decoded: Any) -> Self: raise NotImplementedError( "This is an abstract method and must be implemented in a subclass." ) @classmethod - def from_any(cls, data: Any) -> "InfoBase": + def from_any(cls, data: Any) -> Self: return cls._fix_decoded(data) @classmethod - def list_from_any(cls, data_list: list[Any]) -> list["InfoBase"]: + def list_from_any(cls, data_list: list[Any]) -> list[Self]: return [cls.from_any(data) for data in data_list] def __getitem__(self, item): diff --git a/pyproject.toml b/pyproject.toml index 743c035de..719d7d035 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ dependencies = [ "rich>=13.7,<15.0", "scalecodec==1.2.12", "typer>=0.16", + "typing_extensions>4.0.0; python_version<'3.11'", "bittensor-wallet>=4.0.0", "packaging", "plotille>=5.0.0",