Skip to content

Commit

Permalink
feat: add pytype for register language
Browse files Browse the repository at this point in the history
  • Loading branch information
HerringtonDarkholme committed Aug 9, 2024
1 parent 43e74e7 commit 8b660cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions crates/pyo3/ast_grep_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 55,15 @@ class Config(TypedDict, total=False):
utils: Dict[str, Rule]
transform: Dict[str, Mapping]

class CustomLang(TypedDict):
library_path: str
language_symbol: Optional[str]
meta_var_char: Optional[str]
expando_char: Optional[str]

def register_dynamic_language(langs: Dict[str, any]):
pass

__all__ = [
"Rule",
"Config",
Expand All @@ -66,4 75,5 @@ class Config(TypedDict, total=False):
"Pos",
"Range",
"Edit",
"register_dynamic_language",
]
5 changes: 3 additions & 2 deletions crates/pyo3/src/py_lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 20,7 @@ pub struct CustomLang {
language_symbol: Option<String>,
meta_var_char: Option<char>,
expando_char: Option<char>,
extensions: Vec<String>,
// extensions: Vec<String>,
}

#[pyfunction]
Expand Down Expand Up @@ -51,7 51,8 @@ fn to_registration(name: String, custom_lang: CustomLang, base: &Path) -> Regist
symbol: sym,
meta_var_char: custom_lang.meta_var_char,
expando_char: custom_lang.expando_char,
extensions: custom_lang.extensions,
// extensions: custom_lang.extensions,
extensions: vec![],
}
}

Expand Down

0 comments on commit 8b660cf

Please sign in to comment.