mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
gettext: fix unconstrained TypeVar (#7935)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import io
|
||||
import sys
|
||||
from _typeshed import StrPath
|
||||
from collections.abc import Container, Iterable, Sequence
|
||||
from collections.abc import Callable, Container, Iterable, Sequence
|
||||
from typing import Any, Protocol, TypeVar, overload
|
||||
from typing_extensions import Final, Literal
|
||||
|
||||
@@ -110,7 +111,7 @@ def find(
|
||||
@overload
|
||||
def find(domain: str, localedir: StrPath | None = ..., languages: Iterable[str] | None = ..., all: bool = ...) -> Any: ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_NullTranslationsT = TypeVar("_NullTranslationsT", bound=NullTranslations)
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
@overload
|
||||
@@ -119,24 +120,33 @@ if sys.version_info >= (3, 11):
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: None = ...,
|
||||
fallback: Literal[False] = ...,
|
||||
) -> GNUTranslations: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
*,
|
||||
class_: Callable[[io.BufferedReader], _NullTranslationsT],
|
||||
fallback: Literal[False] = ...,
|
||||
) -> _NullTranslationsT: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None,
|
||||
languages: Iterable[str] | None,
|
||||
class_: Callable[[io.BufferedReader], _NullTranslationsT],
|
||||
fallback: Literal[False] = ...,
|
||||
) -> _NullTranslationsT: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: Callable[[io.BufferedReader], NullTranslations] | None = ...,
|
||||
fallback: bool = ...,
|
||||
) -> NullTranslations: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: type[_T] = ...,
|
||||
fallback: Literal[False] = ...,
|
||||
) -> _T: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: type[Any] = ...,
|
||||
fallback: Literal[True] = ...,
|
||||
) -> Any: ...
|
||||
def install(domain: str, localedir: StrPath | None = ..., *, names: Container[str] | None = ...) -> None: ...
|
||||
|
||||
else:
|
||||
@@ -146,27 +156,37 @@ else:
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: None = ...,
|
||||
fallback: Literal[False] = ...,
|
||||
codeset: str | None = ...,
|
||||
) -> GNUTranslations: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
*,
|
||||
class_: Callable[[io.BufferedReader], _NullTranslationsT],
|
||||
fallback: Literal[False] = ...,
|
||||
codeset: str | None = ...,
|
||||
) -> _NullTranslationsT: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None,
|
||||
languages: Iterable[str] | None,
|
||||
class_: Callable[[io.BufferedReader], _NullTranslationsT],
|
||||
fallback: Literal[False] = ...,
|
||||
codeset: str | None = ...,
|
||||
) -> _NullTranslationsT: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: Callable[[io.BufferedReader], NullTranslations] | None = ...,
|
||||
fallback: bool = ...,
|
||||
codeset: str | None = ...,
|
||||
) -> NullTranslations: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: type[_T] = ...,
|
||||
fallback: Literal[False] = ...,
|
||||
codeset: str | None = ...,
|
||||
) -> _T: ...
|
||||
@overload
|
||||
def translation(
|
||||
domain: str,
|
||||
localedir: StrPath | None = ...,
|
||||
languages: Iterable[str] | None = ...,
|
||||
class_: type[Any] = ...,
|
||||
fallback: Literal[True] = ...,
|
||||
codeset: str | None = ...,
|
||||
) -> Any: ...
|
||||
def install(
|
||||
domain: str, localedir: StrPath | None = ..., codeset: str | None = ..., names: Container[str] | None = ...
|
||||
) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user