Update gettext translations (#7636)

* Use a protocol instead of `IO` for `fp` argument.
* Annotate a few missing return types.
* Mark some class constants as final.

Fixes #7628
This commit is contained in:
Sebastian Rittau
2022-04-16 16:07:15 +02:00
committed by GitHub
parent 653f2c6ba4
commit 182fa6321c

View File

@@ -1,7 +1,8 @@
import sys
from _typeshed import StrPath
from typing import IO, Any, Container, Iterable, Sequence, TypeVar, overload
from typing_extensions import Literal
from collections.abc import Container, Iterable, Sequence
from typing import Any, Protocol, TypeVar, overload
from typing_extensions import Final, Literal
if sys.version_info >= (3, 11):
__all__ = [
@@ -67,9 +68,14 @@ else:
"ngettext",
]
class _TranslationsReader(Protocol):
def read(self) -> bytes: ...
# optional:
# name: str
class NullTranslations:
def __init__(self, fp: IO[str] | None = ...) -> None: ...
def _parse(self, fp: IO[str]) -> None: ...
def __init__(self, fp: _TranslationsReader | None = ...) -> None: ...
def _parse(self, fp: _TranslationsReader) -> None: ...
def add_fallback(self, fallback: NullTranslations) -> None: ...
def gettext(self, message: str) -> str: ...
def lgettext(self, message: str) -> str: ...
@@ -79,18 +85,18 @@ class NullTranslations:
def pgettext(self, context: str, message: str) -> str: ...
def npgettext(self, context: str, msgid1: str, msgid2: str, n: int) -> str: ...
def info(self) -> Any: ...
def charset(self) -> Any: ...
def info(self) -> dict[str, str]: ...
def charset(self) -> str | None: ...
if sys.version_info < (3, 11):
def output_charset(self) -> Any: ...
def output_charset(self) -> str | None: ...
def set_output_charset(self, charset: str) -> None: ...
def install(self, names: Container[str] | None = ...) -> None: ...
class GNUTranslations(NullTranslations):
LE_MAGIC: int
BE_MAGIC: int
CONTEXT: str
LE_MAGIC: Final[int]
BE_MAGIC: Final[int]
CONTEXT: Final[str]
VERSIONS: Sequence[int]
@overload # ignores incompatible overloads