Description
When type hints are generated for class methods that provide the types using the comment annotation format, some cases are not handled correctly. (i.e.: using # type: (<args>) -> <return>
)
- Base classes are replaced by the first argument from their corresponding
__init__
call.
For some reason, theParameters
section for the class'__init__
are not reported anywhere.
(maybe because they are already processed as base class components, instead of self, so no more parameters to process?) - Parameters in other methods have their types offset by one.
All this is most definitely caused by inspect.signature
that does not include self
or cls
definitions, since they are not to be provided type comments definitions (similar to how the instance reference is automatically passed during the method call and must not be passed as argument).
Instead of inspect.siganture
, one should use inspect.getfullargspec
to obtain the full arguments derived from type comments, including self
for methods or cls
for classmethods.
Use cases are demonstrated in below images.
using autodoc_typehints = "description"
with autodoc_typehints
disabled
corresponding code:
source code for reference: https://github.com/Ouranosinc/Magpie
and config: https://github.com/Ouranosinc/Magpie/blob/master/docs/conf.py