Skip to content

Commit 6ef8edd

Browse files
committed
Implement patchedast for type alias
1 parent 0c77b6e commit 6ef8edd

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# **Upcoming release**
22

33
- #850 Update and pin black version in pre-commit and Github Actions
4-
- #850 Bump supported python version to up to Python 3.14
4+
- #851 Bump supported python version to up to Python 3.14
5+
- #852 Implement patchedast for TypeAlias
56

67
# Release 1.14.0
78

rope/refactor/patchedast.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,10 @@ def _MatchMapping(self, node):
825825
children.append("}")
826826
self._handle(node, children)
827827

828+
def _TypeAlias(self, node):
829+
children = ["type", node.name, node.value]
830+
self._handle(node, children)
831+
828832

829833
class _Source:
830834
def __init__(self, source):

ropetest/refactor/patchedasttest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,20 @@ def test_match_node_with_match_mapping_match_as(self):
15101510
"}",
15111511
])
15121512

1513+
def test_type_alias(self):
1514+
source = dedent("""\
1515+
type Point = tuple[float, float]
1516+
""")
1517+
ast_frag = patchedast.get_patched_ast(source, True)
1518+
checker = _ResultChecker(self, ast_frag)
1519+
checker.check_children("TypeAlias", [
1520+
"type",
1521+
" ",
1522+
"Name",
1523+
" = ",
1524+
"Subscript",
1525+
])
1526+
15131527

15141528
class _ResultChecker:
15151529
def __init__(self, test_case, ast):

0 commit comments

Comments
 (0)