fix: better error message in python < 3.9
@@ -29,8 +29,7 @@ class StoreItem(Exportable):
raise NotImplementedError
@classmethod
- @property
- def typename(cls) -> str:
+ def get_typename(cls) -> str:
return cls.__name__
@property
@@ -48,7 +47,7 @@ class StoreItem(Exportable):
raise NotImplementedError
def __repr__(self):
- return f'{self.typename}(tag="{self.tag}")'
+ return f'{self.get_typename()}(tag="{self.tag}")'
Item = t.TypeVar("Item", bound=StoreItem)
@@ -85,7 +84,7 @@ class Store(ABC, t.Generic[Item]):
if _tag.version is None:
if not self._fs.isdir(_tag.name):
raise NotFound(
- f"no {self._item_type.typename}s with name '{_tag.name}' found"
+ f"no {self._item_type.get_typename()}s with name '{_tag.name}' found"
)
tags = sorted(
@@ -117,7 +116,7 @@ class Store(ABC, t.Generic[Item]):
_tag.version = self._fs.readtext(_tag.latest_path())
except fs.errors.ResourceNotFound:
raise NotFound(
- f"no {self._item_type.typename}s with name '{_tag.name}' exist in BentoML store {self._fs}"
+ f"no {self._item_type.get_typename()}s with name '{_tag.name}' exist in BentoML store {self._fs}"
)
path = _tag.path()
@@ -128,7 +127,7 @@ class Store(ABC, t.Generic[Item]):
counts = matches.count().directories
if counts == 0:
raise NotFound(
- f"{self._item_type.typename} '{tag}' is not found in BentoML store {self._fs}"
+ f"{self._item_type.get_typename()} '{tag}' is not found in BentoML store {self._fs}"
)
elif counts == 1:
match = next(iter(matches))
@@ -166,7 +165,7 @@ class Store(ABC, t.Generic[Item]):
_tag = Tag.from_taglike(tag)
if not self._fs.exists(_tag.path()):
- raise NotFound(f"{self._item_type.typename} '{tag}' not found")
+ raise NotFound(f"{self._item_type.get_typename()} '{tag}' not found")
self._fs.removetree(_tag.path())
if self._fs.isdir(_tag.name):
