diff --git a/qc_openscenario/checks/data_type_checker/allowed_operators.py b/qc_openscenario/checks/data_type_checker/allowed_operators.py index 979fd66..cbb68c2 100644 --- a/qc_openscenario/checks/data_type_checker/allowed_operators.py +++ b/qc_openscenario/checks/data_type_checker/allowed_operators.py @@ -1,7 +1,7 @@ import logging from dataclasses import dataclass -from typing import Union +from typing import Union, Optional from lxml import etree @@ -47,7 +47,7 @@ class ExpressionMember(enum.IntEnum): @dataclass class QueueNode: element: etree._ElementTree - xpath: Union[str, None] + xpath: Optional[str] @dataclass diff --git a/qc_openscenario/checks/models.py b/qc_openscenario/checks/models.py index aacd3d7..f171f57 100644 --- a/qc_openscenario/checks/models.py +++ b/qc_openscenario/checks/models.py @@ -1,6 +1,6 @@ from dataclasses import dataclass from lxml import etree -from typing import Union +from typing import Optional from enum import Enum from qc_baselib import Configuration, Result @@ -9,11 +9,11 @@ @dataclass class CheckerData: xml_file_path: str - input_file_xml_root: Union[None, etree._ElementTree] + input_file_xml_root: Optional[etree._ElementTree] config: Configuration result: Result - schema_version: Union[None, str] - xodr_root: Union[None, etree._ElementTree] + schema_version: Optional[str] + xodr_root: Optional[etree._ElementTree] class AttributeType(Enum): diff --git a/qc_openscenario/checks/reference_checker/unique_element_names_on_same_level.py b/qc_openscenario/checks/reference_checker/unique_element_names_on_same_level.py index 99a21e1..95dc937 100644 --- a/qc_openscenario/checks/reference_checker/unique_element_names_on_same_level.py +++ b/qc_openscenario/checks/reference_checker/unique_element_names_on_same_level.py @@ -1,14 +1,14 @@ import logging from dataclasses import dataclass -from typing import Union +from typing import Optional from lxml import etree -from qc_baselib import IssueSeverity, StatusType +from qc_baselib import IssueSeverity from qc_openscenario import constants -from qc_openscenario.checks import utils, models +from qc_openscenario.checks import models from qc_openscenario import basic_preconditions from collections import deque, defaultdict @@ -22,7 +22,7 @@ @dataclass class QueueNode: element: etree._ElementTree - parent_xpath: Union[str, None] + parent_xpath: Optional[str] @dataclass diff --git a/qc_openscenario/checks/utils.py b/qc_openscenario/checks/utils.py index a615c24..7d56ce0 100644 --- a/qc_openscenario/checks/utils.py +++ b/qc_openscenario/checks/utils.py @@ -1,6 +1,6 @@ from lxml import etree from io import BytesIO -from typing import Union +from typing import Union, Optional from qc_openscenario.checks import models import re import logging @@ -17,7 +17,7 @@ def to_float(s): return None -def get_root_without_default_namespace(path: str) -> Union[None, etree._ElementTree]: +def get_root_without_default_namespace(path: str) -> Optional[etree._ElementTree]: if not os.path.exists(path): return None @@ -30,7 +30,7 @@ def get_root_without_default_namespace(path: str) -> Union[None, etree._ElementT return etree.parse(BytesIO(xml_string.encode())) -def get_standard_schema_version(root: etree._ElementTree) -> Union[str, None]: +def get_standard_schema_version(root: etree._ElementTree) -> Optional[str]: header = root.find("FileHeader") if header is None: return None @@ -107,15 +107,15 @@ def get_parameter_value_from_node( def get_xodr_road_network( input_file_path: str, tree: etree._ElementTree -) -> Union[etree._ElementTree, None]: +) -> Optional[etree._ElementTree]: """Get parsed xodr tree indicated in the RoadNetwork/LogicFile node of the input tree Args: tree (etree._ElementTree): xml document tree that refers to a xodr file Returns: - Union[etree._ElementTree, None]: the parsed road network tree. - None if the specified nodes in the root or the road network file are not found + Optional[etree._ElementTree]: the parsed road network tree. + None if the specified nodes in the root or the road network file are not found """ road_network = tree.find("RoadNetwork")