diff --git a/pyproject.toml b/pyproject.toml index fa30371..154617e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,6 @@ ignore = [ # to be removed later "TID252", "FA100", - "PERF401", ] [tool.mypy] diff --git a/raillabel_providerkit/convert/convert.py b/raillabel_providerkit/convert/convert.py index 641dae3..161578b 100644 --- a/raillabel_providerkit/convert/convert.py +++ b/raillabel_providerkit/convert/convert.py @@ -39,10 +39,11 @@ def convert(data: dict, loader_class: t.Optional[t.Type[LoaderABC]] = None) -> r def _select_loader_class(data: dict) -> t.Type[LoaderABC]: - loader_classes = [] - for cls in loader_classes_pkg.__dict__.values(): - if isinstance(cls, type) and issubclass(cls, LoaderABC) and cls != LoaderABC: - loader_classes.append(cls) + loader_classes = [ + cls + for cls in loader_classes_pkg.__dict__.values() + if isinstance(cls, type) and issubclass(cls, LoaderABC) and cls != LoaderABC + ] for loader_class in loader_classes: if loader_class().supports(data): diff --git a/raillabel_providerkit/convert/loader_classes/loader_understand_ai.py b/raillabel_providerkit/convert/loader_classes/loader_understand_ai.py index 7f0fb40..edc21e2 100644 --- a/raillabel_providerkit/convert/loader_classes/loader_understand_ai.py +++ b/raillabel_providerkit/convert/loader_classes/loader_understand_ai.py @@ -90,9 +90,7 @@ def validate_schema(self, data: dict) -> t.List[str]: schema = json.load(file) validator = jsonschema.Draft7Validator(schema=schema) - schema_errors = [] - - for error in validator.iter_errors(data): - schema_errors.append("$" + error.json_path[1:] + ": " + str(error.message)) - - return schema_errors + return [ + "$" + error.json_path[1:] + ": " + str(error.message) + for error in validator.iter_errors(data) + ] diff --git a/raillabel_providerkit/format/understand_ai/_annotation.py b/raillabel_providerkit/format/understand_ai/_annotation.py index 95a7746..af94cba 100644 --- a/raillabel_providerkit/format/understand_ai/_annotation.py +++ b/raillabel_providerkit/format/understand_ai/_annotation.py @@ -19,8 +19,6 @@ class _Annotation(ABC): attributes: dict sensor: SensorReference - OPENLABEL_ID: str - @classmethod @abstractmethod def fromdict(cls, data_dict: t.Dict) -> t.Type["_Annotation"]: diff --git a/raillabel_providerkit/validation/validate_onthology/_onthology_classes/_object_classes.py b/raillabel_providerkit/validation/validate_onthology/_onthology_classes/_object_classes.py index c6fd13b..e772256 100644 --- a/raillabel_providerkit/validation/validate_onthology/_onthology_classes/_object_classes.py +++ b/raillabel_providerkit/validation/validate_onthology/_onthology_classes/_object_classes.py @@ -50,38 +50,28 @@ def _attribute_fromdict(cls, attribute: dict or str) -> t.Type[_Attribute]: @classmethod def _sensor_types_fromdict(cls, sensor_types_dict: dict) -> t.Dict[str, _SensorType]: - sensor_types = {} - - for type_id, sensor_type_dict in sensor_types_dict.items(): - sensor_types[raillabel.format.SensorType(type_id)] = _SensorType.fromdict( - sensor_type_dict - ) - - return sensor_types + return { + raillabel.format.SensorType(type_id): _SensorType.fromdict(sensor_type_dict) + for type_id, sensor_type_dict in sensor_types_dict.items() + } def _check_undefined_attributes( self, annotation: t.Type[raillabel.format._ObjectAnnotation] ) -> t.List[str]: - errors = [] - - applicable_attributes = self._compile_applicable_attributes(annotation) - - for attr_name in annotation.attributes: - if attr_name not in applicable_attributes: - errors.append(f"Undefined attribute '{attr_name}' in annotation {annotation.uid}.") - - return errors + return [ + f"Undefined attribute '{attr_name}' in annotation {annotation.uid}." + for attr_name in annotation.attributes + if attr_name not in self._compile_applicable_attributes(annotation) + ] def _check_missing_attributes( self, annotation: t.Type[raillabel.format._ObjectAnnotation] ) -> t.List[str]: - errors = [] - - for attr_name in self._compile_applicable_attributes(annotation): - if attr_name not in annotation.attributes: - errors.append(f"Missing attribute '{attr_name}' in annotation {annotation.uid}.") - - return errors + return [ + f"Missing attribute '{attr_name}' in annotation {annotation.uid}." + for attr_name in self._compile_applicable_attributes(annotation) + if attr_name not in annotation.attributes + ] def _check_false_attribute_type( self, annotation: t.Type[raillabel.format._ObjectAnnotation] diff --git a/tests/test_raillabel_providerkit/format/understand_ai/conftest.py b/tests/test_raillabel_providerkit/format/understand_ai/conftest.py index 38a72d7..7f14471 100644 --- a/tests/test_raillabel_providerkit/format/understand_ai/conftest.py +++ b/tests/test_raillabel_providerkit/format/understand_ai/conftest.py @@ -1,18 +1,18 @@ # Copyright DB Netz AG and contributors # SPDX-License-Identifier: Apache-2.0 -from test_uai_attributes import attributes_raillabel_dict, attributes_uai, attributes_uai_dict -from test_uai_bounding_box_2d import ( +from .test_uai_attributes import attributes_raillabel_dict, attributes_uai, attributes_uai_dict +from .test_uai_bounding_box_2d import ( bounding_box_2d_raillabel_dict, bounding_box_2d_uai, bounding_box_2d_uai_dict, ) -from test_uai_bounding_box_3d import ( +from .test_uai_bounding_box_3d import ( bounding_box_3d_raillabel_dict, bounding_box_3d_uai, bounding_box_3d_uai_dict, ) -from test_uai_coordinate_system import ( +from .test_uai_coordinate_system import ( coordinate_system_camera_raillabel_dict, coordinate_system_camera_translated_uid, coordinate_system_camera_uai, @@ -26,19 +26,19 @@ coordinate_system_radar_uai, coordinate_system_radar_uai_dict, ) -from test_uai_frame import frame_raillabel_dict, frame_uai, frame_uai_dict -from test_uai_metadata import metadata_raillabel_dict, metadata_uai, metadata_uai_dict -from test_uai_point_3d import point_3d_uai, point_3d_uai_dict, point_3d_vec -from test_uai_polygon_2d import polygon_2d_raillabel_dict, polygon_2d_uai, polygon_2d_uai_dict -from test_uai_polyline_2d import polyline_2d_raillabel_dict, polyline_2d_uai, polyline_2d_uai_dict -from test_uai_quaternion import quaternion_uai, quaternion_uai_dict, quaternion_vec -from test_uai_scene import scene_raillabel_dict, scene_uai, scene_uai_dict -from test_uai_segmentation_3d import ( +from .test_uai_frame import frame_raillabel_dict, frame_uai, frame_uai_dict +from .test_uai_metadata import metadata_raillabel_dict, metadata_uai, metadata_uai_dict +from .test_uai_point_3d import point_3d_uai, point_3d_uai_dict, point_3d_vec +from .test_uai_polygon_2d import polygon_2d_raillabel_dict, polygon_2d_uai, polygon_2d_uai_dict +from .test_uai_polyline_2d import polyline_2d_raillabel_dict, polyline_2d_uai, polyline_2d_uai_dict +from .test_uai_quaternion import quaternion_uai, quaternion_uai_dict, quaternion_vec +from .test_uai_scene import scene_raillabel_dict, scene_uai, scene_uai_dict +from .test_uai_segmentation_3d import ( segmentation_3d_raillabel_dict, segmentation_3d_uai, segmentation_3d_uai_dict, ) -from test_uai_sensor_reference import ( +from .test_uai_sensor_reference import ( sensor_camera_raillabel_dict, sensor_camera_uai, sensor_camera_uai_dict, @@ -46,4 +46,4 @@ sensor_lidar_uai, sensor_lidar_uai_dict, ) -from test_uai_size_3d import size_3d_uai, size_3d_uai_dict, size_3d_vec +from .test_uai_size_3d import size_3d_uai, size_3d_uai_dict, size_3d_vec