Skip to content

Commit 15ca6d8

Browse files
committed
fix: Fix type errors with options during collection and docstring parsing
1 parent c8bee99 commit 15ca6d8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/mkdocstrings_handlers/python/handler.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ def get_options(self, local_options: Mapping[str, Any]) -> HandlerOptions:
195195
def collect(self, identifier: str, options: PythonOptions) -> CollectorItem: # noqa: D102
196196
module_name = identifier.split(".", 1)[0]
197197
unknown_module = module_name not in self._modules_collection
198-
if options == {} and unknown_module:
199-
raise CollectionError("Not loading additional modules during fallback")
198+
reapply = True
199+
if options == {}:
200+
if unknown_module:
201+
raise CollectionError("Not loading additional modules during fallback")
202+
options = self.get_options({})
203+
reapply = False
200204

201205
parser_name = options.docstring_style
202206
parser = parser_name and Parser(parser_name)
@@ -244,11 +248,11 @@ def collect(self, identifier: str, options: PythonOptions) -> CollectorItem: #
244248
except AliasResolutionError as error:
245249
raise CollectionError(str(error)) from error
246250

247-
if not unknown_module:
251+
if not unknown_module and reapply:
248252
with suppress(AliasResolutionError):
249253
if doc_object.docstring is not None:
250254
doc_object.docstring.parser = parser
251-
doc_object.docstring.parser_options = parser_options
255+
doc_object.docstring.parser_options = parser_options or {}
252256

253257
return doc_object
254258

0 commit comments

Comments
 (0)