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
```python
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.
Description of the bug
If a Griffe object has its
lineno
attribute set toNone
, 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. Enableshow_source: true
.Full traceback
Full traceback
```python 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
isNone
.Environment information
PYTHONPATH
:/home/pawamoy/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/pep582
mkdocs
v1.6.0mkdocstrings
v0.25.1mkdocstrings-python
v1.10.0.1.8.1griffe
v0.45.0Additional context
/