Skip to content

Commit e8f8b62

Browse files
authored
Make sure to add trailing slash on paths (#779)
* Make sure to add trailing slash on paths
1 parent 350ca72 commit e8f8b62

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/dodal/devices/detector/detector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _parse_detector_size_constants(cls, det_type: str) -> DetectorSizeConstants:
7979
def _parse_directory(cls, directory: str | Path) -> str:
8080
path = Path(directory)
8181
assert path.is_dir()
82-
return str(path)
82+
return f"{path}/"
8383

8484
def get_beam_position_mm(self, detector_distance: float) -> tuple[float, float]:
8585
x_beam_mm = self.beam_xy_converter.get_beam_xy_from_det_dist(

src/dodal/devices/util/lookup_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def energy_distance_table(lookup_table_path: str) -> np.ndarray:
2727

2828
# Slight cheat to make the file IO async, numpy doesn't do any real IO now, just
2929
# decodes the text
30-
async with aiofiles.open(lookup_table_path, "r") as stream:
30+
async with aiofiles.open(lookup_table_path) as stream:
3131
raw_table = await stream.read()
3232
return loadtxt(StringIO(raw_table), comments=["#", "Units"])
3333

tests/devices/unit_tests/detector/test_detector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def create_det_params_with_dir_and_prefix(directory: str | Path, prefix="test"):
2828
def test_if_string_provided_check_is_dir(tmp_path: Path):
2929
assert not (_dir := str(tmp_path)).endswith("/")
3030
params = create_det_params_with_dir_and_prefix(_dir)
31-
assert params.directory == str(tmp_path)
31+
assert params.directory == f"{tmp_path}/"
3232
file_path = tmp_path / "foo.h5"
3333
file_path.touch()
3434
with pytest.raises(ValidationError):
@@ -37,7 +37,7 @@ def test_if_string_provided_check_is_dir(tmp_path: Path):
3737

3838
def test_if_path_provided_check_is_dir(tmp_path: Path):
3939
params = create_det_params_with_dir_and_prefix(tmp_path)
40-
assert params.directory == str(tmp_path)
40+
assert params.directory == f"{tmp_path}/"
4141
file_path = tmp_path / "foo.h5"
4242
file_path.touch()
4343
with pytest.raises(ValidationError):

0 commit comments

Comments
 (0)