Skip to content

Commit

Permalink
lint: make mypy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
nalquas committed Dec 2, 2024
1 parent 9ea9e29 commit c1815d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def supports(cls, data_dict: dict) -> bool:

@classmethod
@abc.abstractmethod
def fromdict(cls, data_dict: dict) -> type[_Attribute]:
def fromdict(cls, data_dict: dict) -> _Attribute:
raise NotImplementedError

@abc.abstractmethod
Expand Down Expand Up @@ -48,5 +48,5 @@ def _collect_attribute_classes() -> None:
ATTRIBUTE_CLASSES.append(class_)


ATTRIBUTE_CLASSES = []
ATTRIBUTE_CLASSES: list[type[_Attribute]] = []
_collect_attribute_classes()
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ def fromdict(cls, data_dict: dict) -> _MultiSelectAttribute:
return _MultiSelectAttribute(options=set(data_dict["options"]))

def check(
self, attribute_name: str, attribute_values: bool | float | str | list, annotation_id: str
self, attribute_name: str, attribute_value: bool | float | str | list, annotation_id: str
) -> list[str]:
if type(attribute_values) is not list:
if type(attribute_value) is not list:
return [
f"Attribute '{attribute_name}' of annotation {annotation_id} is of type "
f"'{attribute_values.__class__.__name__}' (should be 'list')."
f"'{attribute_value.__class__.__name__}' (should be 'list')."
]

for attribute_value in attribute_values:
if attribute_value not in self.options:
for single_value in attribute_value:
if single_value not in self.options:
return [
f"Attribute '{attribute_name}' of annotation {annotation_id} has an undefined "
f"value '{attribute_value}' (defined options: {self._stringify_options()})."
f"value '{single_value}' (defined options: {self._stringify_options()})."
]

return []
Expand Down

0 comments on commit c1815d9

Please sign in to comment.