Skip to content

Commit

Permalink
lint: enable ruff RUF012 rule
Browse files Browse the repository at this point in the history
  • Loading branch information
unexcellent committed Oct 29, 2024
1 parent d56c521 commit 010d572
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 24 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ ignore = [
"TRY003",
"D417",
"A002",
"RUF012",
]

[tool.mypy]
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_annotation_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_annotation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions raillabel/filter/_filter_classes/_filter_frames.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_object_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_object_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions raillabel/filter/_filter_classes/_filter_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion raillabel/format/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
3 changes: 2 additions & 1 deletion raillabel/format/cuboid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
3 changes: 2 additions & 1 deletion raillabel/format/poly2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
3 changes: 2 additions & 1 deletion raillabel/format/poly3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down
3 changes: 2 additions & 1 deletion raillabel/format/seg3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 010d572

Please sign in to comment.