yunojuno / django-side-effects

Django app used to centralise and document external side effects
MIT License
18 stars 4 forks source link

`display_side_effects` management command could have better error on no docstring #32

Open djm opened 1 year ago

djm commented 1 year ago

When running python manage.py display_side_effects against a codebase with a side-effect that does not have a docstring defined - it errors hard with a very hard to grok error message.

File "/Users/[..snip...]/platform/.venv/lib/python3.10/site-packages/side_effects/management/commands/display_side_effects.py", line 28, in <dictcomp>
    label: sorted(handlers, key=handler_sort_key)
TypeError: '<' not supported between instances of 'NoneType' and 'list'
zemgin commented 1 year ago

Full [redacted] stack trace

Traceback (most recent call last):
  ...
  File "[..snip...]/side_effects/management/commands/display_side_effects.py", line 98, in handle
    events = sort_events(
  File "[..snip...]/side_effects/management/commands/display_side_effects.py", line 27, in sort_events
    return {
  File "[..snip...]/side_effects/management/commands/display_side_effects.py", line 28, in <dictcomp>
    label: sorted(handlers, key=handler_sort_key)
TypeError: '<' not supported between instances of 'NoneType' and 'list'
task: Failed to run task "freeze-snapshots": exit status 1
hugorodgerbrown commented 1 year ago

This is a bug in the --sorted option. The command itself handles functions missing docstrings, but if you try and sort the output it blows up.