Skip to content

Commit

Permalink
feat: support runtime Dict
Browse files Browse the repository at this point in the history
part of #389
  • Loading branch information
HerringtonDarkholme committed Nov 5, 2023
1 parent 46044dc commit 5e51e98
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
15 changes: 15 additions & 0 deletions crates/pyo3/ast_grep_pyo3/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from .ast_grep_pyo3 import SgNode, SgRoot, Pos, Range

Pattern = dict
Config = dict
Rule = dict

__all__ = (
"Rule",
"Config",
"Pattern",
"SgNode",
"SgRoot",
"Pos",
"Range",
)
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,14 @@ class SgNode:
def next(self) -> Optional[SgNode]: ...
def next_all(self) -> List[SgNode]: ...
def prev(self) -> Optional[SgNode]: ...
def prev_all(self) -> List[SgNode]: ...
def prev_all(self) -> List[SgNode]: ...

__all__ = (
"Rule",
"Config",
"Pattern",
"SgNode",
"SgRoot",
"Pos",
"Range",
)
Empty file.
4 changes: 3 additions & 1 deletion crates/pyo3/tests/test_range.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ast_grep_pyo3 import SgRoot
from ast_grep_pyo3 import SgRoot, Range, Pos

source = """
function test() {
Expand All @@ -19,6 +19,7 @@ def test_pos():
r2 = node2.range()
pos = r1.start
pos2 = r2.start
assert isinstance(pos, Pos)
assert pos.line == 1
assert pos.column == 2
assert pos.index == 20
Expand All @@ -29,6 +30,7 @@ def test_pos():
def test_range():
r1 = node1.range()
r2 = node2.range()
assert isinstance(r1, Range)
assert r1.start.line == 1
assert r1.end.line == 1
assert r1.start.column == 2
Expand Down

0 comments on commit 5e51e98

Please sign in to comment.