mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #4158: pycode.parser failed to parse starred assignment
This commit is contained in:
parent
3369d9a03a
commit
4fdcae0584
@ -62,6 +62,8 @@ def get_lvar_names(node, self=None):
|
||||
raise TypeError('The assignment %r is not instance variable' % node)
|
||||
elif node_name == 'str':
|
||||
return [node] # type: ignore
|
||||
elif node_name == 'Starred':
|
||||
return [node.value.id] # type: ignore
|
||||
else:
|
||||
raise NotImplementedError('Unexpected node name %r' % node_name)
|
||||
|
||||
|
@ -9,6 +9,9 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from six import PY2
|
||||
|
||||
from sphinx.pycode.parser import Parser
|
||||
|
||||
|
||||
@ -116,6 +119,18 @@ def test_complex_assignment():
|
||||
assert parser.definitions == {}
|
||||
|
||||
|
||||
@pytest.mark.skipif(PY2, reason='tests for py3 syntax')
|
||||
def test_complex_assignment_py3():
|
||||
source = 'a, *b, c = (1, 2, 3, 4) #: unpack assignment\n'
|
||||
parser = Parser(source)
|
||||
parser.parse()
|
||||
assert parser.comments == {('', 'a'): 'unpack assignment',
|
||||
('', 'b'): 'unpack assignment',
|
||||
('', 'c'): 'unpack assignment',
|
||||
}
|
||||
assert parser.definitions == {}
|
||||
|
||||
|
||||
def test_obj_assignment():
|
||||
source = ('obj = SomeObject() #: some object\n'
|
||||
'obj.attr = 1 #: attr1\n'
|
||||
|
Loading…
Reference in New Issue
Block a user