Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions bittensor_cli/src/bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading