forked from VimPlug/jedi
Param docstring.
This commit is contained in:
@@ -925,6 +925,10 @@ class Param(PythonBaseNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def star_count(self):
|
def star_count(self):
|
||||||
|
"""
|
||||||
|
Is `0` in case of `foo`, `1` in case of `*foo` or `2` in case of
|
||||||
|
`**foo`.
|
||||||
|
"""
|
||||||
first = self.children[0]
|
first = self.children[0]
|
||||||
if first in ('*', '**'):
|
if first in ('*', '**'):
|
||||||
return len(first.value)
|
return len(first.value)
|
||||||
@@ -932,6 +936,10 @@ class Param(PythonBaseNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def default(self):
|
def default(self):
|
||||||
|
"""
|
||||||
|
The default is the test node that appears after the `=`. Is `None` in
|
||||||
|
case no default is present.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.children[int(self.children[0] in ('*', '**')) + 2]
|
return self.children[int(self.children[0] in ('*', '**')) + 2]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@@ -939,6 +947,10 @@ class Param(PythonBaseNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def annotation(self):
|
def annotation(self):
|
||||||
|
"""
|
||||||
|
The default is the test node that appears after `->`. Is `None` in case
|
||||||
|
no annotation is present.
|
||||||
|
"""
|
||||||
tfpdef = self._tfpdef()
|
tfpdef = self._tfpdef()
|
||||||
if tfpdef.type == 'tfpdef':
|
if tfpdef.type == 'tfpdef':
|
||||||
assert tfpdef.children[1] == ":"
|
assert tfpdef.children[1] == ":"
|
||||||
@@ -957,6 +969,9 @@ class Param(PythonBaseNode):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
"""
|
||||||
|
The `Name` leaf of the param.
|
||||||
|
"""
|
||||||
if self._tfpdef().type == 'tfpdef':
|
if self._tfpdef().type == 'tfpdef':
|
||||||
return self._tfpdef().children[0]
|
return self._tfpdef().children[0]
|
||||||
else:
|
else:
|
||||||
@@ -965,7 +980,7 @@ class Param(PythonBaseNode):
|
|||||||
@property
|
@property
|
||||||
def position_index(self):
|
def position_index(self):
|
||||||
"""
|
"""
|
||||||
Returns the positional index of a paramter.
|
Property for the positional index of a paramter.
|
||||||
"""
|
"""
|
||||||
index = self.parent.children.index(self)
|
index = self.parent.children.index(self)
|
||||||
try:
|
try:
|
||||||
@@ -979,7 +994,7 @@ class Param(PythonBaseNode):
|
|||||||
|
|
||||||
def get_parent_function(self):
|
def get_parent_function(self):
|
||||||
"""
|
"""
|
||||||
Returns the function/lambda a paramter is defined in.
|
Returns the function/lambda of a parameter.
|
||||||
"""
|
"""
|
||||||
return search_ancestor(self, ('funcdef', 'lambdef'))
|
return search_ancestor(self, ('funcdef', 'lambdef'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user