Skip to content

Commit b5048a0

Browse files
AvasamAlexWaygood
andauthored
Add stubs for pyasn1 (#9437)
Co-authored-by: Alex Waygood <[email protected]>
1 parent b1cb9c8 commit b5048a0

39 files changed

+1529
-0
lines changed

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"stubs/pika",
5757
"stubs/psutil",
5858
"stubs/psycopg2",
59+
"stubs/pyasn1",
5960
"stubs/pyflakes",
6061
"stubs/Pygments",
6162
"stubs/PyMySQL",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Unintended re-exports
2+
pyasn1.compat.binary.version_info
3+
pyasn1.compat.octets.version_info
4+
pyasn1.compat.string.version_info
5+
6+
# type_check_only
7+
pyasn1.type.base.NoValue.plug
8+
9+
# typeshed typing differences with runtime collections.OrderedDict and builtins.dict
10+
pyasn1.codec.native.encoder.SequenceEncoder.protoDict
11+
pyasn1.codec.native.encoder.SetEncoder.protoDict
12+
13+
# Attempted "__ne__" operation on ASN.1 schema object
14+
pyasn1.type.base
15+
pyasn1.type.univ

stubs/pyasn1/METADATA.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version = "0.4.*"
2+
3+
[tool.stubtest]
4+
ignore_missing_stub = false

stubs/pyasn1/pyasn1/__init__.pyi

Whitespace-only changes.

stubs/pyasn1/pyasn1/codec/__init__.pyi

Whitespace-only changes.

stubs/pyasn1/pyasn1/codec/ber/__init__.pyi

Whitespace-only changes.
Lines changed: 337 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,337 @@
1+
from _typeshed import Incomplete
2+
from abc import ABCMeta, abstractmethod
3+
from collections.abc import Callable
4+
from typing_extensions import TypeAlias
5+
6+
from pyasn1.type import base, char, univ, useful
7+
from pyasn1.type.base import Asn1Type
8+
from pyasn1.type.tag import TagSet
9+
10+
_Unused: TypeAlias = object
11+
12+
class AbstractDecoder:
13+
protoComponent: Asn1Type | None
14+
@abstractmethod
15+
def valueDecoder(
16+
self,
17+
substrate,
18+
asn1Spec,
19+
tagSet: TagSet | None = ...,
20+
length: int | None = ...,
21+
state: Incomplete | None = ...,
22+
decodeFun: Callable[..., Incomplete] | None = ...,
23+
substrateFun: Callable[..., Incomplete] | None = ...,
24+
**options,
25+
) -> None: ...
26+
# Abstract, but implementation is optional
27+
def indefLenValueDecoder(
28+
self,
29+
substrate,
30+
asn1Spec,
31+
tagSet: TagSet | None = ...,
32+
length: int | None = ...,
33+
state: Incomplete | None = ...,
34+
decodeFun: Callable[..., Incomplete] | None = ...,
35+
substrateFun: Callable[..., Incomplete] | None = ...,
36+
**options,
37+
) -> None: ...
38+
39+
class AbstractSimpleDecoder(AbstractDecoder, metaclass=ABCMeta):
40+
@staticmethod
41+
def substrateCollector(asn1Object, substrate, length): ...
42+
43+
class ExplicitTagDecoder(AbstractSimpleDecoder):
44+
protoComponent: univ.Any
45+
def valueDecoder(
46+
self,
47+
substrate,
48+
asn1Spec,
49+
tagSet: TagSet | None = ...,
50+
length: int | None = ...,
51+
state: _Unused = ...,
52+
decodeFun: Callable[..., Incomplete] | None = ...,
53+
substrateFun: Callable[..., Incomplete] | None = ...,
54+
**options,
55+
): ...
56+
def indefLenValueDecoder(
57+
self,
58+
substrate,
59+
asn1Spec,
60+
tagSet: TagSet | None = ...,
61+
length: int | None = ...,
62+
state: _Unused = ...,
63+
decodeFun: Callable[..., Incomplete] | None = ...,
64+
substrateFun: Callable[..., Incomplete] | None = ...,
65+
**options,
66+
): ...
67+
68+
class IntegerDecoder(AbstractSimpleDecoder):
69+
protoComponent: univ.Integer
70+
def valueDecoder(
71+
self,
72+
substrate,
73+
asn1Spec,
74+
tagSet: TagSet | None = ...,
75+
length: int | None = ...,
76+
state: _Unused = ...,
77+
decodeFun: _Unused = ...,
78+
substrateFun: _Unused = ...,
79+
**options,
80+
): ...
81+
82+
class BooleanDecoder(IntegerDecoder):
83+
protoComponent: univ.Boolean
84+
85+
class BitStringDecoder(AbstractSimpleDecoder):
86+
protoComponent: univ.BitString
87+
supportConstructedForm: bool
88+
def valueDecoder(
89+
self,
90+
substrate,
91+
asn1Spec,
92+
tagSet: TagSet | None = ...,
93+
length: int | None = ...,
94+
state: _Unused = ...,
95+
decodeFun: Callable[..., Incomplete] | None = ...,
96+
substrateFun: Callable[..., Incomplete] | None = ...,
97+
**options,
98+
): ...
99+
def indefLenValueDecoder(
100+
self,
101+
substrate,
102+
asn1Spec,
103+
tagSet: TagSet | None = ...,
104+
length: int | None = ...,
105+
state: _Unused = ...,
106+
decodeFun: Callable[..., Incomplete] | None = ...,
107+
substrateFun: Callable[..., Incomplete] | None = ...,
108+
**options,
109+
): ...
110+
111+
class OctetStringDecoder(AbstractSimpleDecoder):
112+
protoComponent: univ.OctetString
113+
supportConstructedForm: bool
114+
def valueDecoder(
115+
self,
116+
substrate,
117+
asn1Spec,
118+
tagSet: TagSet | None = ...,
119+
length: int | None = ...,
120+
state: _Unused = ...,
121+
decodeFun: Callable[..., Incomplete] | None = ...,
122+
substrateFun: Callable[..., Incomplete] | None = ...,
123+
**options,
124+
): ...
125+
def indefLenValueDecoder(
126+
self,
127+
substrate,
128+
asn1Spec,
129+
tagSet: TagSet | None = ...,
130+
length: int | None = ...,
131+
state: _Unused = ...,
132+
decodeFun: Callable[..., Incomplete] | None = ...,
133+
substrateFun: Callable[..., Incomplete] | None = ...,
134+
**options,
135+
): ...
136+
137+
class NullDecoder(AbstractSimpleDecoder):
138+
protoComponent: univ.Null
139+
def valueDecoder(
140+
self,
141+
substrate,
142+
asn1Spec,
143+
tagSet: TagSet | None = ...,
144+
length: int | None = ...,
145+
state: _Unused = ...,
146+
decodeFun: _Unused = ...,
147+
substrateFun: _Unused = ...,
148+
**options,
149+
): ...
150+
151+
class ObjectIdentifierDecoder(AbstractSimpleDecoder):
152+
protoComponent: univ.ObjectIdentifier
153+
def valueDecoder(
154+
self,
155+
substrate,
156+
asn1Spec,
157+
tagSet: TagSet | None = ...,
158+
length: int | None = ...,
159+
state: _Unused = ...,
160+
decodeFun: _Unused = ...,
161+
substrateFun: _Unused = ...,
162+
**options,
163+
): ...
164+
165+
class RealDecoder(AbstractSimpleDecoder):
166+
protoComponent: univ.Real
167+
def valueDecoder(
168+
self,
169+
substrate,
170+
asn1Spec,
171+
tagSet: TagSet | None = ...,
172+
length: int | None = ...,
173+
state: _Unused = ...,
174+
decodeFun: _Unused = ...,
175+
substrateFun: _Unused = ...,
176+
**options,
177+
): ...
178+
179+
class AbstractConstructedDecoder(AbstractDecoder, metaclass=ABCMeta):
180+
protoComponent: base.ConstructedAsn1Type | None
181+
182+
class UniversalConstructedTypeDecoder(AbstractConstructedDecoder):
183+
protoRecordComponent: univ.SequenceAndSetBase | None
184+
protoSequenceComponent: univ.SequenceOfAndSetOfBase | None
185+
def valueDecoder(
186+
self,
187+
substrate,
188+
asn1Spec,
189+
tagSet: TagSet | None = ...,
190+
length: int | None = ...,
191+
state: _Unused = ...,
192+
decodeFun: Callable[..., Incomplete] | None = ...,
193+
substrateFun: Callable[..., Incomplete] | None = ...,
194+
**options,
195+
): ...
196+
def indefLenValueDecoder(
197+
self,
198+
substrate,
199+
asn1Spec,
200+
tagSet: TagSet | None = ...,
201+
length: int | None = ...,
202+
state: _Unused = ...,
203+
decodeFun: Callable[..., Incomplete] | None = ...,
204+
substrateFun: Callable[..., Incomplete] | None = ...,
205+
**options,
206+
): ...
207+
208+
class SequenceOrSequenceOfDecoder(UniversalConstructedTypeDecoder):
209+
protoRecordComponent: univ.Sequence
210+
protoSequenceComponent: univ.SequenceOf
211+
212+
class SequenceDecoder(SequenceOrSequenceOfDecoder):
213+
protoComponent: univ.Sequence
214+
215+
class SequenceOfDecoder(SequenceOrSequenceOfDecoder):
216+
protoComponent: univ.SequenceOf
217+
218+
class SetOrSetOfDecoder(UniversalConstructedTypeDecoder):
219+
protoRecordComponent: univ.Set
220+
protoSequenceComponent: univ.SetOf
221+
222+
class SetDecoder(SetOrSetOfDecoder):
223+
protoComponent: univ.Set
224+
225+
class SetOfDecoder(SetOrSetOfDecoder):
226+
protoComponent: univ.SetOf
227+
228+
class ChoiceDecoder(AbstractConstructedDecoder):
229+
protoComponent: univ.Choice
230+
def valueDecoder(
231+
self,
232+
substrate,
233+
asn1Spec,
234+
tagSet: TagSet | None = ...,
235+
length: int | None = ...,
236+
state: Incomplete | None = ...,
237+
decodeFun: Callable[..., Incomplete] | None = ...,
238+
substrateFun: Callable[..., Incomplete] | None = ...,
239+
**options,
240+
): ...
241+
def indefLenValueDecoder(
242+
self,
243+
substrate,
244+
asn1Spec,
245+
tagSet: TagSet | None = ...,
246+
length: int | None = ...,
247+
state: Incomplete | None = ...,
248+
decodeFun: Callable[..., Incomplete] | None = ...,
249+
substrateFun: Callable[..., Incomplete] | None = ...,
250+
**options,
251+
): ...
252+
253+
class AnyDecoder(AbstractSimpleDecoder):
254+
protoComponent: univ.Any
255+
def valueDecoder(
256+
self,
257+
substrate,
258+
asn1Spec,
259+
tagSet: TagSet | None = ...,
260+
length: int | None = ...,
261+
state: _Unused = ...,
262+
decodeFun: _Unused = ...,
263+
substrateFun: Callable[..., Incomplete] | None = ...,
264+
**options,
265+
): ...
266+
def indefLenValueDecoder(
267+
self,
268+
substrate,
269+
asn1Spec,
270+
tagSet: TagSet | None = ...,
271+
length: int | None = ...,
272+
state: _Unused = ...,
273+
decodeFun: Callable[..., Incomplete] | None = ...,
274+
substrateFun: Callable[..., Incomplete] | None = ...,
275+
**options,
276+
): ...
277+
278+
class UTF8StringDecoder(OctetStringDecoder):
279+
protoComponent: char.UTF8String
280+
281+
class NumericStringDecoder(OctetStringDecoder):
282+
protoComponent: char.NumericString
283+
284+
class PrintableStringDecoder(OctetStringDecoder):
285+
protoComponent: char.PrintableString
286+
287+
class TeletexStringDecoder(OctetStringDecoder):
288+
protoComponent: char.TeletexString
289+
290+
class VideotexStringDecoder(OctetStringDecoder):
291+
protoComponent: char.VideotexString
292+
293+
class IA5StringDecoder(OctetStringDecoder):
294+
protoComponent: char.IA5String
295+
296+
class GraphicStringDecoder(OctetStringDecoder):
297+
protoComponent: char.GraphicString
298+
299+
class VisibleStringDecoder(OctetStringDecoder):
300+
protoComponent: char.VisibleString
301+
302+
class GeneralStringDecoder(OctetStringDecoder):
303+
protoComponent: char.GeneralString
304+
305+
class UniversalStringDecoder(OctetStringDecoder):
306+
protoComponent: char.UniversalString
307+
308+
class BMPStringDecoder(OctetStringDecoder):
309+
protoComponent: char.BMPString
310+
311+
class ObjectDescriptorDecoder(OctetStringDecoder):
312+
protoComponent: useful.ObjectDescriptor
313+
314+
class GeneralizedTimeDecoder(OctetStringDecoder):
315+
protoComponent: useful.GeneralizedTime
316+
317+
class UTCTimeDecoder(OctetStringDecoder):
318+
protoComponent: useful.UTCTime
319+
320+
class Decoder:
321+
defaultErrorState: int
322+
defaultRawDecoder: AnyDecoder
323+
supportIndefLength: bool
324+
def __init__(self, tagMap, typeMap=...) -> None: ...
325+
def __call__(
326+
self,
327+
substrate,
328+
asn1Spec: Asn1Type | None = ...,
329+
tagSet: TagSet | None = ...,
330+
length: int | None = ...,
331+
state=...,
332+
decodeFun: _Unused = ...,
333+
substrateFun: Callable[..., Incomplete] | None = ...,
334+
**options,
335+
): ...
336+
337+
decode: Decoder

0 commit comments

Comments
 (0)