Skip to content

Commit bbd76c6

Browse files
authored
Add comment for RotationDirection (#979)
* Add comment for RotationDirection * Make ruff 0.9.0 happy
1 parent a7a01e7 commit bbd76c6

File tree

15 files changed

+55
-50
lines changed

15 files changed

+55
-50
lines changed

conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def patched_open(*args, **kwargs):
5353
requested_path = Path(args[0])
5454
if requested_path.is_absolute():
5555
for p in BANNED_PATHS:
56-
assert not requested_path.is_relative_to(
57-
p
58-
), f"Attempt to open {requested_path} from inside a unit test"
56+
assert not requested_path.is_relative_to(p), (
57+
f"Attempt to open {requested_path} from inside a unit test"
58+
)
5959
return unpatched_open(*args, **kwargs)
6060

6161
with patch("builtins.open", side_effect=patched_open):

src/dodal/common/crystal_metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def make_crystal_metadata_from_material(
5555
d_spacing = d_spacing_param or CrystalMetadata.calculate_default_d_spacing(
5656
material.value.lattice_parameter, reflection_plane
5757
)
58-
assert all(
59-
isinstance(i, int) and i > 0 for i in reflection_plane
60-
), "Reflection plane indices must be positive integers"
58+
assert all(isinstance(i, int) and i > 0 for i in reflection_plane), (
59+
"Reflection plane indices must be positive integers"
60+
)
6161
return CrystalMetadata(usage, material.value.name, reflection_plane, d_spacing)

src/dodal/common/udc_directory_provider.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ async def update(self, *, directory: Path, suffix: str = "", **kwargs):
4646
self._filename_provider.suffix = suffix
4747

4848
def __call__(self, device_name: str | None = None) -> PathInfo:
49-
assert self._output_directory, "Directory unknown for PandA to write into, update() needs to be called at least once"
49+
assert self._output_directory, (
50+
"Directory unknown for PandA to write into, update() needs to be called at least once"
51+
)
5052
return PathInfo(
5153
directory_path=self._output_directory,
5254
filename=self._filename_provider(device_name),

src/dodal/devices/attenuator/attenuator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __init__(
106106
with self.add_children_as_readables():
107107
self.filters: DeviceVector[FilterMotor] = DeviceVector(
108108
{
109-
index: FilterMotor(f"{prefix}MP{index+1}:", filter, name)
109+
index: FilterMotor(f"{prefix}MP{index + 1}:", filter, name)
110110
for index, filter in enumerate(filter_selection)
111111
}
112112
)

src/dodal/devices/bimorph_mirror.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def set(self, value: Mapping[int, float], tolerance: float = 0.0001) -> No
114114

115115
if any(key not in self.channels for key in value):
116116
raise ValueError(
117-
f"Attempting to put to non-existent channels: {[key for key in value if (key not in self.channels)]}"
117+
f"Attempting to put to non-existent channels: {[key for key in value if (key not in self.channels)]}"
118118
)
119119

120120
# Write target voltages:

src/dodal/devices/eiger_odin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def check_frames_dropped(self) -> tuple[bool, str]:
9191
def wait_for_no_errors(self, timeout) -> dict[SubscriptionStatus, str]:
9292
errors = {}
9393
for node_number, node_pv in enumerate(self.nodes):
94-
errors[
95-
await_value(node_pv.error_status, False, timeout)
96-
] = f"Filewriter {node_number} is in an error state with error message\
94+
errors[await_value(node_pv.error_status, False, timeout)] = (
95+
f"Filewriter {node_number} is in an error state with error message\
9796
- {node_pv.error_message.get()}"
97+
)
9898

9999
return errors
100100

src/dodal/devices/zebra.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ class I24Axes:
8181

8282

8383
class RotationDirection(StrictEnum):
84+
"""
85+
Defines for a swept angle whether the scan width (sweep) is to be added or subtracted from
86+
the initial angle to obtain the final angle.
87+
"""
88+
8489
POSITIVE = "Positive"
8590
NEGATIVE = "Negative"
8691

@@ -281,7 +286,7 @@ def __str__(self) -> str:
281286
for input, (source, invert) in enumerate(
282287
zip(self.sources, self.invert, strict=False)
283288
):
284-
input_strings.append(f"INP{input+1}={'!' if invert else ''}{source}")
289+
input_strings.append(f"INP{input + 1}={'!' if invert else ''}{source}")
285290

286291
return ", ".join(input_strings)
287292

src/dodal/log.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def set_up_graylog_handler(logger: Logger, host: str, port: int):
152152
def set_up_INFO_file_handler(logger, path: Path, filename: str):
153153
"""Set up a file handler for the logger, at INFO level, which will keep 30 days
154154
of logs, rotating once per day. Creates the directory if necessary."""
155-
print(f"Logging to INFO file handler {path/filename}")
155+
print(f"Logging to INFO file handler {path / filename}")
156156
path.mkdir(parents=True, exist_ok=True)
157157
file_handler = TimedRotatingFileHandler(
158158
filename=path / filename, when="MIDNIGHT", backupCount=INFO_LOG_DAYS
@@ -169,7 +169,7 @@ def set_up_DEBUG_memory_handler(
169169
log file when it sees a message of severity ERROR. Creates the directory if
170170
necessary"""
171171
debug_path = path / "debug"
172-
print(f"Logging to DEBUG handler {debug_path/filename}")
172+
print(f"Logging to DEBUG handler {debug_path / filename}")
173173
debug_path.mkdir(parents=True, exist_ok=True)
174174
file_handler = TimedRotatingFileHandler(
175175
filename=debug_path / filename, when="H", backupCount=DEBUG_LOG_FILES_TO_KEEP

src/dodal/plans/wrapped.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def count(
4949
Wraps bluesky.plans.count(det, num, delay, md=metadata) exposing only serializable
5050
parameters and metadata."""
5151
if isinstance(delay, Sequence):
52-
assert (
53-
len(delay) == num - 1
54-
), f"Number of delays given must be {num - 1}: was given {len(delay)}"
52+
assert len(delay) == num - 1, (
53+
f"Number of delays given must be {num - 1}: was given {len(delay)}"
54+
)
5555
metadata = metadata or {}
5656
metadata["shape"] = (num,)
5757
yield from bp.count(tuple(detectors), num, delay=delay, md=metadata)

tests/common/beamlines/test_device_instantiation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def test_device_creation(RE, module_and_devices_for_beamline):
2929
for name, device in devices.items()
3030
if not follows_bluesky_protocols(device)
3131
]
32-
assert (
33-
len(devices_not_following_bluesky_protocols) == 0
34-
), f"{devices_not_following_bluesky_protocols} do not follow bluesky protocols"
32+
assert len(devices_not_following_bluesky_protocols) == 0, (
33+
f"{devices_not_following_bluesky_protocols} do not follow bluesky protocols"
34+
)
3535

3636

3737
@pytest.mark.parametrize(
@@ -56,6 +56,6 @@ def test_devices_are_identical(RE, module_and_devices_for_beamline):
5656
]
5757
total_number_of_devices = len(devices_a)
5858
non_identical_number_of_devies = len(devices_a)
59-
assert (
60-
len(non_identical_names) == 0
61-
), f"{non_identical_number_of_devies}/{total_number_of_devices} devices were not identical: {non_identical_names}"
59+
assert len(non_identical_names) == 0, (
60+
f"{non_identical_number_of_devies}/{total_number_of_devices} devices were not identical: {non_identical_names}"
61+
)

0 commit comments

Comments
 (0)