Hi I'm trying to make pycharm's auto-complete works with **kwargs. To do this I'm wrote a doc string using epytext syntax which has a way to declare keyword arguments with @keyword p:
but it doesn't works.
Do someone know the way to fix it?
PS I have changed a docstring format in PyCharm setting.
If the keyword arguments are known ahead of time (and you want a docstring to explain them), then they should be explicitly listed in the function parameters. Each one can then be described with the normal @param
& @type
syntax. @keywords
is used to describe the rest of the keyword arguments that are unknown at development time.
For example:
class SomeClass:
def __init__(self, some_kw=None, some_kw_1=None, **other_kwargs):
"""
@param some_kw: A known-at-dev-time keyword argument
@type some_kw: str
@param some_kw_1: Another known-at-dev-time keyword argument
@type some_kw_1: str
@keyword other_kwargs: More kwargs that will be set on the instance
"""
self.some_kw = some_kw
self.some_kw_1 = some_kw_1
for k, v in other_kwargs:
setattr(self, k, v)
an_instance = SomeClass(some_kw="hello", other_kw="world")
print an_instance.some_kw
print an_instance.some_kw_1
print an_instance.other_kw
Output
> "hello"
> None
> "world"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.