Skip to content

no traceback on invalid python #2

Description

Using doc910 in precommit . when the input file has a syntax error, we should output the message, not a traceback,

doc901...................................................................Failed
- hook id: doc901
- exit code: 1

Traceback (most recent call last):
  File "/home/tin/lab/Shiphero-API/.venv/bin/doc901", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/tin/lab/Shiphero-API/.venv/lib/python3.12/site-packages/doc901.py", line 144, in main
    analyze_complexity_with_docstrings(
  File "/home/tin/lab/Shiphero-API/.venv/lib/python3.12/site-packages/doc901.py", line 82, in analyze_complexity_with_docstrings
    docstring_issues = {(issue["filename"], issue["noqa_row"]) for issue in issues if issue["code"].startswith("D1")}
                                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'

(.venv) tin@morocha:~/lab/Shiphero-API$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions