Skip to content

Commit

Permalink
final from typing is removed as it sets the constraint to have pyth…
Browse files Browse the repository at this point in the history
…on>=3.8.
  • Loading branch information
devrimcavusoglu committed Jun 8, 2022
1 parent 771bdd9 commit e6daf22
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pybboxes/types/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABC, abstractmethod
from typing import List, Tuple, Union, final
from typing import List, Tuple, Union

import numpy as np

Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(
self.strict = strict
v1, v2, v3, v4 = self._correct_value_types(v1, v2, v3, v4)
self._validate_values(v1, v2, v3, v4)
self._set_values(v1, v2, v3, v4)
self.__set_values(v1, v2, v3, v4)
voc_values = self.to_voc(return_values=True)
super(BaseBoundingBox, self).__init__(*voc_values)

Expand Down Expand Up @@ -96,8 +96,10 @@ def _correct_value_types(self, *values) -> Tuple:
def _validate_values(self, *values):
pass

@final
def _set_values(self, *values):
def __set_values(self, *values):
"""
This method is intended to be "final", and should not be overridden in child classes.
"""
self._values = values

def to_albumentations(self, return_values: bool = False) -> Union[Tuple[int, int, int, int], "BaseBoundingBox"]:
Expand Down Expand Up @@ -130,8 +132,10 @@ def from_voc(
pass

@classmethod
@final
def from_array(cls, ar: Union[Tuple, List, np.ndarray], **kwargs):
"""
This method is intended to be "final", and should not be overridden in child classes.
"""
if len(ar) != 4:
raise ValueError(f"Given array must be length of 4, got length {len(ar)}.")
return cls(*ar, **kwargs)

0 comments on commit e6daf22

Please sign in to comment.