Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply ruff rules #1

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ jobs:
- "3.13"
- "3.14"
include:
- version: "3.8"
check-consistency: "true"
- version: "3.9"
check-consistency: "true"
- version: "3.10"
check-consistency: "true"
- version: "3.11"
check-consistency: "true"
- version: "3.12"
check-consistency: "true"
- version: "3.13"
check-consistency: "true"
steps:
Expand All @@ -38,6 +48,15 @@ jobs:
uv sync --all-extras --dev
- name: Run pre-commit
run: uvx pre-commit run --all-files
- name: Check types in test.py
run: |
uv build --wheel
OUTPUT=`uvx --python=3.8 --with dist/*.whl mypy test.py || true`
echo $OUTPUT
if [[ ${OUTPUT} != *"Found 1 error"* ]];then
echo "Stubs test failed: $TEST"
exit 1
fi
- name: Stubs consistency check
if: ${{ matrix.check-consistency }}
run: |
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
}
}
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
awscrt-stubs/py.typed
awscrt-stubs/*.pyi
awscrt-stubs/*/*.pyi
include awscrt-stubs/py.typed
include awscrt-stubs/*.pyi
include awscrt-stubs/*/*.pyi
4 changes: 4 additions & 0 deletions awscrt-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Copyright 2024 Vlad Emelianov
"""

from awscrt import auth as auth
from awscrt import crypto as crypto
from awscrt import http as http
Expand Down
4 changes: 4 additions & 0 deletions awscrt-stubs/_test.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Copyright 2024 Vlad Emelianov
"""

from awscrt import NativeResource as NativeResource
from awscrt.io import ClientBootstrap as ClientBootstrap
from awscrt.io import DefaultHostResolver as DefaultHostResolver
Expand Down
70 changes: 36 additions & 34 deletions awscrt-stubs/auth.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""
Copyright 2024 Vlad Emelianov
"""

from concurrent.futures import Future
from datetime import datetime
from enum import IntEnum
from typing import Any, Callable, List, Optional, Sequence, Tuple, Type, TypeVar
from typing import Any, Callable, Sequence, TypeVar

from awscrt import NativeResource as NativeResource
from awscrt.http import HttpProxyOptions
Expand All @@ -16,8 +20,8 @@ class AwsCredentials(NativeResource):
self,
access_key_id: str,
secret_access_key: str,
session_token: Optional[str] = ...,
expiration: Optional[datetime] = ...,
session_token: str | None = ...,
expiration: datetime | None = ...,
) -> None: ...
@property
def access_key_id(self) -> str: ...
Expand All @@ -26,62 +30,60 @@ class AwsCredentials(NativeResource):
@property
def session_token(self) -> str: ...
@property
def expiration(self) -> Optional[datetime]: ...
def expiration(self) -> datetime | None: ...
def __deepcopy__(self: _R, memo: Any) -> _R: ...

class AwsCredentialsProviderBase(NativeResource): ...

class AwsCredentialsProvider(AwsCredentialsProviderBase):
def __init__(self, binding: Any) -> None: ...
@classmethod
def new_default_chain(
cls: Type[_R], client_bootstrap: Optional[ClientBootstrap] = ...
) -> _R: ...
def new_default_chain(cls: type[_R], client_bootstrap: ClientBootstrap | None = ...) -> _R: ...
@classmethod
def new_static(
cls: Type[_R],
cls: type[_R],
access_key_id: str,
secret_access_key: str,
session_token: Optional[str] = ...,
session_token: str | None = ...,
) -> _R: ...
@classmethod
def new_profile(
cls: Type[_R],
client_bootstrap: Optional[ClientBootstrap] = ...,
profile_name: Optional[str] = ...,
config_filepath: Optional[str] = ...,
credentials_filepath: Optional[str] = ...,
cls: type[_R],
client_bootstrap: ClientBootstrap | None = ...,
profile_name: str | None = ...,
config_filepath: str | None = ...,
credentials_filepath: str | None = ...,
) -> _R: ...
@classmethod
def new_process(cls: Type[_R], profile_to_use: Optional[str] = ...) -> _R: ...
def new_process(cls: type[_R], profile_to_use: str | None = ...) -> _R: ...
@classmethod
def new_environment(cls: Type[_R]) -> _R: ...
def new_environment(cls: type[_R]) -> _R: ...
@classmethod
def new_chain(cls: Type[_R], providers: List[AwsCredentialsProvider]) -> _R: ...
def new_chain(cls: type[_R], providers: list[AwsCredentialsProvider]) -> _R: ...
@classmethod
def new_delegate(cls: Type[_R], get_credentials: Callable[[], AwsCredentials]) -> _R: ...
def new_delegate(cls: type[_R], get_credentials: Callable[[], AwsCredentials]) -> _R: ...
@classmethod
def new_cognito(
cls: Type[_R],
cls: type[_R],
*,
endpoint: str,
identity: str,
tls_ctx: ClientTlsContext,
logins: Optional[Sequence[Tuple[str, str]]] = ...,
custom_role_arn: Optional[str] = ...,
client_bootstrap: Optional[ClientBootstrap] = ...,
http_proxy_options: Optional[HttpProxyOptions] = ...,
logins: Sequence[tuple[str, str]] | None = ...,
custom_role_arn: str | None = ...,
client_bootstrap: ClientBootstrap | None = ...,
http_proxy_options: HttpProxyOptions | None = ...,
) -> _R: ...
@classmethod
def new_x509(
cls: Type[_R],
cls: type[_R],
*,
endpoint: str,
thing_name: str,
role_alias: str,
tls_ctx: ClientTlsContext,
client_bootstrap: Optional[ClientBootstrap] = ...,
http_proxy_options: Optional[HttpProxyOptions] = ...,
client_bootstrap: ClientBootstrap | None = ...,
http_proxy_options: HttpProxyOptions | None = ...,
) -> _R: ...
def get_credentials(self) -> Future[AwsCredentials]: ...

Expand Down Expand Up @@ -109,16 +111,16 @@ class AwsSigningConfig(NativeResource):
self,
algorithm: AwsSigningAlgorithm = ...,
signature_type: AwsSignatureType = ...,
credentials_provider: Optional[AwsCredentialsProvider] = ...,
credentials_provider: AwsCredentialsProvider | None = ...,
region: str = ...,
service: str = ...,
date: Optional[datetime] = ...,
should_sign_header: Optional[Callable[[str], bool]] = ...,
date: datetime | None = ...,
should_sign_header: Callable[[str], bool] | None = ...,
use_double_uri_encode: bool = ...,
should_normalize_uri_path: bool = ...,
signed_body_value: Optional[str] = ...,
signed_body_value: str | None = ...,
signed_body_header_type: AwsSignedBodyHeaderType = ...,
expiration_in_seconds: Optional[int] = ...,
expiration_in_seconds: int | None = ...,
omit_session_token: bool = ...,
) -> None: ...
def replace(self: _R, **kwargs: Any) -> _R: ...
Expand All @@ -135,17 +137,17 @@ class AwsSigningConfig(NativeResource):
@property
def date(self) -> datetime: ...
@property
def should_sign_header(self) -> Optional[Callable[[str], bool]]: ...
def should_sign_header(self) -> Callable[[str], bool] | None: ...
@property
def use_double_uri_encode(self) -> bool: ...
@property
def should_normalize_uri_path(self) -> bool: ...
@property
def signed_body_value(self) -> Optional[str]: ...
def signed_body_value(self) -> str | None: ...
@property
def signed_body_header_type(self) -> AwsSignedBodyHeaderType: ...
@property
def expiration_in_seconds(self) -> Optional[int]: ...
def expiration_in_seconds(self) -> int | None: ...
@property
def omit_session_token(self) -> bool: ...

Expand Down
30 changes: 17 additions & 13 deletions awscrt-stubs/crypto.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""
Copyright 2024 Vlad Emelianov
"""

