mirror of
https://github.com/davidhalter/parso.git
synced 2026-05-18 14:30:04 +08:00
Make namedexpr_test a proper NamedExpr class
This commit is contained in:
@@ -9,6 +9,7 @@ Unreleased (XXXX-XX-XX)
|
|||||||
- Dropped Support for Python 2.7, 3.4, 3.5
|
- Dropped Support for Python 2.7, 3.4, 3.5
|
||||||
- It's possible to use ``pathlib.Path`` objects now in the API
|
- It's possible to use ``pathlib.Path`` objects now in the API
|
||||||
- The stubs are gone, we are now using annotations
|
- The stubs are gone, we are now using annotations
|
||||||
|
- ``namedexpr_test`` nodes are now a proper class called ``NamedExpr``
|
||||||
- A lot of smaller refactorings
|
- A lot of smaller refactorings
|
||||||
|
|
||||||
0.7.1 (2020-07-24)
|
0.7.1 (2020-07-24)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class Parser(BaseParser):
|
|||||||
'decorator': tree.Decorator,
|
'decorator': tree.Decorator,
|
||||||
'lambdef': tree.Lambda,
|
'lambdef': tree.Lambda,
|
||||||
'lambdef_nocond': tree.Lambda,
|
'lambdef_nocond': tree.Lambda,
|
||||||
|
'namedexpr_test': tree.NamedExpr,
|
||||||
}
|
}
|
||||||
default_node = tree.PythonNode
|
default_node = tree.PythonNode
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ _FUNC_CONTAINERS = set(
|
|||||||
|
|
||||||
_GET_DEFINITION_TYPES = set([
|
_GET_DEFINITION_TYPES = set([
|
||||||
'expr_stmt', 'sync_comp_for', 'with_stmt', 'for_stmt', 'import_name',
|
'expr_stmt', 'sync_comp_for', 'with_stmt', 'for_stmt', 'import_name',
|
||||||
'import_from', 'param', 'del_stmt',
|
'import_from', 'param', 'del_stmt', 'namedexpr_test',
|
||||||
])
|
])
|
||||||
_IMPORTS = set(['import_name', 'import_from'])
|
_IMPORTS = set(['import_name', 'import_from'])
|
||||||
|
|
||||||
@@ -231,8 +231,6 @@ class Name(_LeafWithoutNewlines):
|
|||||||
while node is not None:
|
while node is not None:
|
||||||
if node.type == 'suite':
|
if node.type == 'suite':
|
||||||
return None
|
return None
|
||||||
if node.type == 'namedexpr_test':
|
|
||||||
return node.children[0]
|
|
||||||
if node.type in _GET_DEFINITION_TYPES:
|
if node.type in _GET_DEFINITION_TYPES:
|
||||||
if self in node.get_defined_names(include_setitem):
|
if self in node.get_defined_names(include_setitem):
|
||||||
return node
|
return node
|
||||||
@@ -1066,6 +1064,13 @@ class ExprStmt(PythonBaseNode, DocstringMixin):
|
|||||||
yield from self.children[3::2]
|
yield from self.children[3::2]
|
||||||
|
|
||||||
|
|
||||||
|
class NamedExpr(PythonBaseNode):
|
||||||
|
type = 'namedexpr_test'
|
||||||
|
|
||||||
|
def get_defined_names(self, include_setitem=False):
|
||||||
|
return _defined_names(self.children[0], include_setitem)
|
||||||
|
|
||||||
|
|
||||||
class Param(PythonBaseNode):
|
class Param(PythonBaseNode):
|
||||||
"""
|
"""
|
||||||
It's a helper class that makes business logic with params much easier. The
|
It's a helper class that makes business logic with params much easier. The
|
||||||
|
|||||||
Reference in New Issue
Block a user