Add stubs for pyasn1 (#9437)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Avasam
2023-01-06 13:25:48 -05:00
committed by GitHub
parent b1cb9c8a8f
commit b5048a00e6
39 changed files with 1529 additions and 0 deletions

View File

@@ -56,6 +56,7 @@
"stubs/pika",
"stubs/psutil",
"stubs/psycopg2",
"stubs/pyasn1",
"stubs/pyflakes",
"stubs/Pygments",
"stubs/PyMySQL",

View File

@@ -0,0 +1,15 @@
# Unintended re-exports
pyasn1.compat.binary.version_info
pyasn1.compat.octets.version_info
pyasn1.compat.string.version_info
# type_check_only
pyasn1.type.base.NoValue.plug
# typeshed typing differences with runtime collections.OrderedDict and builtins.dict
pyasn1.codec.native.encoder.SequenceEncoder.protoDict
pyasn1.codec.native.encoder.SetEncoder.protoDict
# Attempted "__ne__" operation on ASN.1 schema object
pyasn1.type.base
pyasn1.type.univ

View File

@@ -0,0 +1,4 @@
version = "0.4.*"
[tool.stubtest]
ignore_missing_stub = false

View File

View File

View File

@@ -0,0 +1,337 @@
from _typeshed import Incomplete
from abc import ABCMeta, abstractmethod
from collections.abc import Callable
from typing_extensions import TypeAlias
from pyasn1.type import base, char, univ, useful
from pyasn1.type.base import Asn1Type
from pyasn1.type.tag import TagSet
_Unused: TypeAlias = object
class AbstractDecoder:
protoComponent: Asn1Type | None
@abstractmethod
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: Incomplete | None = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
) -> None: ...
# Abstract, but implementation is optional
def indefLenValueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: Incomplete | None = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
) -> None: ...
class AbstractSimpleDecoder(AbstractDecoder, metaclass=ABCMeta):
@staticmethod
def substrateCollector(asn1Object, substrate, length): ...
class ExplicitTagDecoder(AbstractSimpleDecoder):
protoComponent: univ.Any
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
def indefLenValueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
class IntegerDecoder(AbstractSimpleDecoder):
protoComponent: univ.Integer
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: _Unused = ...,
substrateFun: _Unused = ...,
**options,
): ...
class BooleanDecoder(IntegerDecoder):
protoComponent: univ.Boolean
class BitStringDecoder(AbstractSimpleDecoder):
protoComponent: univ.BitString
supportConstructedForm: bool
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
def indefLenValueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
class OctetStringDecoder(AbstractSimpleDecoder):
protoComponent: univ.OctetString
supportConstructedForm: bool
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
def indefLenValueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
class NullDecoder(AbstractSimpleDecoder):
protoComponent: univ.Null
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: _Unused = ...,
substrateFun: _Unused = ...,
**options,
): ...
class ObjectIdentifierDecoder(AbstractSimpleDecoder):
protoComponent: univ.ObjectIdentifier
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: _Unused = ...,
substrateFun: _Unused = ...,
**options,
): ...
class RealDecoder(AbstractSimpleDecoder):
protoComponent: univ.Real
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: _Unused = ...,
substrateFun: _Unused = ...,
**options,
): ...
class AbstractConstructedDecoder(AbstractDecoder, metaclass=ABCMeta):
protoComponent: base.ConstructedAsn1Type | None
class UniversalConstructedTypeDecoder(AbstractConstructedDecoder):
protoRecordComponent: univ.SequenceAndSetBase | None
protoSequenceComponent: univ.SequenceOfAndSetOfBase | None
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
def indefLenValueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
class SequenceOrSequenceOfDecoder(UniversalConstructedTypeDecoder):
protoRecordComponent: univ.Sequence
protoSequenceComponent: univ.SequenceOf
class SequenceDecoder(SequenceOrSequenceOfDecoder):
protoComponent: univ.Sequence
class SequenceOfDecoder(SequenceOrSequenceOfDecoder):
protoComponent: univ.SequenceOf
class SetOrSetOfDecoder(UniversalConstructedTypeDecoder):
protoRecordComponent: univ.Set
protoSequenceComponent: univ.SetOf
class SetDecoder(SetOrSetOfDecoder):
protoComponent: univ.Set
class SetOfDecoder(SetOrSetOfDecoder):
protoComponent: univ.SetOf
class ChoiceDecoder(AbstractConstructedDecoder):
protoComponent: univ.Choice
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: Incomplete | None = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
def indefLenValueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: Incomplete | None = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
class AnyDecoder(AbstractSimpleDecoder):
protoComponent: univ.Any
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: _Unused = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
def indefLenValueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: Callable[..., Incomplete] | None = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
class UTF8StringDecoder(OctetStringDecoder):
protoComponent: char.UTF8String
class NumericStringDecoder(OctetStringDecoder):
protoComponent: char.NumericString
class PrintableStringDecoder(OctetStringDecoder):
protoComponent: char.PrintableString
class TeletexStringDecoder(OctetStringDecoder):
protoComponent: char.TeletexString
class VideotexStringDecoder(OctetStringDecoder):
protoComponent: char.VideotexString
class IA5StringDecoder(OctetStringDecoder):
protoComponent: char.IA5String
class GraphicStringDecoder(OctetStringDecoder):
protoComponent: char.GraphicString
class VisibleStringDecoder(OctetStringDecoder):
protoComponent: char.VisibleString
class GeneralStringDecoder(OctetStringDecoder):
protoComponent: char.GeneralString
class UniversalStringDecoder(OctetStringDecoder):
protoComponent: char.UniversalString
class BMPStringDecoder(OctetStringDecoder):
protoComponent: char.BMPString
class ObjectDescriptorDecoder(OctetStringDecoder):
protoComponent: useful.ObjectDescriptor
class GeneralizedTimeDecoder(OctetStringDecoder):
protoComponent: useful.GeneralizedTime
class UTCTimeDecoder(OctetStringDecoder):
protoComponent: useful.UTCTime
class Decoder:
defaultErrorState: int
defaultRawDecoder: AnyDecoder
supportIndefLength: bool
def __init__(self, tagMap, typeMap=...) -> None: ...
def __call__(
self,
substrate,
asn1Spec: Asn1Type | None = ...,
tagSet: TagSet | None = ...,
length: int | None = ...,
state=...,
decodeFun: _Unused = ...,
substrateFun: Callable[..., Incomplete] | None = ...,
**options,
): ...
decode: Decoder

