Skip to content

Commit b51eb90

Browse files
MNT: satisfy ruff/pylint for parachute changes
- ruff format: collapse the parachutes_info source comprehension to one line. - pylint (no-value-for-parameter, fail-under=10): the base Parachute could not offer a generic from_dict because each concrete model has different required constructor arguments. Make from_dict abstract (mirroring u_dot and add_information_to_flight); the shared _decode_trigger helper stays on the base and HemisphericalParachute keeps its concrete implementation.
1 parent d945ea0 commit b51eb90

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

rocketpy/plots/flight_plots.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,7 @@ def parachutes_info(self, parachute_name="all"):
13081308
if variable == "t":
13091309
continue
13101310
variable_func = Function(
1311-
source=[
1312-
[t, value] for t, value in zip(t_values, variable_values)
1313-
],
1311+
source=[[t, value] for t, value in zip(t_values, variable_values)],
13141312
inputs="time",
13151313
outputs=variable,
13161314
title=f"{variable} x time for parachute {name}",

rocketpy/rocket/parachutes/parachute.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,10 @@ def _decode_trigger(trigger):
394394
return trigger
395395

396396
@classmethod
397+
@abstractmethod
397398
def from_dict(cls, data):
398-
"""Reconstructs a parachute from the fields shared by every model.
399-
Subclasses with additional constructor arguments (e.g. ``cd_s``) must
400-
override this method; ``parachute_type`` is not forwarded because each
401-
concrete model sets it itself."""
402-
return cls(
403-
name=data["name"],
404-
trigger=cls._decode_trigger(data["trigger"]),
405-
sampling_rate=data["sampling_rate"],
406-
lag=data["lag"],
407-
noise=data["noise"],
408-
)
399+
"""Reconstructs a parachute from a serialized dictionary.
400+
401+
Each concrete model must implement this using its own constructor,
402+
since the required arguments differ per model. The shared
403+
``_decode_trigger`` helper handles the ``trigger`` field."""

0 commit comments

Comments
 (0)