I’d wrote a function, that takes any python object and create file.py
: a synopsis about the object with listing and describing all of it’s methods.
For example, when I pass 'str'
to function, I get <class 'str'> synopsis.py
, which includes such info block as:
"""
upper()
Return a copy of the string converted to uppercase.
"""
...
The 'upper'
string is taken from dir(str)
.
The describing string is taken from getattr(str, 'upper').__doc__
But I can’t get THIS string yet: "def upper(self: LiteralString) -> LiteralString"
(or, maybe, string like this).
Its appear in PyCharm Documentation Popup when You hover over the str.upper()
method.
I had try to get access to source file for such methods (builtins.py
) to get this annotation string somehow, but failed in it.
Benedict Abub is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
0