Skip to content

Commit 97fb20c

Browse files
Fix for issue #111 (#112)
Resolve inputs into DSDLDefinition constructor
1 parent 3ea74de commit 97fb20c

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

pydsdl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys as _sys
88
from pathlib import Path as _Path
99

10-
__version__ = "1.22.0"
10+
__version__ = "1.22.1"
1111
__version_info__ = tuple(map(int, __version__.split(".")[:3]))
1212
__license__ = "MIT"
1313
__author__ = "OpenCyphal"

pydsdl/_data_schema_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def offset(self) -> _bit_length_set.BitLengthSet:
8181
# only the total offset (i.e., total size) is defined.
8282
self._bit_length_computed_at_least_once = True
8383
ty = _serializable.UnionType if self.union else _serializable.StructureType
84-
out = ty.aggregate_bit_length_sets([f.data_type for f in self.fields]) # type: ignore
84+
out = ty.aggregate_bit_length_sets([f.data_type for f in self.fields])
8585
assert isinstance(out, _bit_length_set.BitLengthSet) and len(out) > 0
8686
return out
8787

pydsdl/_dsdl_definition.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ def from_first_in(cls: Type["DSDLDefinition"], dsdl_path: Path, valid_dsdl_roots
164164
def __init__(self, file_path: Path, root_namespace_path: Path):
165165
""" """
166166
# Normalizing the path and reading the definition text
167-
self._file_path = Path(file_path)
167+
self._file_path = Path(file_path).resolve()
168168
del file_path
169169

170170
if not self._file_path.exists():
171171
raise InvalidDefinitionError(
172172
"Attempt to construct ReadableDSDLFile object for file that doesn't exist.", self._file_path
173173
)
174174

175-
self._root_namespace_path = Path(root_namespace_path)
175+
self._root_namespace_path = Path(root_namespace_path).resolve()
176176
del root_namespace_path
177177
self._text: str | None = None
178178

@@ -385,6 +385,16 @@ def _unittest_dsdl_definition_read_text(temp_dsdl_factory) -> None: # type: ign
385385
assert "@sealed" == target_definition.text
386386

387387

388+
def _unittest_dsdl_definition_issue_111(temp_dsdl_factory) -> None: # type: ignore
389+
target_root = Path("root", "ns")
390+
target_file_path = Path(target_root / "Target.1.1.dsdl")
391+
dsdl_file = temp_dsdl_factory.new_file(target_root / target_file_path, "@sealed")
392+
actual_root = Path(str(dsdl_file.parent) + "/..")
393+
394+
target_definition = DSDLDefinition(actual_root / dsdl_file.parent / dsdl_file.name, actual_root)
395+
assert "@sealed" == target_definition.text
396+
397+
388398
def _unittest_type_from_path_inference() -> None:
389399
from pytest import raises as expect_raises
390400

0 commit comments

Comments
 (0)