Skip to content

Commit

Permalink
use fresh abcs
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Feb 9, 2025
1 parent 036cce8 commit 6ddd9dc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions numcodecs/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"""

from abc import ABC, abstractmethod
from typing import ClassVar
from typing import Optional


class Codec(ABC):
"""Codec abstract base class."""

# override in sub-class
codec_id: ClassVar[str]
codec_id: Optional[str] = None
"""Codec identifier."""

@abstractmethod
Expand Down Expand Up @@ -106,14 +106,14 @@ def from_config(cls, config):
# keyword arguments without any special decoding
return cls(**config)

def __eq__(self, other: object) -> bool:
def __eq__(self, other):
# override in sub-class if need special equality comparison
try:
return self.get_config() == other.get_config() # type: ignore[attr-defined]
return self.get_config() == other.get_config()
except AttributeError:
return False

def __repr__(self) -> str:
def __repr__(self):
# override in sub-class if need special representation

# by default, assume all non-private members are configuration
Expand Down

0 comments on commit 6ddd9dc

Please sign in to comment.