# test.py
from typing import TypedDict
from typing_extensions import Unpack
class Options(TypedDict):
foo: int
class A:
def __init__(self,**kwargs: Unpack[Options]) -> None:
self.options = kwargs
It seems that the point is that it is trying to find Options inside A, not at the module level (here)
Traceback
Traceback (most recent call last):
File "/home/projects/sdk/test2.py", line 7, in <module>
data = griffe.load("test", extensions=extensions)
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe/loader.py", line 807, in load
result = loader.load(
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe/loader.py", line 233, in load
self.extensions.call("on_package_loaded", pkg=top_module)
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe/extensions/base.py", line 346, in call
getattr(extension, event)(**kwargs)
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe_typingdoc/_extension.py", line 125, in on_package_loaded
self._handle_object(pkg)
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe_typingdoc/_extension.py", line 110, in _handle_object
self._handle_object(member) # type: ignore[arg-type]
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe_typingdoc/_extension.py", line 110, in _handle_object
self._handle_object(member) # type: ignore[arg-type]
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe_typingdoc/_extension.py", line 112, in _handle_object
self._handle_function(obj) # type: ignore[arg-type]
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe_typingdoc/_extension.py", line 65, in _handle_function
other_params_section := module._other_parameters_docs(func, node=node),
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe_typingdoc/_static.py", line 131, in _other_parameters_docs
typed_dict = annotation.slice.parent.get_member(annotation.slice.name) # type: ignore[attr-defined]
File "/home/projects/virtualens/SF8d8bN-py3.9/lib/python3.9/site-packages/griffe/mixins.py", line 78, in get_member
return self.members[parts[0]] # type: ignore[attr-defined]
KeyError: 'Options'
Hi @redb0, thanks for the report. Looks like you're right! I'll fix this asap (PRs welcome too). Ideally we should resolve the name in the slice, then obtain it from the modules_collection.
The following example throws a
KeyError
exceptionI use:
It seems that the point is that it is trying to find
Options
insideA
, not at the module level (here)Traceback