As a maintainer of Jedi I was asked to provide feedback here. Thanks for reaching out!
I generally agree that it would be nice to have documentation for params in a more structured
way. There are a few things that could use improvement:
- I feel like there should be some sort of
typing.get_doc()
call for annotations at runtime. It’s just very normal that one is able to extract information from the typing module. Unlike PyCharm/mkdocs/VSCode, Jedi isn’t just a static analyzer, it can also be used within IPython/Jupyter and extract runtime information.
>>> def f(a: int): ...
...
>>> a = inspect.signature(f).parameters['a']
>>> a.annotation
<class 'int'>
>>> typing.get_doc(a.annotation)
- Like others have pointed out: It feels a bit wrong to use Annotated for this. If this is a really a Python stdlib provided feature, I would probably prefer something like
Doc[str, "The name of the user"]
, which is also shorter and more concise.
def foo(
x: Doc[str, "Lorem Ipsum"],
y: int,
) -> Doc[bool, "Lorem Ipsum Dolor"]:
...
I feel like that’s way more readable and for the tools like Mypy/Jedi/VSCode/etc, this is not a lot of extra work.