mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
Rename .params to .get_params().
This commit is contained in:
@@ -199,7 +199,7 @@ class _Context(object):
|
||||
|
||||
params = []
|
||||
if self.node.type == 'funcdef':
|
||||
params = self.node.params
|
||||
params = self.node.get_params()
|
||||
|
||||
for base_name in globals_or_nonlocals:
|
||||
found_global_or_nonlocal = False
|
||||
@@ -534,7 +534,7 @@ class ErrorFinder(Normalizer):
|
||||
self._add_syntax_error(message, node)
|
||||
elif self._context.is_function():
|
||||
for nonlocal_name in node.children[1::2]:
|
||||
param_names = [p.name.value for p in self._context.node.params]
|
||||
param_names = [p.name.value for p in self._context.node.get_params()]
|
||||
if nonlocal_name.value == node:
|
||||
pass
|
||||
elif node.type == 'expr_stmt':
|
||||
|
||||
@@ -504,8 +504,7 @@ class Function(ClassOrFunc):
|
||||
def _get_param_nodes(self):
|
||||
return self.children[2].children
|
||||
|
||||
@property
|
||||
def params(self):
|
||||
def get_params(self):
|
||||
"""
|
||||
Returns a list of `Param()`.
|
||||
"""
|
||||
|
||||
@@ -17,7 +17,7 @@ def assert_params(param_string, version=None, **wanted_dct):
|
||||
module = parse(source, version=version)
|
||||
funcdef = next(module.iter_funcdefs())
|
||||
dct = dict((p.name.value, p.default and p.default.get_code())
|
||||
for p in funcdef.params)
|
||||
for p in funcdef.get_params())
|
||||
assert dct == wanted_dct
|
||||
assert module.get_code() == source
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ def test_param_splitting(each_version):
|
||||
# ignore them, because it's not what we want to support in the
|
||||
# future.
|
||||
func = next(m.iter_funcdefs())
|
||||
assert [param.name.value for param in func.params] == result
|
||||
assert [param.name.value for param in func.get_params()] == result
|
||||
else:
|
||||
assert not list(m.iter_funcdefs())
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ class TestsFunctionAndLambdaParsing(object):
|
||||
assert node.name.value == expected['name']
|
||||
|
||||
def test_params(self, node, expected):
|
||||
assert isinstance(node.params, list)
|
||||
assert all(isinstance(x, tree.Param) for x in node.params)
|
||||
assert [str(x.name.value) for x in node.params] == [x for x in expected['params']]
|
||||
assert isinstance(node.get_params(), list)
|
||||
assert all(isinstance(x, tree.Param) for x in node.get_params())
|
||||
assert [str(x.name.value) for x in node.get_params()] == [x for x in expected['params']]
|
||||
|
||||
def test_is_generator(self, node, expected):
|
||||
assert node.is_generator() is expected.get('is_generator', False)
|
||||
@@ -73,7 +73,7 @@ def test_end_pos_line(each_version):
|
||||
|
||||
def test_default_param(each_version):
|
||||
func = parse('def x(foo=42): pass', version=each_version).children[0]
|
||||
param, = func.params
|
||||
param, = func.get_params()
|
||||
assert param.default.value == '42'
|
||||
assert param.annotation is None
|
||||
assert not param.star_count
|
||||
@@ -81,7 +81,7 @@ def test_default_param(each_version):
|
||||
|
||||
def test_annotation_param(each_py3_version):
|
||||
func = parse('def x(foo: 3): pass', version=each_py3_version).children[0]
|
||||
param, = func.params
|
||||
param, = func.get_params()
|
||||
assert param.default is None
|
||||
assert param.annotation.value == '3'
|
||||
assert not param.star_count
|
||||
@@ -89,7 +89,7 @@ def test_annotation_param(each_py3_version):
|
||||
|
||||
def test_annotation_params(each_py3_version):
|
||||
func = parse('def x(foo: 3, bar: 4): pass', version=each_py3_version).children[0]
|
||||
param1, param2 = func.params
|
||||
param1, param2 = func.get_params()
|
||||
|
||||
assert param1.default is None
|
||||
assert param1.annotation.value == '3'
|
||||
@@ -102,7 +102,7 @@ def test_annotation_params(each_py3_version):
|
||||
|
||||
def test_default_and_annotation_param(each_py3_version):
|
||||
func = parse('def x(foo:3=42): pass', version=each_py3_version).children[0]
|
||||
param, = func.params
|
||||
param, = func.get_params()
|
||||
assert param.default.value == '42'
|
||||
assert param.annotation.value == '3'
|
||||
assert not param.star_count
|
||||
|
||||
Reference in New Issue
Block a user