Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stubs/titlecase/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# typing the tests would present a requiremnt of effort with zero gain for the end user
titlecase.tests
3 changes: 3 additions & 0 deletions stubs/titlecase/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = "2.4.*"
upstream-repository = "https://github.com/ppannuto/python-titlecase"
dependencies = ["types-regex"]
49 changes: 49 additions & 0 deletions stubs/titlecase/titlecase/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import logging
import re
from typing import Final, Protocol, TypeAlias, overload, type_check_only
from typing_extensions import LiteralString

import regex

_Pattern: TypeAlias = re.Pattern[str] | regex.Pattern[str]

__all__ = ["titlecase"]
__version__: Final[str]
logger: Final[logging.Logger]

REGEX_AVAILABLE: Final[bool]

SMALL: Final[str]
PUNCT: Final[str]

SMALL_WORDS: _Pattern
SMALL_FIRST: _Pattern
SMALL_LAST: _Pattern
SUBPHRASE: _Pattern

MAC_MC: Final[_Pattern]
MR_MRS_MS_DR: Final[_Pattern]
INLINE_PERIOD: Final[_Pattern]
UC_ELSEWHERE: Final[_Pattern]
CAPFIRST: Final[_Pattern]
APOS_SECOND: Final[_Pattern]
UC_INITIALS: Final[_Pattern]

@type_check_only
class _CallbackProtocol(Protocol):
def __call__(self, word: str, /, *, all_caps: bool) -> str | None: ...

class Immutable: ...
class ImmutableString(str, Immutable): ...
class ImmutableBytes(bytes, Immutable): ...

@overload
def set_small_word_list() -> None: ...
@overload
def set_small_word_list(small: str) -> None: ...

def titlecase(
text: str, callback: _CallbackProtocol | None = None, small_first_last: bool = True, preserve_blank_lines: bool = False
) -> LiteralString: ...
def create_wordlist_filter_from_file(file_path: str | None) -> _CallbackProtocol: ...
def cmd() -> None: ...