Skip to content

bug: python try/except with multiple error codes leads to collection errors #814

@SirUli

Description

@SirUli

Description of the bug

When having a try / except with multiple error conditions to be catched, the formatting needs to be very particular to work. Unfortunately ruff 0.15.0 (currently latest) is also very particular to not accept (on Python 3.14 and later) the one that mkdocstring wants. See here. Background. As of Python 3.14, you're allowed to omit the parentheses around groups of exceptions, as long as there's no as binding.

What ruff wants: except KeyError, TypeError:
What mkdocstrings wants: except (KeyError, TypeError):

To Reproduce

Example:

 ```
try:
   ... do something ...
except KeyError, TypeError:
   ... dump the error ...
 ```

Full traceback

Full traceback
ERROR   -  mkdocstrings: some.file.core could not be found
ERROR   -  Error reading page 'reference/some/file/core.md':
ERROR   -  Could not collect 'same.file.core'

Expected behavior

Both ways work.

Environment information

python -m mkdocstrings._internal.debug  # | xclip -selection clipboard
  • System: Linux-6.16.10-200.fc42.aarch64-aarch64-with
  • Python: cpython 3.11.14 (/usr/local/bin/python)
  • Environment variables:
  • Installed packages:
    • mkdocstrings v1.0.2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions