You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AttributeError in make_default_short_help(None) #3189
click.utils.make_default_short_help() crashes with AttributeError when passed None. This can occur when programmatically creating commands where help text might not be provided, or when a developer passes None expecting the function to handle it gracefully.
Reproduction
fromclick.utilsimportmake_default_short_help# This crashesresult=make_default_short_help(None)
Full traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "click/utils.py", line 62, in make_default_short_help
paragraph_end = help.find("\n\n")
^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'find'
Real-world scenario where this could happen:
@click.command()@click.option('--help-text', default=None)defmy_command(help_text):
# If help_text is None, this crashesshort_help=make_default_short_help(help_text)
Expected Behavior
The function should either:
Return an empty string ("") when passed None, OR
Raise a clear TypeError with a message like "help must be a string, not NoneType"
Currently, the AttributeError doesn't clearly indicate that the problem is with the input validation.
Suggested Fix
Add input validation at the start of the function:
defmake_default_short_help(help: str|None, max_length: int=45) ->str:
ifhelpisNone:
return""# ... rest of function
Environment:
Python version: 3.13.1
Click version: latest from main branch (tested with git clone)
Please do not use LLMs to generate bug reports for you.
That's why it's annotated to take str, not str | None. Use a type checker. Additionally, this is not a public API, so we make no guarantees about its availability or use.
Activity
davidism commentedon Jan 20, 2026
Please do not use LLMs to generate bug reports for you.
That's why it's annotated to take
str, notstr | None. Use a type checker. Additionally, this is not a public API, so we make no guarantees about its availability or use.