View File

@@ -0,0 +1,67 @@
from _typeshed import Incomplete
from abc import abstractmethod
from pyasn1.type.base import Asn1Type
class AbstractItemEncoder:
supportIndefLenMode: bool
eooIntegerSubstrate: tuple[int, int]
eooOctetsSubstrate: bytes
def encodeTag(self, singleTag, isConstructed): ...
def encodeLength(self, length, defMode): ...
@abstractmethod
def encodeValue(self, value, asn1Spec, encodeFun, **options) -> None: ...
def encode(self, value, asn1Spec: Asn1Type | None = ..., encodeFun: Incomplete | None = ..., **options): ...
class EndOfOctetsEncoder(AbstractItemEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class BooleanEncoder(AbstractItemEncoder):
supportIndefLenMode: bool
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class IntegerEncoder(AbstractItemEncoder):
supportIndefLenMode: bool
supportCompactZero: bool
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class BitStringEncoder(AbstractItemEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class OctetStringEncoder(AbstractItemEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class NullEncoder(AbstractItemEncoder):
supportIndefLenMode: bool
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class ObjectIdentifierEncoder(AbstractItemEncoder):
supportIndefLenMode: bool
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class RealEncoder(AbstractItemEncoder):
# Mistake in the module, should be False, but is 0 at runtime
supportIndefLenMode: int # type: ignore[assignment]
binEncBase: int
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class SequenceEncoder(AbstractItemEncoder):
omitEmptyOptionals: bool
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class SequenceOfEncoder(AbstractItemEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class ChoiceEncoder(AbstractItemEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class AnyEncoder(OctetStringEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class Encoder:
fixedDefLengthMode: bool | None
fixedChunkSize: int | None
def __init__(self, tagMap, typeMap=...) -> None: ...
def __call__(self, value, asn1Spec: Asn1Type | None = ..., **options): ...
encode: Encoder

View File

@@ -0,0 +1,9 @@
from pyasn1.type import base
from pyasn1.type.tag import TagSet
class EndOfOctets(base.SimpleAsn1Type):
defaultValue: int
tagSet: TagSet
def __new__(cls, *args, **kwargs): ...
endOfOctets: EndOfOctets

View File

@@ -0,0 +1,29 @@
from typing_extensions import TypeAlias
from pyasn1.codec.ber import decoder
from pyasn1.type import univ
from pyasn1.type.tag import TagSet
_Unused: TypeAlias = object
class BooleanDecoder(decoder.AbstractSimpleDecoder):
protoComponent: univ.Boolean
def valueDecoder(
self,
substrate,
asn1Spec,
tagSet: TagSet | None = ...,
length: int | None = ...,
state: _Unused = ...,
decodeFun: _Unused = ...,
substrateFun: _Unused = ...,
**options,
): ...
BitStringDecoder = decoder.BitStringDecoder
OctetStringDecoder = decoder.OctetStringDecoder
RealDecoder = decoder.RealDecoder
class Decoder(decoder.Decoder): ...
decode: Decoder

View File

@@ -0,0 +1,40 @@
from typing import ClassVar
from pyasn1.codec.ber import encoder
class BooleanEncoder(encoder.IntegerEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class RealEncoder(encoder.RealEncoder): ...
class TimeEncoderMixIn:
Z_CHAR: ClassVar[int]
PLUS_CHAR: ClassVar[int]
MINUS_CHAR: ClassVar[int]
COMMA_CHAR: ClassVar[int]
DOT_CHAR: ClassVar[int]
ZERO_CHAR: ClassVar[int]
MIN_LENGTH: ClassVar[int]
MAX_LENGTH: ClassVar[int]
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class GeneralizedTimeEncoder(TimeEncoderMixIn, encoder.OctetStringEncoder): ...
class UTCTimeEncoder(TimeEncoderMixIn, encoder.OctetStringEncoder): ...
class SetOfEncoder(encoder.SequenceOfEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class SequenceOfEncoder(encoder.SequenceOfEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class SetEncoder(encoder.SequenceEncoder):
def encodeValue(self, value, asn1Spec, encodeFun, **options): ...
class SequenceEncoder(encoder.SequenceEncoder):
omitEmptyOptionals: bool
class Encoder(encoder.Encoder):
fixedDefLengthMode: bool
fixedChunkSize: int
encode: Encoder

View File

@@ -0,0 +1,12 @@
from pyasn1.codec.cer import decoder
class BitStringDecoder(decoder.BitStringDecoder):
supportConstructedForm: bool
class OctetStringDecoder(decoder.OctetStringDecoder):
supportConstructedForm: bool
class Decoder(decoder.Decoder):
supportIndefLength: bool
decode: Decoder

View File

@@ -0,0 +1,9 @@
from pyasn1.codec.cer import encoder
class SetEncoder(encoder.SetEncoder): ...
class Encoder(encoder.Encoder):
fixedDefLengthMode: bool
fixedChunkSize: int
encode: Encoder

View File

@@ -0,0 +1,26 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing_extensions import TypeAlias
_Unused: TypeAlias = object
class AbstractScalarDecoder:
def __call__(self, pyObject, asn1Spec, decodeFun: _Unused = ..., **options): ...
class BitStringDecoder(AbstractScalarDecoder):
def __call__(self, pyObject, asn1Spec, decodeFun: _Unused = ..., **options): ...
class SequenceOrSetDecoder:
def __call__(self, pyObject, asn1Spec, decodeFun: Callable[..., Incomplete] | None = ..., **options): ...
class SequenceOfOrSetOfDecoder:
def __call__(self, pyObject, asn1Spec, decodeFun: Callable[..., Incomplete] | None = ..., **options): ...
class ChoiceDecoder:
def __call__(self, pyObject, asn1Spec, decodeFun: Callable[..., Incomplete] | None = ..., **options): ...
class Decoder:
def __init__(self, tagMap, typeMap) -> None: ...
def __call__(self, pyObject, asn1Spec, **options): ...
decode: Decoder

View File

@@ -0,0 +1,51 @@
from abc import abstractmethod
from collections import OrderedDict
class AbstractItemEncoder:
@abstractmethod
def encode(self, value, encodeFun, **options) -> None: ...
class BooleanEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class IntegerEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class BitStringEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class OctetStringEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class TextStringEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class NullEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options) -> None: ...
class ObjectIdentifierEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class RealEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class SetEncoder(AbstractItemEncoder):
protoDict = dict
def encode(self, value, encodeFun, **options): ...
class SequenceEncoder(SetEncoder):
protoDict = OrderedDict
class SequenceOfEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class ChoiceEncoder(SequenceEncoder): ...
class AnyEncoder(AbstractItemEncoder):
def encode(self, value, encodeFun, **options): ...
class Encoder:
def __init__(self, tagMap, typeMap=...) -> None: ...
def __call__(self, value, **options): ...
encode: Encoder

View File

View File

@@ -0,0 +1 @@
from builtins import bin as bin

View File

@@ -0,0 +1 @@
from builtins import callable as callable

View File

@@ -0,0 +1,3 @@
from datetime import datetime
strptime = datetime.strptime

View File

@@ -0,0 +1,8 @@
from typing_extensions import Literal
implementation: str
null: Literal[b""]
def from_bytes(octets, signed: bool = ...): ...
def to_bytes(value, signed: bool = ..., length: int = ...): ...
def bitLength(number): ...

View File

@@ -0,0 +1,19 @@
from typing import TypeVar
from typing_extensions import Literal
_T = TypeVar("_T")
ints2octs = bytes
def int2oct(x) -> bytes: ...
null: Literal[b""]
def oct2int(x: _T) -> _T: ...
def octs2ints(x: _T) -> _T: ...
def str2octs(x: str) -> bytes: ...
def octs2str(x: bytes) -> str: ...
def isOctetsType(s: object) -> bool: ...
def isStringType(s: object) -> bool: ...
ensureString = bytes

View File

@@ -0,0 +1,2 @@
# Same as string.partition(sep)
def partition(string: str, sep: str) -> tuple[str, str, str]: ...

View File

@@ -0,0 +1,28 @@
import logging
from typing import TextIO
class Printer:
def __init__(
self,
logger: logging.Logger | None = ...,
handler: logging.StreamHandler[TextIO] | None = ...,
formatter: logging.Formatter | None = ...,
) -> None: ...
def __call__(self, msg) -> None: ...
NullHandler = logging.NullHandler
class Debug:
defaultPrinter: Printer
def __init__(self, *flags, **options) -> None: ...
def __call__(self, msg) -> None: ...
def __and__(self, flag): ...
def __rand__(self, flag): ...
def setLogger(userLogger) -> None: ...
def hexdump(octets): ...
class Scope:
def __init__(self) -> None: ...
def push(self, token) -> None: ...
def pop(self): ...

View File

@@ -0,0 +1,9 @@
class PyAsn1Error(Exception): ...
class ValueConstraintError(PyAsn1Error): ...
class SubstrateUnderrunError(PyAsn1Error): ...
class PyAsn1UnicodeError(PyAsn1Error, UnicodeError):
def __init__(self, message, unicode_error: UnicodeError | None = ...) -> None: ...
class PyAsn1UnicodeDecodeError(PyAsn1UnicodeError, UnicodeDecodeError): ...
class PyAsn1UnicodeEncodeError(PyAsn1UnicodeError, UnicodeEncodeError): ...

View File

View File

@@ -0,0 +1,149 @@
from _typeshed import Incomplete
from typing import type_check_only
from typing_extensions import final
from pyasn1.type import constraint, namedtype
from pyasn1.type.tag import TagSet
class Asn1Item:
@classmethod
def getTypeId(cls, increment: int = ...): ...
class Asn1Type(Asn1Item):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
typeId: int | None
def __init__(self, **kwargs) -> None: ...
def __setattr__(self, name, value) -> None: ...
@property
def readOnly(self): ...
@property
def effectiveTagSet(self): ...
@property
def tagMap(self): ...
def isSameTypeWith(self, other, matchTags: bool = ..., matchConstraints: bool = ...): ...
def isSuperTypeOf(self, other, matchTags: bool = ..., matchConstraints: bool = ...): ...
@staticmethod
def isNoValue(*values): ...
def prettyPrint(self, scope: int = ...) -> None: ...
def getTagSet(self): ...
def getEffectiveTagSet(self): ...
def getTagMap(self): ...
def getSubtypeSpec(self): ...
def hasValue(self): ...
Asn1ItemBase = Asn1Type
@final
class NoValue:
skipMethods: set[str]
def __new__(cls): ...
def __getattr__(self, attr) -> None: ...
# def __new__.<locals>.getPlug.<locals>.plug
@type_check_only
def plug(self, *args: object, **kw: object): ...
# Magic methods assigned dynamically, priority from right to left: plug < str < int < list < dict
__abs__ = int.__abs__
__add__ = list.__add__
__and__ = int.__and__
__bool__ = int.__bool__
__ceil__ = int.__ceil__
__class_getitem__ = plug
__contains__ = dict.__contains__
__delitem__ = dict.__delitem__
__dir__ = plug
__divmod__ = int.__divmod__
__float__ = int.__float__
__floor__ = int.__floor__
__floordiv__ = int.__floordiv__
__ge__ = list.__ge__
__getitem__ = dict.__getitem__
__gt__ = list.__gt__
__iadd__ = list.__iadd__
__imul__ = list.__imul__
__index__ = int.__index__
# self instead of cls
__init_subclass__ = plug # pyright: ignore[reportGeneralTypeIssues]
__int__ = int.__int__
__invert__ = int.__invert__
__ior__ = plug
__iter__ = dict.__iter__
__le__ = list.__le__
__len__ = dict.__len__
__lshift__ = int.__lshift__
__lt__ = list.__lt__
__mod__ = int.__mod__
__mul__ = list.__mul__
__neg__ = int.__neg__
__or__ = int.__or__
__pos__ = int.__pos__
__pow__ = int.__pow__
__radd__ = int.__radd__
__rand__ = int.__rand__
__rdivmod__ = int.__rdivmod__
__reversed__ = list.__reversed__
__rfloordiv__ = int.__rfloordiv__
__rlshift__ = int.__rlshift__
__rmod__ = int.__rmod__
__rmul__ = list.__rmul__
__ror__ = int.__ror__
__round__ = int.__round__
__rpow__ = int.__rpow__
__rrshift__ = int.__rrshift__
__rshift__ = int.__rshift__
__rsub__ = int.__rsub__
__rtruediv__ = int.__rtruediv__
__rxor__ = int.__rxor__
__setitem__ = list.__setitem__
__str__ = plug
__sub__ = int.__sub__
__truediv__ = int.__truediv__
__trunc__ = int.__trunc__
__xor__ = int.__xor__
class SimpleAsn1Type(Asn1Type):
defaultValue: Incomplete | NoValue
def __init__(self, value=..., **kwargs) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __bool__(self) -> bool: ...
def __hash__(self): ...
@property
def isValue(self): ...
def clone(self, value=..., **kwargs): ...
def subtype(self, value=..., **kwargs): ...
def prettyIn(self, value): ...
def prettyOut(self, value): ...
def prettyPrint(self, scope: int = ...): ...
def prettyPrintType(self, scope: int = ...): ...
AbstractSimpleAsn1Item = SimpleAsn1Type
class ConstructedAsn1Type(Asn1Type):
strictConstraints: bool
componentType: namedtype.NamedTypes | None
sizeSpec: constraint.ConstraintsIntersection
def __init__(self, **kwargs) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __bool__(self) -> bool: ...
@property
def components(self) -> None: ...
def clone(self, **kwargs): ...
def subtype(self, **kwargs): ...
def getComponentByPosition(self, idx) -> None: ...
def setComponentByPosition(self, idx, value, verifyConstraints: bool = ...) -> None: ...
def setComponents(self, *args, **kwargs): ...
def setDefaultComponents(self) -> None: ...
def getComponentType(self): ...
def verifySizeSpec(self) -> None: ...
AbstractConstructedAsn1Item = ConstructedAsn1Type

View File

@@ -0,0 +1,72 @@
from pyasn1.type import univ
from pyasn1.type.tag import TagSet
class AbstractCharacterString(univ.OctetString):
def __bytes__(self) -> bytes: ...
def prettyIn(self, value): ...
def asOctets(self, padding: bool = ...): ...
def asNumbers(self, padding: bool = ...): ...
def prettyOut(self, value): ...
def prettyPrint(self, scope: int = ...): ...
def __reversed__(self): ...
class NumericString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class PrintableString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class TeletexString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class T61String(TeletexString):
typeId: int
class VideotexString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class IA5String(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class GraphicString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class VisibleString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class ISO646String(VisibleString):
typeId: int
class GeneralString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class UniversalString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class BMPString(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int
class UTF8String(AbstractCharacterString):
tagSet: TagSet
encoding: str
typeId: int

View File

@@ -0,0 +1,40 @@
class AbstractConstraint:
def __init__(self, *values) -> None: ...
def __call__(self, value, idx: int | None = ...) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __bool__(self) -> bool: ...
def __hash__(self): ...
def getValueMap(self): ...
def isSuperTypeOf(self, otherConstraint): ...
def isSubTypeOf(self, otherConstraint): ...
class SingleValueConstraint(AbstractConstraint):
def __contains__(self, item) -> bool: ...
def __iter__(self): ...
def __add__(self, constraint): ...
def __sub__(self, constraint): ...
class ContainedSubtypeConstraint(AbstractConstraint): ...
class ValueRangeConstraint(AbstractConstraint): ...
class ValueSizeConstraint(ValueRangeConstraint): ...
class PermittedAlphabetConstraint(SingleValueConstraint): ...
class ComponentPresentConstraint(AbstractConstraint): ...
class ComponentAbsentConstraint(AbstractConstraint): ...
class WithComponentsConstraint(AbstractConstraint): ...
class InnerTypeConstraint(AbstractConstraint): ...
class ConstraintsExclusion(AbstractConstraint): ...
class AbstractConstraintSet(AbstractConstraint):
def __getitem__(self, idx): ...
def __iter__(self): ...
def __add__(self, value): ...
def __radd__(self, value): ...
def __len__(self) -> int: ...
class ConstraintsIntersection(AbstractConstraintSet): ...
class ConstraintsUnion(AbstractConstraintSet): ...

View File

@@ -0,0 +1,3 @@
from pyasn1.error import PyAsn1Error
class ValueConstraintError(PyAsn1Error): ...

View File

@@ -0,0 +1,71 @@
class NamedType:
isOptional: bool
isDefaulted: bool
def __init__(self, name, asn1Object, openType: type | None = ...) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __hash__(self): ...
def __getitem__(self, idx): ...
def __iter__(self): ...
@property
def name(self): ...
@property
def asn1Object(self): ...
@property
def openType(self): ...
def getName(self): ...
def getType(self): ...
class OptionalNamedType(NamedType):
isOptional: bool
class DefaultedNamedType(NamedType):
isDefaulted: bool
class NamedTypes:
def __init__(self, *namedTypes, **kwargs) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __hash__(self): ...
def __getitem__(self, idx): ...
def __contains__(self, key) -> bool: ...
def __iter__(self): ...
def __bool__(self) -> bool: ...
def __len__(self) -> int: ...
def values(self): ...
def keys(self): ...
def items(self): ...
def clone(self): ...
class PostponedError:
def __init__(self, errorMsg) -> None: ...
def __getitem__(self, item) -> None: ...
def getTypeByPosition(self, idx): ...
def getPositionByType(self, tagSet): ...
def getNameByPosition(self, idx): ...
def getPositionByName(self, name): ...
def getTagMapNearPosition(self, idx): ...
def getPositionNearType(self, tagSet, idx): ...
@property
def minTagSet(self): ...
@property
def tagMap(self): ...
@property
def tagMapUnique(self): ...
@property
def hasOptionalOrDefault(self): ...
@property
def hasOpenTypes(self): ...
@property
def namedTypes(self): ...
@property
def requiredComponents(self): ...

View File

@@ -0,0 +1,24 @@
from _typeshed import Incomplete
from collections.abc import Generator
class NamedValues:
def __init__(self, *args, **kwargs) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __hash__(self): ...
def __getitem__(self, key): ...
def __len__(self) -> int: ...
def __contains__(self, key) -> bool: ...
def __iter__(self): ...
def values(self): ...
def keys(self): ...
def items(self) -> Generator[Incomplete, None, None]: ...
def __add__(self, namedValues): ...
def clone(self, *args, **kwargs): ...
def getName(self, value): ...
def getValue(self, name): ...
def getValues(self, *names): ...

View File

@@ -0,0 +1,15 @@
from _typeshed import Incomplete
from collections.abc import Mapping
from pyasn1.type.base import Asn1Type
class OpenType:
def __init__(self, name, typeMap: Mapping[Incomplete, Asn1Type] | None = ...) -> None: ...
@property
def name(self): ...
def values(self): ...
def keys(self): ...
def items(self): ...
def __contains__(self, key) -> bool: ...
def __getitem__(self, key): ...
def __iter__(self): ...

View File

@@ -0,0 +1,51 @@
tagClassUniversal: int
tagClassApplication: int
tagClassContext: int
tagClassPrivate: int
tagFormatSimple: int
tagFormatConstructed: int
tagCategoryImplicit: int
tagCategoryExplicit: int
tagCategoryUntagged: int
class Tag:
def __init__(self, tagClass, tagFormat, tagId) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __hash__(self): ...
def __getitem__(self, idx): ...
def __iter__(self): ...
def __and__(self, otherTag): ...
def __or__(self, otherTag): ...
@property
def tagClass(self): ...
@property
def tagFormat(self): ...
@property
def tagId(self): ...
class TagSet:
def __init__(self, baseTag=..., *superTags) -> None: ...
def __add__(self, superTag): ...
def __radd__(self, superTag): ...
def __getitem__(self, i): ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __hash__(self): ...
def __len__(self) -> int: ...
@property
def baseTag(self): ...
@property
def superTags(self): ...
def tagExplicitly(self, superTag): ...
def tagImplicitly(self, superTag): ...
def isSuperTagSetOf(self, tagSet): ...
def getBaseTag(self): ...

View File

@@ -0,0 +1,23 @@
from collections.abc import Container, Mapping
from pyasn1.type.base import Asn1Type
class TagMap:
def __init__(
self,
presentTypes: Mapping[TagMap, Asn1Type] | None = ...,
skipTypes: Container[TagMap] | None = ...,
defaultType: Asn1Type | None = ...,
) -> None: ...
def __contains__(self, tagSet) -> bool: ...
def __getitem__(self, tagSet): ...
def __iter__(self): ...
@property
def presentTypes(self): ...
@property
def skipTypes(self): ...
@property
def defaultType(self): ...
def getPosMap(self): ...
def getNegMap(self): ...
def getDef(self): ...

View File

@@ -0,0 +1,382 @@
from _typeshed import Incomplete, ReadableBuffer, Self, SupportsRichComparison, SupportsTrunc
from collections.abc import Callable, Generator
from typing import SupportsInt
from typing_extensions import SupportsIndex, TypeAlias
from pyasn1.type import base, constraint, namedtype, namedval
from pyasn1.type.tag import TagSet
_SizedIntegerable: TypeAlias = ReadableBuffer | str | SupportsInt | SupportsIndex | SupportsTrunc
NoValue = base.NoValue
noValue: NoValue
class Integer(base.SimpleAsn1Type):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
namedValues: namedval.NamedValues
typeId: int
def __init__(self, value=..., **kwargs) -> None: ...
def __and__(self, value): ...
def __rand__(self, value): ...
def __or__(self, value): ...
def __ror__(self, value): ...
def __xor__(self, value): ...
def __rxor__(self, value): ...
def __lshift__(self, value): ...
def __rshift__(self, value): ...
def __add__(self, value): ...
def __radd__(self, value): ...
def __sub__(self, value): ...
def __rsub__(self, value): ...
def __mul__(self, value): ...
def __rmul__(self, value): ...
def __mod__(self, value): ...
def __rmod__(self, value): ...
# Accepts everything builtins.pow does
def __pow__(self: Self, value: complex, modulo: int | None = ...) -> Self: ...
def __rpow__(self, value): ...
def __floordiv__(self, value): ...
def __rfloordiv__(self, value): ...
def __truediv__(self, value): ...
def __rtruediv__(self, value): ...
def __divmod__(self, value): ...
def __rdivmod__(self, value): ...
__hash__ = base.SimpleAsn1Type.__hash__
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __abs__(self): ...
def __index__(self) -> int: ...
def __pos__(self): ...
def __neg__(self): ...
def __invert__(self): ...
def __round__(self, n: int = ...): ...
def __floor__(self): ...
def __ceil__(self): ...
def __trunc__(self): ...
def __lt__(self, value): ...
def __le__(self, value): ...
def __eq__(self, value): ...
def __ne__(self, value): ...
def __gt__(self, value): ...
def __ge__(self, value): ...
def prettyIn(self, value): ...
def prettyOut(self, value): ...
def getNamedValues(self): ...
class Boolean(Integer):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
namedValues: namedval.NamedValues
typeId: int
SizedIntegerBase = int
class SizedInteger(SizedIntegerBase):
bitLength: int | None
leadingZeroBits: int | None
def setBitLength(self, bitLength): ...
def __len__(self) -> int: ...
class BitString(base.SimpleAsn1Type):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
namedValues: namedval.NamedValues
typeId: int
defaultBinValue: str | base.NoValue
defaultHexValue: str | base.NoValue
def __init__(self, value=..., **kwargs) -> None: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __len__(self) -> int: ...
def __getitem__(self, i): ...
def __iter__(self): ...
def __reversed__(self): ...
def __add__(self, value): ...
def __radd__(self, value): ...
def __mul__(self, value): ...
def __rmul__(self, value): ...
def __lshift__(self, count): ...
def __rshift__(self, count): ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def asNumbers(self): ...
def asOctets(self): ...
def asInteger(self): ...
def asBinary(self): ...
@classmethod
def fromHexString(cls, value, internalFormat: bool = ..., prepend: _SizedIntegerable | None = ...): ...
@classmethod
def fromBinaryString(cls, value, internalFormat: bool = ..., prepend: _SizedIntegerable | None = ...): ...
@classmethod
def fromOctetString(cls, value, internalFormat: bool = ..., prepend: _SizedIntegerable | None = ..., padding: int = ...): ...
def prettyIn(self, value): ...
class OctetString(base.SimpleAsn1Type):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
defaultBinValue: str | base.NoValue
defaultHexValue: str | base.NoValue
encoding: str
def __init__(self, value=..., **kwargs) -> None: ...
def prettyIn(self, value): ...
def __bytes__(self) -> bytes: ...
def asOctets(self): ...
def asNumbers(self): ...
def prettyOut(self, value): ...
def prettyPrint(self, scope: int = ...): ...
@staticmethod
def fromBinaryString(value): ...
@staticmethod
def fromHexString(value): ...
def __len__(self) -> int: ...
def __getitem__(self, i): ...
def __iter__(self): ...
def __contains__(self, value) -> bool: ...
def __add__(self, value): ...
def __radd__(self, value): ...
def __mul__(self, value): ...
def __rmul__(self, value): ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __reversed__(self): ...
class Null(OctetString):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
def prettyIn(self, value): ...
class ObjectIdentifier(base.SimpleAsn1Type):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
def __add__(self, other): ...
def __radd__(self, other): ...
def asTuple(self): ...
def __len__(self) -> int: ...
def __getitem__(self, i): ...
def __iter__(self): ...
def __contains__(self, value) -> bool: ...
def index(self, suboid): ...
def isPrefixOf(self, other): ...
def prettyIn(self, value): ...
def prettyOut(self, value): ...
class Real(base.SimpleAsn1Type):
binEncBase: int | None
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
def prettyIn(self, value): ...
def prettyPrint(self, scope: int = ...): ...
@property
def isPlusInf(self): ...
@property
def isMinusInf(self): ...
@property
def isInf(self): ...
def __add__(self, value): ...
def __radd__(self, value): ...
def __mul__(self, value): ...
def __rmul__(self, value): ...
def __sub__(self, value): ...
def __rsub__(self, value): ...
def __mod__(self, value): ...
def __rmod__(self, value): ...
# Accepts everything builtins.pow with a float base does
def __pow__(self: Self, value: complex, modulo: int | None = ...) -> Self: ...
def __rpow__(self, value): ...
def __truediv__(self, value): ...
def __rtruediv__(self, value): ...
def __divmod__(self, value): ...
def __rdivmod__(self, value): ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __abs__(self): ...
def __pos__(self): ...
def __neg__(self): ...
def __round__(self, n: int = ...): ...
def __floor__(self): ...
def __ceil__(self): ...
def __trunc__(self): ...
def __lt__(self, value): ...
def __le__(self, value): ...
def __eq__(self, value): ...
def __ne__(self, value): ...
def __gt__(self, value): ...
def __ge__(self, value): ...
def __bool__(self) -> bool: ...
__hash__ = base.SimpleAsn1Type.__hash__
def __getitem__(self, idx): ...
def isPlusInfinity(self): ...
def isMinusInfinity(self): ...
def isInfinity(self): ...
class Enumerated(Integer):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
namedValues: namedval.NamedValues
class SequenceOfAndSetOfBase(base.ConstructedAsn1Type):
componentType: namedtype.NamedTypes | None
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
def __init__(
self,
*args,
componentType: namedtype.NamedTypes | None = ...,
tagSet: TagSet = ...,
subtypeSpec: constraint.ConstraintsIntersection = ...,
) -> None: ...
def __getitem__(self, idx): ...
def __setitem__(self, idx, value) -> None: ...
def append(self, value) -> None: ...
def count(self, value): ...
def extend(self, values) -> None: ...
def index(self, value, start: int = ..., stop: int | None = ...): ...
def reverse(self) -> None: ...
def sort(self, key: Callable[[Incomplete], SupportsRichComparison] | None = ..., reverse: bool = ...) -> None: ...
def __len__(self) -> int: ...
def __iter__(self): ...
def getComponentByPosition(self, idx, default=..., instantiate: bool = ...): ...
def setComponentByPosition(
self, idx, value=..., verifyConstraints: bool = ..., matchTags: bool = ..., matchConstraints: bool = ...
): ...
@property
def componentTagMap(self): ...
@property
def components(self): ...
def clear(self): ...
def reset(self): ...
def prettyPrint(self, scope: int = ...): ...
def prettyPrintType(self, scope: int = ...): ...
@property
def isValue(self): ...
@property
def isInconsistent(self): ...
class SequenceOf(SequenceOfAndSetOfBase):
typeId: int
class SetOf(SequenceOfAndSetOfBase):
typeId: int
class SequenceAndSetBase(base.ConstructedAsn1Type):
componentType: namedtype.NamedTypes
class DynamicNames:
def __init__(self) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, item) -> bool: ...
def __iter__(self): ...
def __getitem__(self, item): ...
def getNameByPosition(self, idx): ...
def getPositionByName(self, name): ...
def addField(self, idx) -> None: ...
def __init__(self, **kwargs) -> None: ...
def __getitem__(self, idx): ...
def __setitem__(self, idx, value) -> None: ...
def __contains__(self, key) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self): ...
def values(self) -> Generator[Incomplete, None, None]: ...
def keys(self): ...
def items(self) -> Generator[Incomplete, None, None]: ...
def update(self, *iterValue, **mappingValue) -> None: ...
def clear(self): ...
def reset(self): ...
@property
def components(self): ...
def getComponentByName(self, name, default=..., instantiate: bool = ...): ...
def setComponentByName(
self, name, value=..., verifyConstraints: bool = ..., matchTags: bool = ..., matchConstraints: bool = ...
): ...
def getComponentByPosition(self, idx, default=..., instantiate: bool = ...): ...
def setComponentByPosition(
self, idx, value=..., verifyConstraints: bool = ..., matchTags: bool = ..., matchConstraints: bool = ...
): ...
@property
def isValue(self): ...
@property
def isInconsistent(self): ...
def prettyPrint(self, scope: int = ...): ...
def prettyPrintType(self, scope: int = ...): ...
def setDefaultComponents(self): ...
def getComponentType(self): ...
def getNameByPosition(self, idx): ...
class Sequence(SequenceAndSetBase):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
componentType: namedtype.NamedTypes
typeId: int
def getComponentTagMapNearPosition(self, idx): ...
def getComponentPositionNearType(self, tagSet, idx): ...
class Set(SequenceAndSetBase):
tagSet: TagSet
componentType: namedtype.NamedTypes
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
def getComponent(self, innerFlag: bool = ...): ...
def getComponentByType(self, tagSet, default=..., instantiate: bool = ..., innerFlag: bool = ...): ...
def setComponentByType(
self,
tagSet,
value=...,
verifyConstraints: bool = ...,
matchTags: bool = ...,
matchConstraints: bool = ...,
innerFlag: bool = ...,
): ...
@property
def componentTagMap(self): ...
class Choice(Set):
tagSet: TagSet
componentType: namedtype.NamedTypes
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
def __eq__(self, other): ...
def __ne__(self, other): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __bool__(self) -> bool: ...
def __len__(self) -> int: ...
def __contains__(self, key) -> bool: ...
def __iter__(self): ...
def values(self) -> Generator[Incomplete, None, None]: ...
def keys(self) -> Generator[Incomplete, None, None]: ...
def items(self) -> Generator[Incomplete, None, None]: ...
def checkConsistency(self) -> None: ...
def getComponentByPosition(self, idx, default=..., instantiate: bool = ...): ...
def setComponentByPosition(
self, idx, value=..., verifyConstraints: bool = ..., matchTags: bool = ..., matchConstraints: bool = ...
): ...
@property
def effectiveTagSet(self): ...
@property
def tagMap(self): ...
def getComponent(self, innerFlag: bool = ...): ...
def getName(self, innerFlag: bool = ...): ...
@property
def isValue(self): ...
def clear(self): ...
def getMinTagSet(self): ...
class Any(OctetString):
tagSet: TagSet
subtypeSpec: constraint.ConstraintsIntersection
typeId: int
@property
def tagMap(self): ...

View File

@@ -0,0 +1,28 @@
import datetime
from pyasn1.type import char
from pyasn1.type.tag import TagSet
class ObjectDescriptor(char.GraphicString):
tagSet: TagSet
typeId: int
class TimeMixIn:
class FixedOffset(datetime.tzinfo):
def __init__(self, offset: int = ..., name: str = ...) -> None: ...
def utcoffset(self, dt): ...
def tzname(self, dt): ...
def dst(self, dt): ...
UTC: FixedOffset
@property
def asDateTime(self): ...
@classmethod
def fromDateTime(cls, dt): ...
class GeneralizedTime(char.VisibleString, TimeMixIn):
tagSet: TagSet
typeId: int
class UTCTime(char.VisibleString, TimeMixIn):
tagSet: TagSet
typeId: int