1
1
import logging
2
- from _typeshed import Incomplete , SupportsWrite
3
- from collections .abc import Iterable , Iterator
4
- from typing import Any , Final , Literal , TypeVar , overload
2
+ import re
3
+ from _typeshed import Incomplete , MaybeNone , SupportsWrite
4
+ from collections .abc import Generator , Iterator
5
+ from typing import Any , AnyStr , Final , Literal , TypeVar , overload
6
+ from typing_extensions import Self
5
7
6
8
_V = TypeVar ("_V" , bound = VBase )
7
9
_W = TypeVar ("_W" , bound = SupportsWrite [bytes ])
8
10
11
+ VERSION : Final [str ]
12
+
13
+ def to_unicode (value : str | bytes | bytearray ) -> str : ...
14
+ def to_basestring (s : str | bytes ) -> bytes : ...
15
+
9
16
logger : logging .Logger
10
17
DEBUG : bool
11
18
CR : str
@@ -15,8 +22,6 @@ SPACE: str
15
22
TAB : str
16
23
SPACEORTAB : str
17
24
18
- VERSION : Final [str ]
19
-
20
25
class VBase :
21
26
group : Incomplete | None
22
27
behavior : Incomplete | None
@@ -41,44 +46,53 @@ class VBase:
41
46
@overload
42
47
def serialize (self , buf : _W , lineLength : int = 75 , validate : bool = True , behavior = None , * args : Any , ** kwargs : Any ) -> _W : ...
43
48
44
- def toVName (name , stripNum : int = 0 , upper : bool = False ): ...
49
+ def toVName (name : str , stripNum : int = 0 , upper : bool = False ) -> str : ...
45
50
46
51
class ContentLine (VBase ):
47
- name : Incomplete
48
- encoded : Incomplete
49
- params : Incomplete
50
- singletonparams : Incomplete
51
- isNative : Incomplete
52
- lineNumber : Incomplete
53
- value : Incomplete
52
+ name : str
53
+ encoded : bool
54
+ params : dict [ Incomplete , list [ Incomplete ]]
55
+ singletonparams : list [ Incomplete ]
56
+ isNative : bool
57
+ lineNumber : int | None
58
+ value : str
54
59
def __init__ (
55
- self , name , params , value , group = None , encoded : bool = False , isNative : bool = False , lineNumber = None , * args , ** kwds
60
+ self ,
61
+ name : str ,
62
+ params : dict [Incomplete , list [Incomplete ]],
63
+ value : str ,
64
+ group = None ,
65
+ encoded : bool = False ,
66
+ isNative : bool = False ,
67
+ lineNumber : int | None = None ,
68
+ * args ,
69
+ ** kwds ,
56
70
) -> None : ...
57
71
@classmethod
58
- def duplicate (cls , copyit ): ...
72
+ def duplicate (cls , copyit ) -> Self : ...
59
73
def copy (self , copyit ) -> None : ...
60
74
def __eq__ (self , other ): ...
61
75
def __getattr__ (self , name : str ): ...
62
76
def __setattr__ (self , name : str , value ) -> None : ...
63
77
def __delattr__ (self , name : str ) -> None : ...
64
- def valueRepr (self ): ...
78
+ def valueRepr (self ) -> str : ...
65
79
def __unicode__ (self ) -> str : ...
66
80
def prettyPrint (self , level : int = 0 , tabwidth : int = 3 ) -> None : ...
67
81
68
82
class Component (VBase ):
69
83
contents : dict [str , list [VBase ]]
70
- name : Incomplete
84
+ name : str
71
85
useBegin : bool
72
- def __init__ (self , name = None , * args , ** kwds ) -> None : ...
86
+ def __init__ (self , name : str | None = None , * args , ** kwds ) -> None : ...
73
87
@classmethod
74
- def duplicate (cls , copyit ): ...
88
+ def duplicate (cls , copyit ) -> Self : ...
75
89
def copy (self , copyit ) -> None : ...
76
- def setProfile (self , name ) -> None : ...
90
+ def setProfile (self , name : str ) -> None : ...
77
91
def __getattr__ (self , name : str ): ...
78
- normal_attributes : Incomplete
92
+ normal_attributes : list [ str ]
79
93
def __setattr__ (self , name : str , value ) -> None : ...
80
94
def __delattr__ (self , name : str ) -> None : ...
81
- def getChildValue (self , childName , default = None , childNumber : int = 0 ): ...
95
+ def getChildValue (self , childName : str , default = None , childNumber : int = 0 ): ...
82
96
@overload
83
97
def add (self , objOrName : _V , group : str | None = None ) -> _V : ...
84
98
@overload
@@ -91,45 +105,47 @@ class Component(VBase):
91
105
def add (self , objOrName : str , group : str | None = None ) -> Any : ... # returns VBase sub-class
92
106
def remove (self , obj ) -> None : ...
93
107
def getChildren (self ) -> list [Incomplete ]: ...
94
- def components (self ) -> Iterable [Component ]: ...
95
- def lines (self ): ...
96
- def sortChildKeys (self ): ...
97
- def getSortedChildren (self ): ...
108
+ def components (self ) -> Generator [Component ]: ...
109
+ def lines (self ) -> Generator [ ContentLine ] : ...
110
+ def sortChildKeys (self ) -> list [ Incomplete ] : ...
111
+ def getSortedChildren (self ) -> list [ Incomplete ] : ...
98
112
def setBehaviorFromVersionLine (self , versionLine ) -> None : ...
99
113
def transformChildrenToNative (self ) -> None : ...
100
114
def transformChildrenFromNative (self , clearBehavior : bool = True ) -> None : ...
101
115
def prettyPrint (self , level : int = 0 , tabwidth : int = 3 ) -> None : ...
102
116
103
117
class VObjectError (Exception ):
104
- msg : Incomplete
105
- lineNumber : Incomplete
106
- def __init__ (self , msg , lineNumber = None ) -> None : ...
118
+ msg : str
119
+ lineNumber : int
120
+ def __init__ (self , msg : str , lineNumber : int | None = None ) -> None : ...
107
121
108
122
class ParseError (VObjectError ): ...
109
123
class ValidateError (VObjectError ): ...
110
124
class NativeError (VObjectError ): ...
111
125
112
- patterns : Incomplete
113
- param_values_re : Incomplete
114
- params_re : Incomplete
115
- line_re : Incomplete
116
- begin_re : Incomplete
126
+ patterns : dict [ str , str ]
127
+ param_values_re : re . Pattern [ str ]
128
+ params_re : re . Pattern [ str ]
129
+ line_re : re . Pattern [ str ]
130
+ begin_re : re . Pattern [ str ]
117
131
118
- def parseParams (string ): ...
119
- def parseLine (line , lineNumber = None ): ...
132
+ def parseParams (string : str ) -> list [list [Any ]]: ... # Any was taken from re module stubs
133
+ def parseLine (
134
+ line : str , lineNumber : int | None = None
135
+ ) -> tuple [str , list [list [Any ]], str | MaybeNone , str | MaybeNone ]: ... # Any is result of parseParams()
120
136
121
- wrap_re : Incomplete
122
- logical_lines_re : Incomplete
137
+ wrap_re : re . Pattern [ str ]
138
+ logical_lines_re : re . Pattern [ str ]
123
139
testLines : str
124
140
125
- def getLogicalLines (fp , allowQP : bool = True ) -> None : ...
126
- def textLineToContentLine (text , n = None ): ...
127
- def dquoteEscape (param ) : ...
128
- def foldOneLine (outbuf , input , lineLength : int = 75 ) -> None : ...
129
- def defaultSerialize (obj , buf , lineLength ): ...
141
+ def getLogicalLines (fp , allowQP : bool = True ) -> Generator [ tuple [ str , int ]] : ...
142
+ def textLineToContentLine (text , n : int | None = None ) -> ContentLine : ...
143
+ def dquoteEscape (param : str ) -> str : ...
144
+ def foldOneLine (outbuf : SupportsWrite [ AnyStr ] , input : AnyStr , lineLength : int = 75 ) -> None : ...
145
+ def defaultSerialize (obj : Component | ContentLine , buf , lineLength : int ): ...
130
146
131
147
class Stack :
132
- stack : Incomplete
148
+ stack : list [ Incomplete ]
133
149
def __len__ (self ) -> int : ...
134
150
def top (self ): ...
135
151
def topName (self ): ...
@@ -141,7 +157,7 @@ def readComponents(
141
157
streamOrString , validate : bool = False , transform : bool = True , ignoreUnreadable : bool = False , allowQP : bool = False
142
158
) -> Iterator [Component ]: ...
143
159
def readOne (stream , validate : bool = False , transform : bool = True , ignoreUnreadable : bool = False , allowQP : bool = False ): ...
144
- def registerBehavior (behavior , name = None , default : bool = False , id = None ) -> None : ...
145
- def getBehavior (name , id = None ): ...
146
- def newFromBehavior (name , id = None ): ...
147
- def backslashEscape (s ) : ...
160
+ def registerBehavior (behavior , name : str | None = None , default : bool = False , id = None ) -> None : ...
161
+ def getBehavior (name : str , id = None ): ...
162
+ def newFromBehavior (name : str , id = None ) -> Component | ContentLine : ...
163
+ def backslashEscape (s : str ) -> str : ...
0 commit comments