11import sys
22from _typeshed import StrPath
3- from typing import IO , Any , Container , Iterable , Sequence , TypeVar , overload
4- from typing_extensions import Literal
3+ from collections .abc import Container , Iterable , Sequence
4+ from typing import Any , Protocol , TypeVar , overload
5+ from typing_extensions import Final , Literal
56
67if sys .version_info >= (3 , 11 ):
78 __all__ = [
6768 "ngettext" ,
6869 ]
6970
71+ class _TranslationsReader (Protocol ):
72+ def read (self ) -> bytes : ...
73+ # optional:
74+ # name: str
75+
7076class NullTranslations :
71- def __init__ (self , fp : IO [ str ] | None = ...) -> None : ...
72- def _parse (self , fp : IO [ str ] ) -> None : ...
77+ def __init__ (self , fp : _TranslationsReader | None = ...) -> None : ...
78+ def _parse (self , fp : _TranslationsReader ) -> None : ...
7379 def add_fallback (self , fallback : NullTranslations ) -> None : ...
7480 def gettext (self , message : str ) -> str : ...
7581 def lgettext (self , message : str ) -> str : ...
@@ -79,18 +85,18 @@ class NullTranslations:
7985 def pgettext (self , context : str , message : str ) -> str : ...
8086 def npgettext (self , context : str , msgid1 : str , msgid2 : str , n : int ) -> str : ...
8187
82- def info (self ) -> Any : ...
83- def charset (self ) -> Any : ...
88+ def info (self ) -> dict [ str , str ] : ...
89+ def charset (self ) -> str | None : ...
8490 if sys .version_info < (3 , 11 ):
85- def output_charset (self ) -> Any : ...
91+ def output_charset (self ) -> str | None : ...
8692 def set_output_charset (self , charset : str ) -> None : ...
8793
8894 def install (self , names : Container [str ] | None = ...) -> None : ...
8995
9096class GNUTranslations (NullTranslations ):
91- LE_MAGIC : int
92- BE_MAGIC : int
93- CONTEXT : str
97+ LE_MAGIC : Final [ int ]
98+ BE_MAGIC : Final [ int ]
99+ CONTEXT : Final [ str ]
94100 VERSIONS : Sequence [int ]
95101
96102@overload # ignores incompatible overloads
0 commit comments