feat(bindings): use CapsuleType in Python stub
This commit is contained in:
parent
46f7f860e6
commit
3d26b8e500
2 changed files with 20 additions and 4 deletions
|
|
@ -646,9 +646,24 @@ pub fn generate_grammar_files(
|
|||
generate_file(path, INIT_PY_TEMPLATE, language_name, &generate_opts)
|
||||
})?;
|
||||
|
||||
missing_path(lang_path.join("__init__.pyi"), |path| {
|
||||
generate_file(path, INIT_PYI_TEMPLATE, language_name, &generate_opts)
|
||||
})?;
|
||||
missing_path_else(
|
||||
lang_path.join("__init__.pyi"),
|
||||
allow_update,
|
||||
|path| generate_file(path, INIT_PYI_TEMPLATE, language_name, &generate_opts),
|
||||
|path| {
|
||||
let mut contents = fs::read_to_string(path)?;
|
||||
if !contents.contains("CapsuleType") {
|
||||
contents = contents
|
||||
.replace(
|
||||
"from typing import Final",
|
||||
"from typing import Final\nfrom typing_extensions import CapsuleType"
|
||||
)
|
||||
.replace("-> object:", "-> CapsuleType:");
|
||||
write_file(path, contents)?;
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
missing_path(lang_path.join("py.typed"), |path| {
|
||||
generate_file(path, "", language_name, &generate_opts) // py.typed is empty
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from typing import Final
|
||||
from typing_extensions import CapsuleType
|
||||
|
||||
# NOTE: uncomment these to include any queries that this grammar contains:
|
||||
|
||||
|
|
@ -7,4 +8,4 @@ from typing import Final
|
|||
# LOCALS_QUERY: Final[str]
|
||||
# TAGS_QUERY: Final[str]
|
||||
|
||||
def language() -> object: ...
|
||||
def language() -> CapsuleType: ...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue