1
1
import sys
2
2
from _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
5
6
6
7
if sys .version_info >= (3 , 11 ):
7
8
__all__ = [
67
68
"ngettext" ,
68
69
]
69
70
71
+ class _TranslationsReader (Protocol ):
72
+ def read (self ) -> bytes : ...
73
+ # optional:
74
+ # name: str
75
+
70
76
class 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 : ...
73
79
def add_fallback (self , fallback : NullTranslations ) -> None : ...
74
80
def gettext (self , message : str ) -> str : ...
75
81
def lgettext (self , message : str ) -> str : ...
@@ -79,18 +85,18 @@ class NullTranslations:
79
85
def pgettext (self , context : str , message : str ) -> str : ...
80
86
def npgettext (self , context : str , msgid1 : str , msgid2 : str , n : int ) -> str : ...
81
87
82
- def info (self ) -> Any : ...
83
- def charset (self ) -> Any : ...
88
+ def info (self ) -> dict [ str , str ] : ...
89
+ def charset (self ) -> str | None : ...
84
90
if sys .version_info < (3 , 11 ):
85
- def output_charset (self ) -> Any : ...
91
+ def output_charset (self ) -> str | None : ...
86
92
def set_output_charset (self , charset : str ) -> None : ...
87
93
88
94
def install (self , names : Container [str ] | None = ...) -> None : ...
89
95
90
96
class 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 ]
94
100
VERSIONS : Sequence [int ]
95
101
96
102
@overload # ignores incompatible overloads
0 commit comments