Skip to content

Commit 669d5cb

Browse files
Added pyphen (#15645)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 31e72d1 commit 669d5cb

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

stubs/pyphen/METADATA.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version = "0.17.2"
2+
upstream-repository = "https://github.com/Kozea/Pyphen"

stubs/pyphen/pyphen/__init__.pyi

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from collections.abc import Generator
2+
from pathlib import Path
3+
from typing import SupportsInt, TypeAlias
4+
from typing_extensions import Self
5+
6+
__all__ = ("LANGUAGES", "Pyphen", "language_fallback")
7+
LANGUAGES: dict[str, Path]
8+
_Data: TypeAlias = tuple[str, int, int]
9+
10+
def language_fallback(language: str) -> str: ...
11+
12+
class AlternativeParser:
13+
change: str
14+
index: int
15+
cut: int
16+
17+
def __init__(self, pattern: str, alternative: str) -> None: ...
18+
def __call__(self, value: str | SupportsInt) -> int: ...
19+
20+
class DataInt(int):
21+
data: _Data | None
22+
23+
def __new__(cls, value: int, data: _Data | None = ..., reference: DataInt | None = ...) -> Self: ...
24+
25+
class HyphDict:
26+
patterns: dict[str, tuple[int, tuple[int, ...]]]
27+
cache: dict[str, list[DataInt]]
28+
maxlen: int
29+
30+
def __init__(self, path: Path) -> None: ...
31+
def positions(self, word: str) -> list[DataInt]: ...
32+
33+
class Pyphen:
34+
hd: HyphDict
35+
36+
def __init__(
37+
self, filename: str | Path | None = ..., lang: str | None = ..., left: int = 2, right: int = 2, cache: bool = True
38+
) -> None: ...
39+
def positions(self, word: str) -> list[DataInt]: ...
40+
def iterate(self, word: str) -> Generator[tuple[str, str]]: ...
41+
def wrap(self, word: str, width: int, hyphen: str = "-") -> tuple[str, str] | None: ...
42+
def inserted(self, word: str, hyphen: str = "-") -> str: ...
43+
__call__ = iterate

0 commit comments

Comments
 (0)