Skip to content

Commit

Permalink
Update for new mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Dec 20, 2024
1 parent cd9b244 commit 09f1daa
Show file tree
Hide file tree
Showing 12 changed files with 325 additions and 283 deletions.
11 changes: 11 additions & 0 deletions awscrt-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ from awscrt import mqtt as mqtt
from awscrt import s3 as s3
from awscrt import websocket as websocket

__all__ = [
"auth",
"crypto",
"http",
"io",
"mqtt",
"s3",
"websocket",
]
__version__: str = ...

class NativeResource:
def __init__(self) -> None: ...
14 changes: 7 additions & 7 deletions awscrt-stubs/auth.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ class AwsCredentialsProvider(AwsCredentialsProviderBase):
def get_credentials(self) -> Future[AwsCredentials]: ...

class AwsSigningAlgorithm(IntEnum):
V4: int
V4_ASYMMETRIC: int
V4_S3EXPRESS: int
V4 = 0
V4_ASYMMETRIC = 1
V4_S3EXPRESS = 2

class AwsSignatureType(IntEnum):
HTTP_REQUEST_HEADERS: int
HTTP_REQUEST_QUERY_PARAMS: int
HTTP_REQUEST_HEADERS = 0
HTTP_REQUEST_QUERY_PARAMS = 1

class AwsSignedBodyValue:
EMPTY_SHA256: str
Expand All @@ -105,8 +105,8 @@ class AwsSignedBodyValue:
STREAMING_AWS4_HMAC_SHA256_EVENTS: str

class AwsSignedBodyHeaderType(IntEnum):
NONE: int
X_AMZ_CONTENT_SHA_256: int
NONE = 0
X_AMZ_CONTENT_SHA_256 = 1

