Title: bug: `docstring_style: sphinx` + any explicit `docstring_options` crashes: `parse_sphinx() got an unexpected keyword argument 'warn_missing_types'` · Issue #337 · mkdocstrings/python · GitHub
Open Graph Title: bug: `docstring_style: sphinx` + any explicit `docstring_options` crashes: `parse_sphinx() got an unexpected keyword argument 'warn_missing_types'` · Issue #337 · mkdocstrings/python
X Title: bug: `docstring_style: sphinx` + any explicit `docstring_options` crashes: `parse_sphinx() got an unexpected keyword argument 'warn_missing_types'` · Issue #337 · mkdocstrings/python
Description: Description With mkdocstrings-python 2.0.5 on griffelib 2.1.0, any configuration that uses docstring_style: sphinx and sets at least one key under docstring_options crashes on the first rendered docstring: TypeError: parse_sphinx() got a...
Open Graph Description: Description With mkdocstrings-python 2.0.5 on griffelib 2.1.0, any configuration that uses docstring_style: sphinx and sets at least one key under docstring_options crashes on the first rendered do...
X Description: Description With mkdocstrings-python 2.0.5 on griffelib 2.1.0, any configuration that uses docstring_style: sphinx and sets at least one key under docstring_options crashes on the first rendered do...
Opengraph URL: https://github.com/mkdocstrings/python/issues/337
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: `docstring_style: sphinx` + any explicit `docstring_options` crashes: `parse_sphinx() got an unexpected keyword argument 'warn_missing_types'`","articleBody":"## Description\n\nWith mkdocstrings-python 2.0.5 on griffelib 2.1.0, any configuration that uses `docstring_style: sphinx` **and sets at least one key under `docstring_options`** crashes on the first rendered docstring:\n\n```\nTypeError: parse_sphinx() got an unexpected keyword argument 'warn_missing_types'\n```\n\nConfigurations with no `docstring_options` at all build cleanly, which makes this easy to miss in minimal testing: the empty case short-circuits before the bad kwarg is ever produced.\n\n## Mechanism\n\n- `SphinxStyleOptions` still declares `warn_missing_types: bool = True` as a defaulted field (`mkdocstrings_handlers/python/_internal/config.py:252`, class at `:240`).\n- `PythonHandler.render` builds the parser options via `parser_options = options.docstring_options and asdict(options.docstring_options)` (`handler.py:198`). `asdict()` materializes **every** field of the dataclass — defaults included — so `warn_missing_types=True` is emitted as soon as `docstring_options` is non-empty.\n- The dict is assigned to `doc_object.docstring.parser_options` (`handler.py:246`) and forwarded by griffe (`griffe/_internal/models.py:183`: `parse(self, parser or self.parser, **(options or self.parser_options))`).\n- griffelib 2.1.0's `parse_sphinx` signature is `parse_sphinx(docstring, *, warn_unknown_params=True, warnings=True)` (`griffe/_internal/docstrings/sphinx.py:98`) — it no longer accepts `warn_missing_types`, so the call raises `TypeError`.\n\nNote the asymmetry: `parse_google` (`google.py:881`) **still accepts** `warn_missing_types`, so google-style configs are unaffected. Only the sphinx parser dropped the parameter, while `SphinxStyleOptions` still declares it. (griffelib's internal `_read_return` helper in `sphinx.py` still implements the `warn_missing_types` behavior — the kwarg was dropped from the public parser signature only.)\n\n## Minimal reproducer (no mkdocs needed)\n\n```python\n# venv: griffelib==2.1.0\nfrom griffe import Docstring, Parser\n\nd = Docstring(\n \":param x: foo\",\n parser=Parser.sphinx,\n parser_options={\"warn_unknown_params\": False, \"warn_missing_types\": True, \"warnings\": True},\n)\nd.parsed\n# TypeError: parse_sphinx() got an unexpected keyword argument 'warn_missing_types'\n```\n\nThat `parser_options` dict is byte-for-byte what mkdocstrings-python 2.0.5 produces from the mkdocs config below. The same `Docstring` with `parser_options={}` parses fine — the false-negative path.\n\n## mkdocs config that triggers it\n\n```yaml\nplugins:\n - mkdocstrings:\n handlers:\n python:\n options:\n docstring_style: sphinx\n docstring_options:\n warn_unknown_params: false # any single key here is enough\n```\n\n## Full-build traceback (excerpt)\n\n```\nTypeError: parse_sphinx() got an unexpected keyword argument 'warn_missing_types'\n ...\n mkdocstrings/_internal/extension.py:194, in _process_block\n rendered = render(data, options)\n mkdocstrings_handlers/python/_internal/handler.py:264, in render\n return template.render(\n ...templates/material/_base/module.html.jinja:94, in block 'docstring'\n griffe/_internal/models.py:163, in parsed\n return self.parse()\n griffe/_internal/models.py:183, in parse\n return parse(self, parser or self.parser, **(options or self.parser_options))\n griffe/_internal/docstrings/parsers.py:53, in parse\n return parsers(docstring, **options)\n```\n\nThe failure is content-independent — it fires on the first docstring rendered, regardless of what the docstring contains, and regardless of any griffe extensions in use.\n\n## Environment\n\n- mkdocstrings-python 2.0.5\n- griffelib 2.1.0 (sole provider of the `griffe` import; the legacy `griffe` 1.x distribution is **not** installed)\n- mkdocstrings 1.0.6\n- Python 3.12.13\n\n## Suggested fix directions\n\nAny of:\n1. Drop `warn_missing_types` from `SphinxStyleOptions` in mkdocstrings-python (align the options schema with `parse_sphinx`'s actual signature), or\n2. Filter forwarded kwargs per parser signature before assigning `parser_options`, or\n3. Re-accept `warn_missing_types` in griffelib's `parse_sphinx` and thread it through — the internal `_read_return` helper still implements it, so this restores documented behavior rather than adding new surface.\n\nThank you.","author":{"url":"https://github.com/selbs","@type":"Person","name":"selbs"},"datePublished":"2026-08-07T15:17:41Z","url":"https://github.com/mkdocstrings/python/issues/337"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f7635049-96cc-4805-56b6-5aea06b1fb13 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E2D2:23EE1:ADC36E:E501B4:6AF85A19 |
| html-safe-nonce | c772a4585324d73d1001a44f66cb749b5048904689321dbff61276cd9b3b4ab8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkQyOjIzRUUxOkFEQzM2RTpFNTAxQjQ6NkFGODVBMTkiLCJ2aXNpdG9yX2lkIjoiNTE0MTg3MDk2OTUxNzI2NzQ4MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 156fe5838d8d21321a6ef300c712d215a72ae0aed8810e79f8edfef62fa94a82 |
| hovercard-subject-tag | issue:5091510852 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/mkdocstrings/python/337/issue_layout |
| twitter:image | https://opengraph.githubassets.com/faded1954107340992db31f5151eed8b18cfb43ce4a5dab3deb04965a3f142c5/mkdocstrings/python/issues/337 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/faded1954107340992db31f5151eed8b18cfb43ce4a5dab3deb04965a3f142c5/mkdocstrings/python/issues/337 |
| og:image:alt | Description With mkdocstrings-python 2.0.5 on griffelib 2.1.0, any configuration that uses docstring_style: sphinx and sets at least one key under docstring_options crashes on the first rendered do... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | selbs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| go-import | github.com/mkdocstrings/python git https://github.com/mkdocstrings/python.git |
| octolytics-dimension-user_id | 75664361 |
| octolytics-dimension-user_login | mkdocstrings |
| octolytics-dimension-repository_id | 422878404 |
| octolytics-dimension-repository_nwo | mkdocstrings/python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 422878404 |
| octolytics-dimension-repository_network_root_nwo | mkdocstrings/python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width