|
1 |
| -from typing import Any |
| 1 | +import datetime |
| 2 | +from collections import OrderedDict |
| 3 | +from collections.abc import Generator, Iterable, Iterator |
| 4 | +from typing_extensions import TypeAlias |
| 5 | + |
| 6 | +from babel.core import Locale |
| 7 | + |
| 8 | +__all__ = ["Message", "Catalog", "TranslationError"] |
| 9 | + |
| 10 | +_MessageID: TypeAlias = str | tuple[str, ...] | list[str] |
2 | 11 |
|
3 | 12 | class Message:
|
4 |
| - id: Any |
5 |
| - string: Any |
6 |
| - locations: Any |
7 |
| - flags: Any |
8 |
| - auto_comments: Any |
9 |
| - user_comments: Any |
10 |
| - previous_id: Any |
11 |
| - lineno: Any |
12 |
| - context: Any |
| 13 | + id: _MessageID |
| 14 | + string: _MessageID |
| 15 | + locations: list[tuple[str, int]] |
| 16 | + flags: set[str] |
| 17 | + auto_comments: list[str] |
| 18 | + user_comments: list[str] |
| 19 | + previous_id: list[str] |
| 20 | + lineno: int | None |
| 21 | + context: str | None |
13 | 22 | def __init__(
|
14 | 23 | self,
|
15 |
| - id, |
| 24 | + id: str, |
16 | 25 | string: str = ...,
|
17 |
| - locations=..., |
18 |
| - flags=..., |
19 |
| - auto_comments=..., |
20 |
| - user_comments=..., |
21 |
| - previous_id=..., |
22 |
| - lineno: Any | None = ..., |
23 |
| - context: Any | None = ..., |
| 26 | + locations: Iterable[tuple[str, int]] = ..., |
| 27 | + flags: Iterable[str] = ..., |
| 28 | + auto_comments: Iterable[str] = ..., |
| 29 | + user_comments: Iterable[str] = ..., |
| 30 | + previous_id: _MessageID = ..., |
| 31 | + lineno: int | None = ..., |
| 32 | + context: str | None = ..., |
24 | 33 | ) -> None: ...
|
25 |
| - def __cmp__(self, other): ... |
26 |
| - def __gt__(self, other): ... |
27 |
| - def __lt__(self, other): ... |
28 |
| - def __ge__(self, other): ... |
29 |
| - def __le__(self, other): ... |
30 |
| - def __eq__(self, other): ... |
31 |
| - def __ne__(self, other): ... |
| 34 | + def __cmp__(self, other: Message) -> int: ... |
| 35 | + def __gt__(self, other: Message) -> bool: ... |
| 36 | + def __lt__(self, other: Message) -> bool: ... |
| 37 | + def __ge__(self, other: Message) -> bool: ... |
| 38 | + def __le__(self, other: Message) -> bool: ... |
| 39 | + def __eq__(self, other: object) -> bool: ... |
| 40 | + def __ne__(self, other: object) -> bool: ... |
32 | 41 | def is_identical(self, other: Message) -> bool: ...
|
33 |
| - def clone(self): ... |
34 |
| - def check(self, catalog: Any | None = ...): ... |
| 42 | + def clone(self) -> Message: ... |
| 43 | + def check(self, catalog: Catalog | None = ...) -> list[TranslationError]: ... |
35 | 44 | @property
|
36 |
| - def fuzzy(self): ... |
| 45 | + def fuzzy(self) -> bool: ... |
37 | 46 | @property
|
38 |
| - def pluralizable(self): ... |
| 47 | + def pluralizable(self) -> bool: ... |
39 | 48 | @property
|
40 |
| - def python_format(self): ... |
| 49 | + def python_format(self) -> bool: ... |
41 | 50 |
|
42 | 51 | class TranslationError(Exception): ...
|
43 | 52 |
|
44 | 53 | class Catalog:
|
45 |
| - domain: Any |
46 |
| - locale: Any |
47 |
| - project: Any |
48 |
| - version: Any |
49 |
| - copyright_holder: Any |
50 |
| - msgid_bugs_address: Any |
51 |
| - last_translator: Any |
52 |
| - language_team: Any |
53 |
| - charset: Any |
54 |
| - creation_date: Any |
55 |
| - revision_date: Any |
56 |
| - fuzzy: Any |
57 |
| - obsolete: Any |
| 54 | + domain: str | None |
| 55 | + project: str |
| 56 | + version: str |
| 57 | + copyright_holder: str |
| 58 | + msgid_bugs_address: str |
| 59 | + last_translator: str |
| 60 | + language_team: str |
| 61 | + charset: str |
| 62 | + creation_date: datetime.datetime | str |
| 63 | + revision_date: datetime.datetime | datetime.time | float | str |
| 64 | + fuzzy: bool |
| 65 | + obsolete: OrderedDict[str | tuple[str, str], Message] |
58 | 66 | def __init__(
|
59 | 67 | self,
|
60 |
| - locale: Any | None = ..., |
61 |
| - domain: Any | None = ..., |
62 |
| - header_comment=..., |
63 |
| - project: Any | None = ..., |
64 |
| - version: Any | None = ..., |
65 |
| - copyright_holder: Any | None = ..., |
66 |
| - msgid_bugs_address: Any | None = ..., |
67 |
| - creation_date: Any | None = ..., |
68 |
| - revision_date: Any | None = ..., |
69 |
| - last_translator: Any | None = ..., |
70 |
| - language_team: Any | None = ..., |
71 |
| - charset: Any | None = ..., |
| 68 | + locale: str | Locale | None = ..., |
| 69 | + domain: str | None = ..., |
| 70 | + header_comment: str | None = ..., |
| 71 | + project: str | None = ..., |
| 72 | + version: str | None = ..., |
| 73 | + copyright_holder: str | None = ..., |
| 74 | + msgid_bugs_address: str | None = ..., |
| 75 | + creation_date: datetime.datetime | str | None = ..., |
| 76 | + revision_date: datetime.datetime | datetime.time | float | str | None = ..., |
| 77 | + last_translator: str | None = ..., |
| 78 | + language_team: str | None = ..., |
| 79 | + charset: str | None = ..., |
72 | 80 | fuzzy: bool = ...,
|
73 | 81 | ) -> None: ...
|
74 | 82 | @property
|
75 |
| - def locale_identifier(self): ... |
76 |
| - header_comment: Any |
77 |
| - mime_headers: Any |
| 83 | + def locale(self) -> Locale | None: ... |
| 84 | + @locale.setter # Assigning a string looks up the right Locale object. |
| 85 | + def locale(self, value: Locale | str | None) -> None: ... |
| 86 | + @property |
| 87 | + def locale_identifier(self) -> str | None: ... |
| 88 | + @property |
| 89 | + def header_comment(self) -> str: ... |
| 90 | + @header_comment.setter |
| 91 | + def header_comment(self, value: str) -> None: ... |
| 92 | + @property |
| 93 | + def mime_headers(self) -> list[tuple[str, str]]: ... |
| 94 | + @mime_headers.setter |
| 95 | + def mime_headers(self, value: Iterable[tuple[str | bytes, str | bytes]]) -> None: ... |
78 | 96 | @property
|
79 |
| - def num_plurals(self): ... |
| 97 | + def num_plurals(self) -> int: ... |
80 | 98 | @property
|
81 |
| - def plural_expr(self): ... |
| 99 | + def plural_expr(self) -> str: ... |
82 | 100 | @property
|
83 |
| - def plural_forms(self): ... |
84 |
| - def __contains__(self, id): ... |
| 101 | + def plural_forms(self) -> str: ... |
| 102 | + def __contains__(self, id: _MessageID) -> bool: ... |
85 | 103 | def __len__(self) -> int: ...
|
86 |
| - def __iter__(self): ... |
87 |
| - def __delitem__(self, id) -> None: ... |
88 |
| - def __getitem__(self, id): ... |
89 |
| - def __setitem__(self, id, message) -> None: ... |
| 104 | + def __iter__(self) -> Iterator[Message]: ... |
| 105 | + def __delitem__(self, id: _MessageID) -> None: ... |
| 106 | + def __getitem__(self, id: _MessageID) -> Message: ... |
| 107 | + def __setitem__(self, id: _MessageID, message: Message) -> None: ... |
90 | 108 | def add(
|
91 | 109 | self,
|
92 |
| - id, |
93 |
| - string: Any | None = ..., |
94 |
| - locations=..., |
95 |
| - flags=..., |
96 |
| - auto_comments=..., |
97 |
| - user_comments=..., |
98 |
| - previous_id=..., |
99 |
| - lineno: Any | None = ..., |
100 |
| - context: Any | None = ..., |
101 |
| - ): ... |
102 |
| - def check(self) -> None: ... |
103 |
| - def get(self, id, context: Any | None = ...): ... |
104 |
| - def delete(self, id, context: Any | None = ...) -> None: ... |
| 110 | + id: _MessageID, |
| 111 | + string: _MessageID | None = ..., |
| 112 | + locations: Iterable[tuple[str, int]] = ..., |
| 113 | + flags: Iterable[str] = ..., |
| 114 | + auto_comments: Iterable[str] = ..., |
| 115 | + user_comments: Iterable[str] = ..., |
| 116 | + previous_id: _MessageID = ..., |
| 117 | + lineno: int | None = ..., |
| 118 | + context: str | None = ..., |
| 119 | + ) -> Message: ... |
| 120 | + def check(self) -> Generator[tuple[Message, list[TranslationError]], None, None]: ... |
| 121 | + def get(self, id: _MessageID, context: str | None = ...): ... |
| 122 | + def delete(self, id, context: str | None = ...) -> None: ... |
105 | 123 | def update(
|
106 |
| - self, template, no_fuzzy_matching: bool = ..., update_header_comment: bool = ..., keep_user_comments: bool = ... |
| 124 | + self, template: Catalog, no_fuzzy_matching: bool = ..., update_header_comment: bool = ..., keep_user_comments: bool = ... |
107 | 125 | ) -> None: ...
|
108 | 126 | def is_identical(self, other: Catalog) -> bool: ...
|
0 commit comments