Skip to content

Commit

Permalink
Automatically comment parameters that are Undefined to keep them docu…
Browse files Browse the repository at this point in the history
…mented but not crashing everything in case they're optional.
  • Loading branch information
ccossou committed Jul 6, 2023
1 parent 83ab9b2 commit 5af793d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ctapipe/core/config_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def commented(text, indent_level=indent_level, width=144):
if isinstance(trait, traitlets.Unicode):
trait_value = f"'{trait_value}'"

trait_repr += f"{indent_str*indent_level}{trait.name}: {trait_value}\n"
# Automatically comment all parameters that are unvalid
commented = ""
if trait_value == traitlets.Undefined:
commented = "#"

trait_repr += f"{indent_str*indent_level}{commented}{trait.name}: {trait_value}\n"

return trait_repr

0 comments on commit 5af793d

Please sign in to comment.