class AwsSigningConfig(NativeResource):
def __init__(
Expand Down
12 changes: 6 additions & 6 deletions awscrt-stubs/crypto.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class HMAC:
def digest(self, truncate_to: int = ...) -> str: ...

class RSAEncryptionAlgorithm(IntEnum):
PKCS1_5: int
OAEP_SHA256: int
OAEP_SHA512: int
PKCS1_5 = 0
OAEP_SHA256 = 1
OAEP_SHA512 = 2

class RSASignatureAlgorithm(IntEnum):
PKCS1_5_SHA256: int
PKCS1_5_SHA1: int
PSS_SHA256: int
PKCS1_5_SHA256 = 0
PKCS1_5_SHA1 = 1
PSS_SHA256 = 2

class RSA(NativeResource):
def __init__(self, binding: Any) -> None: ...
Expand Down
22 changes: 12 additions & 10 deletions awscrt-stubs/eventstream/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ from enum import IntEnum
from typing import Any
from uuid import UUID

__all__ = ["Header", "HeaderType"]

class HeaderType(IntEnum):
BOOL_TRUE: int
BOOL_FALSE: int
BYTE: int
INT16: int
INT32: int
INT64: int
BYTE_BUF: int
STRING: int
TIMESTAMP: int
UUID: int
BOOL_TRUE = 0
BOOL_FALSE = 1
BYTE = 2
INT16 = 3
INT32 = 4
INT64 = 5
BYTE_BUF = 6
STRING = 7
TIMESTAMP = 8
UUID = 9
def __format__(self, format_spec: str) -> str: ...

class Header:
Expand Down
31 changes: 20 additions & 11 deletions awscrt-stubs/eventstream/rpc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@ from awscrt.eventstream import Header
from awscrt.http import HttpClientConnection
from awscrt.io import ClientBootstrap, SocketOptions, TlsConnectionOptions

__all__ = [
"ClientConnection",
"ClientConnectionHandler",
"ClientContinuation",
"ClientContinuationHandler",
"MessageFlag",
"MessageType",
]

class MessageType(IntEnum):
APPLICATION_MESSAGE: int
APPLICATION_ERROR: int
PING: int
PING_RESPONSE: int
CONNECT: int
CONNECT_ACK: int
PROTOCOL_ERROR: int
INTERNAL_ERROR: int
APPLICATION_MESSAGE = 0
APPLICATION_ERROR = 1
PING = 2
PING_RESPONSE = 3
CONNECT = 4
CONNECT_ACK = 5
PROTOCOL_ERROR = 6
INTERNAL_ERROR = 7
def __format__(self, format_spec: str) -> str: ...

class MessageFlag:
NONE: int
CONNECTION_ACCEPTED: int
TERMINATE_STREAM: int
NONE: int = ...
CONNECTION_ACCEPTED: int = ...
TERMINATE_STREAM: int = ...
def __format__(self, format_spec: str) -> str: ...

class ClientConnectionHandler(ABC, metaclass=abc.ABCMeta):
Expand Down
18 changes: 9 additions & 9 deletions awscrt-stubs/http.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ from awscrt.io import TlsConnectionOptions as TlsConnectionOptions
_R = TypeVar("_R")

class HttpVersion(IntEnum):
Unknown: int
Http1_0: int
Http1_1: int
Http2: int
Unknown = 0
Http1_0 = 1
Http1_1 = 2
Http2 = 3

class HttpConnectionBase(NativeResource):
def __init__(self) -> None: ...
Expand Down Expand Up @@ -117,13 +117,13 @@ class HttpHeaders(NativeResource):
def __iter__(self) -> Iterator[tuple[str, str]]: ...

class HttpProxyConnectionType(IntEnum):
Legacy: int
Forwarding: int
Tunneling: int
Legacy = 0
Forwarding = 1
Tunneling = 2

class HttpProxyAuthenticationType(IntEnum):
Nothing: int
Basic: int
Nothing = 0
Basic = 1

class HttpProxyOptions:
def __init__(
Expand Down
46 changes: 23 additions & 23 deletions awscrt-stubs/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ from awscrt import NativeResource as NativeResource
_R = TypeVar("_R")

class LogLevel(IntEnum):
NoLogs: int
Fatal: int
Error: int
Warn: int
Info: int
Debug: int
Trace: int
NoLogs = 0
Fatal = 1
Error = 2
Warn = 3
Info = 4
Debug = 5
Trace = 6

def init_logging(log_level: int, file_name: str) -> None: ...

Expand Down Expand Up @@ -51,13 +51,13 @@ class ClientBootstrap(NativeResource):
def release_static_default() -> None: ...

class SocketDomain(IntEnum):
IPv4: int
IPv6: int
Local: int
IPv4 = 0
IPv6 = 1
Local = 2

class SocketType(IntEnum):
Stream: int
DGram: int
Stream = 0
DGram = 1

class SocketOptions:
domain: SocketDomain
Expand All @@ -70,16 +70,16 @@ class SocketOptions:
def __init__(self) -> None: ...

class TlsVersion(IntEnum):
SSLv3: int
TLSv1: int
TLSv1_1: int
TLSv1_2: int
TLSv1_3: int
DEFAULT: int
SSLv3 = 0
TLSv1 = 1
TLSv1_1 = 2
TLSv1_2 = 3
TLSv1_3 = 4
DEFAULT = 128

class TlsCipherPref(IntEnum):
DEFAULT: int
PQ_TLSv1_0_2021_05: int
DEFAULT = 0
PQ_TLSv1_0_2021_05 = 6
def is_supported(self) -> bool: ...

class TlsContextOptions:
Expand Down Expand Up @@ -148,8 +148,8 @@ class InputStream(NativeResource):

class Pkcs11Lib(NativeResource):
class InitializeFinalizeBehavior(IntEnum):
DEFAULT: int
OMIT: int
STRICT: int
DEFAULT = 0
OMIT = 1
STRICT = 2

def __init__(self, *, file: str, behavior: InitializeFinalizeBehavior | None = ...) -> None: ...
18 changes: 9 additions & 9 deletions awscrt-stubs/mqtt.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ from awscrt.io import SocketOptions as SocketOptions
from awscrt.mqtt5 import QoS as Mqtt5QoS

class QoS(IntEnum):
AT_MOST_ONCE: int
AT_LEAST_ONCE: int
EXACTLY_ONCE: int
AT_MOST_ONCE = 0
AT_LEAST_ONCE = 1
EXACTLY_ONCE = 2

def to_mqtt5(self) -> Mqtt5QoS: ...

class ConnectReturnCode(IntEnum):
ACCEPTED: int
UNACCEPTABLE_PROTOCOL_VERSION: int
IDENTIFIER_REJECTED: int
SERVER_UNAVAILABLE: int
BAD_USERNAME_OR_PASSWORD: int
NOT_AUTHORIZED: int
ACCEPTED = 0
UNACCEPTABLE_PROTOCOL_VERSION = 1
IDENTIFIER_REJECTED = 2
SERVER_UNAVAILABLE = 3
BAD_USERNAME_OR_PASSWORD = 4
NOT_AUTHORIZED = 5

class Will:
def __init__(self, topic: str, qos: QoS, payload: bytes, retain: bool) -> None:
Expand Down
Loading

0 comments on commit 09f1daa

Please sign in to comment.