Skip to content

Commit

Permalink
Handle case when doc=None in get_help_table()
Browse files Browse the repository at this point in the history
If some option had `doc=None`, looking for its width or calling
`.ljust()` would fail, so convert all `doc` to `str` before calculating
the length.
  • Loading branch information
johnomotani committed Jan 1, 2023
1 parent ee19e26 commit 04e399a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions optionsfactory/optionsfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def get_help_table(self, prefix=None):
heading2 = "Description"
heading3 = "Default"
column1_width = max(max(len(k) for k in keys), len(heading1))
column2_width = max(max(len(d) for d in docs.values()), len(heading2))
column2_width = max(max(len(str(d)) for d in docs.values()), len(heading2))
column3_width = max(max(len(str(d)) for d in defaults.values()), len(heading3))
separator = (
prefix
Expand Down Expand Up @@ -255,7 +255,7 @@ def get_help_table(self, prefix=None):
+ "|"
+ k.ljust(column1_width)
+ "|"
+ docs[k].ljust(column2_width)
+ str(docs[k]).ljust(column2_width)
+ "|"
+ str(defaults[k].evaluate_expression(self.create())).ljust(
column3_width
Expand Down

0 comments on commit 04e399a

Please sign in to comment.