diff --git a/pydsdl/__init__.py b/pydsdl/__init__.py index 8531978..bc71a3e 100644 --- a/pydsdl/__init__.py +++ b/pydsdl/__init__.py @@ -7,7 +7,7 @@ import sys as _sys from pathlib import Path as _Path -__version__ = "1.22.0" +__version__ = "1.22.1" __version_info__ = tuple(map(int, __version__.split(".")[:3])) __license__ = "MIT" __author__ = "OpenCyphal" diff --git a/pydsdl/_data_schema_builder.py b/pydsdl/_data_schema_builder.py index 1ec7896..9fc246b 100644 --- a/pydsdl/_data_schema_builder.py +++ b/pydsdl/_data_schema_builder.py @@ -81,7 +81,7 @@ def offset(self) -> _bit_length_set.BitLengthSet: # only the total offset (i.e., total size) is defined. self._bit_length_computed_at_least_once = True ty = _serializable.UnionType if self.union else _serializable.StructureType - out = ty.aggregate_bit_length_sets([f.data_type for f in self.fields]) # type: ignore + out = ty.aggregate_bit_length_sets([f.data_type for f in self.fields]) assert isinstance(out, _bit_length_set.BitLengthSet) and len(out) > 0 return out diff --git a/pydsdl/_dsdl_definition.py b/pydsdl/_dsdl_definition.py index a85e6b4..adf5383 100644 --- a/pydsdl/_dsdl_definition.py +++ b/pydsdl/_dsdl_definition.py @@ -164,7 +164,7 @@ def from_first_in(cls: Type["DSDLDefinition"], dsdl_path: Path, valid_dsdl_roots def __init__(self, file_path: Path, root_namespace_path: Path): """ """ # Normalizing the path and reading the definition text - self._file_path = Path(file_path) + self._file_path = Path(file_path).resolve() del file_path if not self._file_path.exists(): @@ -172,7 +172,7 @@ def __init__(self, file_path: Path, root_namespace_path: Path): "Attempt to construct ReadableDSDLFile object for file that doesn't exist.", self._file_path ) - self._root_namespace_path = Path(root_namespace_path) + self._root_namespace_path = Path(root_namespace_path).resolve() del root_namespace_path self._text: str | None = None @@ -385,6 +385,16 @@ def _unittest_dsdl_definition_read_text(temp_dsdl_factory) -> None: # type: ign assert "@sealed" == target_definition.text +def _unittest_dsdl_definition_issue_111(temp_dsdl_factory) -> None: # type: ignore + target_root = Path("root", "ns") + target_file_path = Path(target_root / "Target.1.1.dsdl") + dsdl_file = temp_dsdl_factory.new_file(target_root / target_file_path, "@sealed") + actual_root = Path(str(dsdl_file.parent) + "/..") + + target_definition = DSDLDefinition(actual_root / dsdl_file.parent / dsdl_file.name, actual_root) + assert "@sealed" == target_definition.text + + def _unittest_type_from_path_inference() -> None: from pytest import raises as expect_raises