Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderDokuchaev committed Mar 25, 2022
1 parent a2bd710 commit 3bf3b3a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion external/anomaly/ote_anomalib/nncf_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def load_model(self, ote_model: Optional[ModelEntity]) -> AnomalyModule:
for key in model_data["model"].keys():
if key.startswith("model."):
new_key = key.replace("model.", "")
res = re.search("nncf_module\.(\w+)_backbone\.(.*)", new_key)
res = re.search(r"nncf_module\.(\w+)_backbone\.(.*)", new_key)
if res:
new_key = f"nncf_module.{res.group(1)}_model.backbone.{res.group(2)}"
nncf_modules[new_key] = model_data["model"][key]
Expand Down
4 changes: 2 additions & 2 deletions ote_sdk/ote_sdk/configuration/elements/parameter_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ def __eq__(self, other):
return False


TParameterGroup = TypeVar("TParameterGroup", bound=ParameterGroup)
_ParameterGroup = TypeVar("_ParameterGroup", bound=ParameterGroup)


def add_parameter_group(group: Type[TParameterGroup]) -> TParameterGroup:
def add_parameter_group(group: Type[_ParameterGroup]) -> _ParameterGroup:
"""
Wrapper to attr.ib to add nested parameter groups to a configuration.
"""
Expand Down
10 changes: 5 additions & 5 deletions ote_sdk/ote_sdk/configuration/elements/primitive_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

# pylint:disable=too-many-arguments

TConfigurableEnum = TypeVar("TConfigurableEnum", bound=ConfigurableEnum)
_ConfigurableEnum = TypeVar("_ConfigurableEnum", bound=ConfigurableEnum)


def set_common_metadata(
Expand Down Expand Up @@ -350,7 +350,7 @@ class for more details. Defaults to NullUIRules.


def selectable(
default_value: TConfigurableEnum,
default_value: _ConfigurableEnum,
header: str,
description: str = "Default selectable description",
warning: str = None,
Expand All @@ -360,7 +360,7 @@ def selectable(
ui_rules: UIRules = NullUIRules(),
auto_hpo_state: AutoHPOState = AutoHPOState.NOT_POSSIBLE,
auto_hpo_value: Optional[str] = None,
) -> TConfigurableEnum:
) -> _ConfigurableEnum:
"""
Constructs a selectable attribute from a pre-defined Enum, with the appropriate metadata. The list of options for
display in the UI is inferred from the type of the ConfigurableEnum instance passed in as default_value.
Expand Down Expand Up @@ -408,8 +408,8 @@ class for more details. Defaults to NullUIRules.
type_validator = attr.validators.instance_of(ConfigurableEnum)
value_validator = construct_attr_enum_selectable_onsetattr(default_value)

# The Attribute returned by attr.ib is not compatible with the return typevar TConfigurableEnum. However, as the
# class containing the Attribute is instantiated the selectable type will correspond to the TConfigurableEnum, so
# The Attribute returned by attr.ib is not compatible with the return typevar _ConfigurableEnum. However, as the
# class containing the Attribute is instantiated the selectable type will correspond to the _ConfigurableEnum, so
# mypy can ignore the error.
return attr.ib(
default=default_value,
Expand Down
10 changes: 5 additions & 5 deletions ote_sdk/ote_sdk/entities/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,11 @@ def __repr__(self):
)


MetricType = TypeVar("MetricType", bound=MetricEntity)
VisualizationInfoType = TypeVar("VisualizationInfoType", bound=VisualizationInfo)
_MetricType = TypeVar("_MetricType", bound=MetricEntity)
_VisualizationInfoType = TypeVar("_VisualizationInfoType", bound=VisualizationInfo)


class MetricsGroup(Generic[MetricType, VisualizationInfoType]):
class MetricsGroup(Generic[_MetricType, _VisualizationInfoType]):
"""
This class aggregates a list of metric entities and defines how this group will be
visualized on the UI. This class is the parent class to the different types of
Expand All @@ -571,7 +571,7 @@ class MetricsGroup(Generic[MetricType, VisualizationInfoType]):
:example: An accuracy as a metrics group
>>> acc = ScoreMetric("Accuracy", 0.5)
>>> visual_info = BarChartInfo("Accuracy", visualization_type=VisualizationInfoType.BAR) # show it as radial bar
>>> visual_info = BarChartInfo("Accuracy", visualization_type=_VisualizationInfoType.BAR) # show it as radial bar
>>> metrics_group = BarMetricsGroup([acc], visual_info)
Loss curves as a metrics group
Expand All @@ -583,7 +583,7 @@ class MetricsGroup(Generic[MetricType, VisualizationInfoType]):
"""

def __init__(
self, metrics: Sequence[MetricType], visualization_info: VisualizationInfoType
self, metrics: Sequence[_MetricType], visualization_info: _VisualizationInfoType
):
if metrics is None or len(metrics) == 0:
raise ValueError("Metrics cannot be None or empty")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def __init__(self, path: str) -> None:
self.media_type = MediaType.IMAGE
self.filenames = _get_filenames(path=path, media_type=MediaType.IMAGE)

#pylint: disable=arguments-differ
@staticmethod
def get_stream(stream_input: str) -> Iterable[np.ndarray]:
image = cv2.imread(stream_input)
Expand Down
6 changes: 3 additions & 3 deletions ote_sdk/ote_sdk/utils/shape_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@

CvTextSize = NewType("CvTextSize", Tuple[Tuple[int, int], int])

AnyType = TypeVar("AnyType")
_AnyType = TypeVar("_AnyType")


class DrawerEntity(Generic[AnyType]):
class DrawerEntity(Generic[_AnyType]):
"""
An interface to draw a shape of type ``T`` onto an image.
"""
Expand All @@ -52,7 +52,7 @@ class DrawerEntity(Generic[AnyType]):

@abc.abstractmethod
def draw(
self, image: np.ndarray, entity: AnyType, labels: List[ScoredLabel]
self, image: np.ndarray, entity: _AnyType, labels: List[ScoredLabel]
) -> np.ndarray:
"""
Draw an entity to a given frame
Expand Down

0 comments on commit 3bf3b3a

Please sign in to comment.