From 010d5729a424daf103bc6a1e3b13cc136e06504f Mon Sep 17 00:00:00 2001 From: unexcellent <> Date: Tue, 29 Oct 2024 17:37:14 +0100 Subject: [PATCH] lint: enable ruff RUF012 rule --- pyproject.toml | 1 - raillabel/filter/_filter_classes/_filter_annotation_ids.py | 5 +++-- .../filter/_filter_classes/_filter_annotation_types.py | 5 +++-- raillabel/filter/_filter_classes/_filter_attributes.py | 5 +++-- raillabel/filter/_filter_classes/_filter_end.py | 5 +++-- raillabel/filter/_filter_classes/_filter_frames.py | 6 ++++-- raillabel/filter/_filter_classes/_filter_object_ids.py | 5 +++-- raillabel/filter/_filter_classes/_filter_object_types.py | 5 +++-- raillabel/filter/_filter_classes/_filter_sensors.py | 5 +++-- raillabel/filter/_filter_classes/_filter_start.py | 5 +++-- raillabel/format/bbox.py | 3 ++- raillabel/format/cuboid.py | 3 ++- raillabel/format/poly2d.py | 3 ++- raillabel/format/poly3d.py | 3 ++- raillabel/format/seg3d.py | 3 ++- 15 files changed, 38 insertions(+), 24 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0c3af99..5624541 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,6 @@ ignore = [ "TRY003", "D417", "A002", - "RUF012", ] [tool.mypy] diff --git a/raillabel/filter/_filter_classes/_filter_annotation_ids.py b/raillabel/filter/_filter_classes/_filter_annotation_ids.py index 8ed3738..b460fce 100644 --- a/raillabel/filter/_filter_classes/_filter_annotation_ids.py +++ b/raillabel/filter/_filter_classes/_filter_annotation_ids.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 import typing as t +from typing import ClassVar from ._filter_abc import _FilterABC, _ObjectAnnotation class _FilterAnnotationIds(_FilterABC): - PARAMETERS = ["include_annotation_ids", "exclude_annotation_ids"] - LEVELS = ["annotation"] + PARAMETERS: ClassVar = ["include_annotation_ids", "exclude_annotation_ids"] + LEVELS: ClassVar = ["annotation"] def passes_filter(self, annotation: t.Type[_ObjectAnnotation]) -> bool: if self.include_annotation_ids is not None: diff --git a/raillabel/filter/_filter_classes/_filter_annotation_types.py b/raillabel/filter/_filter_classes/_filter_annotation_types.py index 328bbc5..e44d673 100644 --- a/raillabel/filter/_filter_classes/_filter_annotation_types.py +++ b/raillabel/filter/_filter_classes/_filter_annotation_types.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 import typing as t +from typing import ClassVar from ._filter_abc import _FilterABC, _ObjectAnnotation class _FilterAnnotationTypes(_FilterABC): - PARAMETERS = ["include_annotation_types", "exclude_annotation_types"] - LEVELS = ["annotation"] + PARAMETERS: ClassVar = ["include_annotation_types", "exclude_annotation_types"] + LEVELS: ClassVar = ["annotation"] def passes_filter(self, annotation: t.Type[_ObjectAnnotation]) -> bool: if self.include_annotation_types is not None: diff --git a/raillabel/filter/_filter_classes/_filter_attributes.py b/raillabel/filter/_filter_classes/_filter_attributes.py index d4f93dd..44a8263 100644 --- a/raillabel/filter/_filter_classes/_filter_attributes.py +++ b/raillabel/filter/_filter_classes/_filter_attributes.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 import typing as t +from typing import ClassVar from ._filter_abc import _FilterABC, _ObjectAnnotation class _FilterAttributes(_FilterABC): - PARAMETERS = ["include_attributes", "exclude_attributes"] - LEVELS = ["annotation"] + PARAMETERS: ClassVar = ["include_attributes", "exclude_attributes"] + LEVELS: ClassVar = ["annotation"] def passes_filter(self, annotation: t.Type[_ObjectAnnotation]) -> bool: if self.include_attributes is not None: diff --git a/raillabel/filter/_filter_classes/_filter_end.py b/raillabel/filter/_filter_classes/_filter_end.py index f7edc7b..cc97667 100644 --- a/raillabel/filter/_filter_classes/_filter_end.py +++ b/raillabel/filter/_filter_classes/_filter_end.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 from decimal import Decimal +from typing import ClassVar from ._filter_abc import Frame, _FilterABC class _FilterEnd(_FilterABC): - PARAMETERS = ["end_frame", "end_timestamp"] - LEVELS = ["frame"] + PARAMETERS: ClassVar = ["end_frame", "end_timestamp"] + LEVELS: ClassVar = ["frame"] def passes_filter(self, frame: Frame) -> bool: if self.end_frame is not None: diff --git a/raillabel/filter/_filter_classes/_filter_frames.py b/raillabel/filter/_filter_classes/_filter_frames.py index 02130fc..b2ee895 100644 --- a/raillabel/filter/_filter_classes/_filter_frames.py +++ b/raillabel/filter/_filter_classes/_filter_frames.py @@ -1,12 +1,14 @@ # Copyright DB InfraGO AG and contributors # SPDX-License-Identifier: Apache-2.0 +from typing import ClassVar + from ._filter_abc import Frame, _FilterABC class _FilterFrame(_FilterABC): - PARAMETERS = ["include_frames", "exclude_frames"] - LEVELS = ["frame"] + PARAMETERS: ClassVar = ["include_frames", "exclude_frames"] + LEVELS: ClassVar = ["frame"] def passes_filter(self, frame: Frame) -> bool: if self.include_frames is not None: diff --git a/raillabel/filter/_filter_classes/_filter_object_ids.py b/raillabel/filter/_filter_classes/_filter_object_ids.py index 600ecaa..fe85bc4 100644 --- a/raillabel/filter/_filter_classes/_filter_object_ids.py +++ b/raillabel/filter/_filter_classes/_filter_object_ids.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 import typing as t +from typing import ClassVar from ._filter_abc import _FilterABC, _ObjectAnnotation class _FilterObjectIds(_FilterABC): - PARAMETERS = ["include_object_ids", "exclude_object_ids"] - LEVELS = ["annotation"] + PARAMETERS: ClassVar = ["include_object_ids", "exclude_object_ids"] + LEVELS: ClassVar = ["annotation"] def passes_filter(self, annotation: t.Type[_ObjectAnnotation]) -> bool: if self.include_object_ids is not None: diff --git a/raillabel/filter/_filter_classes/_filter_object_types.py b/raillabel/filter/_filter_classes/_filter_object_types.py index 35150d5..01d708d 100644 --- a/raillabel/filter/_filter_classes/_filter_object_types.py +++ b/raillabel/filter/_filter_classes/_filter_object_types.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 import typing as t +from typing import ClassVar from ._filter_abc import _FilterABC, _ObjectAnnotation class _FilterObjectTypes(_FilterABC): - PARAMETERS = ["include_object_types", "exclude_object_types"] - LEVELS = ["annotation"] + PARAMETERS: ClassVar = ["include_object_types", "exclude_object_types"] + LEVELS: ClassVar = ["annotation"] def passes_filter(self, annotation: t.Type[_ObjectAnnotation]) -> bool: if self.include_object_types is not None: diff --git a/raillabel/filter/_filter_classes/_filter_sensors.py b/raillabel/filter/_filter_classes/_filter_sensors.py index 5c4f98e..4aa65f9 100644 --- a/raillabel/filter/_filter_classes/_filter_sensors.py +++ b/raillabel/filter/_filter_classes/_filter_sensors.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 import typing as t +from typing import ClassVar from ._filter_abc import _FilterABC, _ObjectAnnotation class _FilterSensors(_FilterABC): - PARAMETERS = ["include_sensors", "exclude_sensors"] - LEVELS = ["frame_data", "annotation"] + PARAMETERS: ClassVar = ["include_sensors", "exclude_sensors"] + LEVELS: ClassVar = ["frame_data", "annotation"] def passes_filter(self, annotation: t.Type[_ObjectAnnotation]) -> bool: if self.include_sensors is not None: diff --git a/raillabel/filter/_filter_classes/_filter_start.py b/raillabel/filter/_filter_classes/_filter_start.py index 684049b..7a0bd17 100644 --- a/raillabel/filter/_filter_classes/_filter_start.py +++ b/raillabel/filter/_filter_classes/_filter_start.py @@ -2,13 +2,14 @@ # SPDX-License-Identifier: Apache-2.0 from decimal import Decimal +from typing import ClassVar from ._filter_abc import Frame, _FilterABC class _FilterStart(_FilterABC): - PARAMETERS = ["start_frame", "start_timestamp"] - LEVELS = ["frame"] + PARAMETERS: ClassVar = ["start_frame", "start_timestamp"] + LEVELS: ClassVar = ["frame"] def passes_filter(self, frame: Frame) -> bool: if self.start_frame is not None: diff --git a/raillabel/format/bbox.py b/raillabel/format/bbox.py index 5f44cb2..df04322 100644 --- a/raillabel/format/bbox.py +++ b/raillabel/format/bbox.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 from dataclasses import dataclass +from typing import ClassVar from ._object_annotation import _ObjectAnnotation from .object import Object @@ -40,7 +41,7 @@ class Bbox(_ObjectAnnotation): size: Size2d = None OPENLABEL_ID = "bbox" - _REQ_FIELDS = ["pos", "size"] + _REQ_FIELDS: ClassVar = ["pos", "size"] @classmethod def fromdict(cls, data_dict: dict, sensors: dict, object: Object) -> "Bbox": diff --git a/raillabel/format/cuboid.py b/raillabel/format/cuboid.py index e218d05..8f5999c 100644 --- a/raillabel/format/cuboid.py +++ b/raillabel/format/cuboid.py @@ -2,6 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 from dataclasses import dataclass +from typing import ClassVar from ._object_annotation import _ObjectAnnotation from .object import Object @@ -45,7 +46,7 @@ class Cuboid(_ObjectAnnotation): size: Size3d = None OPENLABEL_ID = "cuboid" - _REQ_FIELDS = ["pos", "size", "quat"] + _REQ_FIELDS: ClassVar = ["pos", "size", "quat"] @classmethod def fromdict(cls, data_dict: dict, sensors: dict, object: Object) -> "Cuboid": diff --git a/raillabel/format/poly2d.py b/raillabel/format/poly2d.py index a6a19fc..8207445 100644 --- a/raillabel/format/poly2d.py +++ b/raillabel/format/poly2d.py @@ -3,6 +3,7 @@ import typing as t from dataclasses import dataclass +from typing import ClassVar from ._object_annotation import _ObjectAnnotation from .object import Object @@ -49,7 +50,7 @@ class Poly2d(_ObjectAnnotation): mode: str = "MODE_POLY2D_ABSOLUTE" OPENLABEL_ID = "poly2d" - _REQ_FIELDS = ["points", "closed"] + _REQ_FIELDS: ClassVar = ["points", "closed"] @classmethod def fromdict(cls, data_dict: dict, sensors: dict, object: Object) -> "Poly2d": diff --git a/raillabel/format/poly3d.py b/raillabel/format/poly3d.py index bc9ae0e..a4334eb 100644 --- a/raillabel/format/poly3d.py +++ b/raillabel/format/poly3d.py @@ -3,6 +3,7 @@ import typing as t from dataclasses import dataclass +from typing import ClassVar from ._object_annotation import _ObjectAnnotation from .object import Object @@ -41,7 +42,7 @@ class Poly3d(_ObjectAnnotation): closed: bool = None OPENLABEL_ID = "poly3d" - _REQ_FIELDS = ["points", "closed"] + _REQ_FIELDS: ClassVar = ["points", "closed"] @classmethod def fromdict(cls, data_dict: dict, sensors: dict, object: Object) -> "Poly3d": diff --git a/raillabel/format/seg3d.py b/raillabel/format/seg3d.py index 5cdbb3b..872877c 100644 --- a/raillabel/format/seg3d.py +++ b/raillabel/format/seg3d.py @@ -3,6 +3,7 @@ import typing as t from dataclasses import dataclass +from typing import ClassVar from ._object_annotation import _ObjectAnnotation from .object import Object @@ -36,7 +37,7 @@ class Seg3d(_ObjectAnnotation): point_ids: t.List[int] = None OPENLABEL_ID = "vec" - _REQ_FIELDS = ["point_ids"] + _REQ_FIELDS: ClassVar = ["point_ids"] @classmethod def fromdict(cls, data_dict: dict, sensors: dict, object: Object) -> "Seg3d":