from enum import IntEnum
from typing import Any, Union
from typing import Any

from awscrt import NativeResource

Expand Down Expand Up @@ -35,36 +39,36 @@ class RSA(NativeResource):
def __init__(self, binding: Any) -> None: ...
@staticmethod
def new_private_key_from_pem_data(
pem_data: Union[str, bytes, bytearray, memoryview],
) -> "RSA": ...
pem_data: str | bytes | bytearray | memoryview,
) -> RSA: ...
@staticmethod
def new_public_key_from_pem_data(
pem_data: Union[str, bytes, bytearray, memoryview],
) -> "RSA": ...
pem_data: str | bytes | bytearray | memoryview,
) -> RSA: ...
@staticmethod
def new_private_key_from_der_data(
der_data: Union[str, bytes, bytearray, memoryview],
) -> "RSA": ...
der_data: str | bytes | bytearray | memoryview,
) -> RSA: ...
@staticmethod
def new_public_key_from_der_data(der_data: Union[bytes, bytearray, memoryview]) -> "RSA": ...
def new_public_key_from_der_data(der_data: bytes | bytearray | memoryview) -> RSA: ...
def encrypt(
self,
encryption_algorithm: RSAEncryptionAlgorithm,
plaintext: Union[bytes, bytearray, memoryview],
plaintext: bytes | bytearray | memoryview,
) -> bytes: ...
def decrypt(
self,
encryption_algorithm: RSAEncryptionAlgorithm,
ciphertext: Union[bytes, bytearray, memoryview],
ciphertext: bytes | bytearray | memoryview,
) -> bytes: ...
def sign(
self,
signature_algorithm: RSASignatureAlgorithm,
digest: Union[bytes, bytearray, memoryview],
digest: bytes | bytearray | memoryview,
) -> bytes: ...
def verify(
self,
signature_algorithm: RSASignatureAlgorithm,
digest: Union[bytes, bytearray, memoryview],
signature: Union[bytes, bytearray, memoryview],
digest: bytes | bytearray | memoryview,
signature: bytes | bytearray | memoryview,
) -> bool: ...
9 changes: 6 additions & 3 deletions awscrt-stubs/eventstream/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from collections.abc import ByteString
"""
Copyright 2024 Vlad Emelianov
"""

from enum import IntEnum
from typing import Any
from uuid import UUID
Expand Down Expand Up @@ -29,7 +32,7 @@ class Header:
@classmethod
def from_int64(cls, name: str, value: int) -> Header: ...
@classmethod
def from_byte_buf(cls, name: str, value: ByteString) -> Header: ...
def from_byte_buf(cls, name: str, value: bytes | bytearray) -> Header: ...
@classmethod
def from_string(cls, name: str, value: str) -> Header: ...
@classmethod
Expand All @@ -47,7 +50,7 @@ class Header:
def value_as_int16(self) -> int: ...
def value_as_int32(self) -> int: ...
def value_as_int64(self) -> int: ...
def value_as_byte_buf(self) -> ByteString: ...
def value_as_byte_buf(self) -> bytes | bytearray: ...
def value_as_string(self) -> str: ...
def value_as_timestamp(self) -> int: ...
def value_as_uuid(self) -> UUID: ...
Loading