comparison stubs/twisted/words/xish/domish.pyi @ 3911:8289ac1b34f4

plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo: - support for both (modern) OMEMO under the `urn:xmpp:omemo:2` namespace and (legacy) OMEMO under the `eu.siacs.conversations.axolotl` namespace - maintains one identity across both versions of OMEMO - migrates data from the old plugin - includes more features for protocol stability - uses SCE for modern OMEMO - fully type-checked, linted and format-checked - added type hints to various pieces of backend code used by the plugin - added stubs for some Twisted APIs used by the plugin under stubs/ (use `export MYPYPATH=stubs/` before running mypy) - core (xmpp): enabled `send` trigger and made it an asyncPoint fix 375
author Syndace <me@syndace.dev>
date Tue, 23 Aug 2022 21:06:24 +0200
parents
children
comparison
equal deleted inserted replaced
3910:199598223f82 3911:8289ac1b34f4
1 from typing import (
2 Dict, Iterator, List, Literal, Optional, Tuple, TypeVar, Union, overload
3 )
4
5
6 URI = str
7 Name = str
8 QName = Tuple[Optional[URI], Name]
9 AttributeKey = Union[QName, Name]
10 Attributes = Dict[AttributeKey, str]
11 Prefix = str
12
13
14 D = TypeVar("D")
15
16
17 # Note: these typings are incomplete and evolve as needed.
18 class Element:
19 uri: Optional[URI]
20 name: Name
21 defaultUri: Optional[URI]
22 children: List[Union["Element", str]]
23 attributes: Attributes
24
25 def __init__(
26 self,
27 qname: QName,
28 defaultUri: Optional[URI] = None,
29 attribs: Optional[Attributes] = None,
30 localPrefixes: Optional[Dict[URI, Prefix]] = None
31 ) -> None:
32 ...
33
34 def __getitem__(self, key: AttributeKey) -> str:
35 ...
36
37 def __setitem__(self, key: AttributeKey, value: str) -> None:
38 ...
39
40 @overload
41 def getAttribute(
42 self,
43 attribname: AttributeKey,
44 default: None = None
45 ) -> Union[str, None]:
46 ...
47
48 @overload
49 def getAttribute(self, attribname: AttributeKey, default: D) -> Union[str, D]:
50 ...
51
52 def addChild(self, node: "Element") -> "Element":
53 ...
54
55 def addContent(self, text: str) -> str:
56 ...
57
58 def addElement(
59 self,
60 name: Union[QName, Name],
61 defaultUri: Optional[URI] = None,
62 content: Optional[str] = None
63 ) -> "Element":
64 ...
65
66 def elements(
67 self,
68 uri: Optional[URI] = None,
69 name: Optional[Name] = None
70 ) -> Iterator["Element"]:
71 ...
72
73 def toXml(
74 self,
75 prefixes: Optional[Dict[URI, Prefix]] = None,
76 closeElement: Literal[0, 1] = 1,
77 defaultUri: str = "",
78 prefixesInScope: Optional[List[Prefix]] = None
79 ) -> str:
80 ...