diff --git a/stubs/pyphen/METADATA.toml b/stubs/pyphen/METADATA.toml new file mode 100644 index 000000000000..f6b2d875f6b8 --- /dev/null +++ b/stubs/pyphen/METADATA.toml @@ -0,0 +1,2 @@ +version = "0.17.2" +upstream-repository = "https://github.com/Kozea/Pyphen" diff --git a/stubs/pyphen/pyphen/__init__.pyi b/stubs/pyphen/pyphen/__init__.pyi new file mode 100644 index 000000000000..0507b0c3eff1 --- /dev/null +++ b/stubs/pyphen/pyphen/__init__.pyi @@ -0,0 +1,40 @@ +from collections.abc import Generator +from pathlib import Path +from typing import Any +from typing_extensions import Self + +__all__ = ("LANGUAGES", "Pyphen", "language_fallback") +LANGUAGES: dict[str, Path] + +def language_fallback(language: str) -> str: ... + +class AlternativeParser: + change: str + index: int + cut: int + + def __init__(self, pattern: str, alternative: str) -> None: ... + def __call__(self, value: str) -> int: ... + +class DataInt(int): + def __new__(cls, value: int, data: Any = ..., reference: DataInt | None = ...) -> Self: ... + +class HyphDict: + patterns: dict[str, tuple[int, tuple[int, ...]]] + cache: dict[str, list[DataInt]] + maxlen: int + + def __init__(self, path: Path) -> None: ... + def positions(self, word: str) -> list[DataInt]: ... + +class Pyphen: + hd: HyphDict + + def __init__( + self, filename: str | Path | None = ..., lang: str | None = ..., left: int = 2, right: int = 2, cache: bool = True + ) -> None: ... + def positions(self, word: str) -> list[DataInt]: ... + def iterate(self, word: str) -> Generator[tuple[str, str]]: ... + def wrap(self, word: str, width: int, hyphen: str = "-") -> tuple[str, str] | None: ... + def inserted(self, word: str, hyphen: str = "-") -> str: ... + __call__ = iterate