-
-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description of the bug
If a Griffe object has its lineno
attribute set to None
, rendering its source will fail.
To Reproduce
Add a Griffe extension that adds a member, created manually (in the extension) without a lineno
.
Render it in the docs. Enable show_source: true
.
Full traceback
Full traceback
File "/home/pawamoy/data/dev/qtile/.venv/lib/python3.12/site-packages/mkdocstrings_handlers/python/templates/material/_base/function.html", line 99, in block 'source'
{{ function.source|highlight(language="python", linestart=function.lineno, linenums=True) }}
^^^^^^^^^^^^^^^^^
File "/home/pawamoy/data/dev/qtile/.venv/lib/python3.12/site-packages/mkdocstrings/handlers/rendering.py", line 120, in highlight
result = super().highlight(src, language, inline=inline, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pawamoy/data/dev/qtile/.venv/lib/python3.12/site-packages/pymdownx/highlight.py", line 385, in highlight
if not linenums or linestart < 1:
^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'NoneType' and 'int'
Expected behavior
Rendering the source shouldn't make MkDocs crash, even if lineno
is None
.
Environment information
python -m mkdocstrings_handlers.python.debug # | xclip -selection clipboard
- System: Linux-6.8.9-arch1-2-x86_64-with-glibc2.39
- Python: cpython 3.12.1 (/home/pawamoy/data/dev/qtile/.venv/bin/python)
- Environment variables:
PYTHONPATH
:/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/pep582
- Installed packages:
mkdocs
v1.6.0mkdocstrings
v0.25.1mkdocstrings-python
v1.10.0.1.8.1griffe
v0.45.0
Additional context
/
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working