Skip to content

Commit

Permalink
feat: improve rule typing
Browse files Browse the repository at this point in the history
part of #389
  • Loading branch information
HerringtonDarkholme committed Oct 23, 2023
1 parent 097a209 commit 80b255a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/pyo3/ast_grep_pyo3.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from typing import Optional
from typing import Optional, TypedDict, Unpack, NotRequired

class Pattern(TypedDict):
selector: str
context: str

class Rule(TypedDict):
pattern: NotRequired[str | Pattern]
kind: NotRequired[str]

class Pos:
line: int
Expand All @@ -16,6 +23,6 @@ class SgRoot:

class SgNode:
def range(self) -> Range: pass
def find(self, config = None, **kwargs) -> SgNode: ...
def find(self, config = None, **kwargs: Unpack[Rule]) -> SgNode: ...
def get_match(self, meta_var: str) -> Optional[SgNode]: ...
def text(self) -> str: ...

0 comments on commit 80b255a

Please sign in to comment.