Skip to content

Commit c791c1d

Browse files
committed
Apply ruff rules
1 parent f40f9b6 commit c791c1d

File tree

15 files changed

+233
-136
lines changed

15 files changed

+233
-136
lines changed

.github/workflows/on_push.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,17 @@ jobs:
2222
- "3.13"
2323
- "3.14"
2424
include:
25+
- version: "3.8"
26+
check-consistency: "true"
27+
- version: "3.9"
28+
check-consistency: "true"
29+
- version: "3.10"
30+
check-consistency: "true"
31+
- version: "3.11"
32+
check-consistency: "true"
33+
- version: "3.12"
34+
check-consistency: "true"
2535
- version: "3.13"
26-
check-formatting: "true"
2736
check-consistency: "true"
2837
steps:
2938
- uses: actions/checkout@v4
@@ -38,6 +47,15 @@ jobs:
3847
run: uv sync --all-extras --dev
3948
- name: Run pre-commit
4049
run: uvx pre-commit run --all-files
50+
- name: Check types in test.py
51+
run: |
52+
uv build --wheel
53+
OUTPUT=`uvx --with dist/*.whl mypy test.py || true`
54+
echo $OUTPUT
55+
if [[ ${OUTPUT} != *"Found 1 error"* ]];then
56+
echo "Stubs test failed: $TEST"
57+
exit 1
58+
fi
4159
- name: Stubs consistency check
4260
if: ${{ matrix.check-consistency }}
4361
run: |

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,4 @@ ENV/
4747
.mypy_cache
4848
.pytest_cache
4949

50-
test.py
5150
out

aioboto3-stubs/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
Type annotations for aioboto3 module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
17
import logging
28
from typing import Any
39

aioboto3-stubs/dynamodb/table.pyi

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
"""
2+
Type annotations for aioboto3.dynamodb.table module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
17
import logging
28
from types import TracebackType
3-
from typing import Any, Dict, List, Optional, Type, TypeVar
9+
from typing import Any, TypeVar
410

511
from boto3.dynamodb.table import TableResource
612
from botocore.client import BaseClient
@@ -9,32 +15,32 @@ logger: logging.Logger
915

1016
_R = TypeVar("_R")
1117

12-
def register_table_methods(base_classes: List[Any], **kwargs: Any) -> None: ...
18+
def register_table_methods(base_classes: list[Any], **kwargs: Any) -> None: ...
1319

1420
class CustomTableResource(TableResource):
1521
# FIXME: Signature of "batch_writer" incompatible with supertype "TableResource"
1622
def batch_writer( # type: ignore [override]
1723
self,
18-
overwrite_by_pkeys: Optional[List[str]] = ...,
24+
overwrite_by_pkeys: list[str] | None = ...,
1925
flush_amount: int = ...,
2026
on_exit_loop_sleep: int = ...,
21-
) -> "BatchWriter": ...
27+
) -> BatchWriter: ...
2228

2329
class BatchWriter:
2430
def __init__(
2531
self,
2632
table_name: str,
2733
client: BaseClient,
2834
flush_amount: int = ...,
29-
overwrite_by_pkeys: Optional[List[str]] = ...,
35+
overwrite_by_pkeys: list[str] | None = ...,
3036
on_exit_loop_sleep: int = ...,
3137
) -> None: ...
32-
async def put_item(self, Item: Dict[str, Any]) -> None: ...
33-
async def delete_item(self, Key: Dict[str, Any]) -> None: ...
38+
async def put_item(self, Item: dict[str, Any]) -> None: ...
39+
async def delete_item(self, Key: dict[str, Any]) -> None: ...
3440
async def __aenter__(self: _R) -> _R: ...
3541
async def __aexit__(
3642
self,
37-
exc_type: Optional[Type[BaseException]],
38-
exc_value: Optional[BaseException],
39-
tb: Optional[TracebackType],
43+
exc_type: type[BaseException] | None,
44+
exc_value: BaseException | None,
45+
tb: TracebackType | None,
4046
) -> None: ...

aioboto3-stubs/experimental/async_chalice.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
from typing import Any, Optional
1+
"""
2+
Type annotations for aioboto3.experimental.async_chalice module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
7+
from typing import Any
28

39
from aioboto3.session import Session as Session
410
from chalice import Chalice # type: ignore
@@ -9,7 +15,7 @@ class AsyncRestAPIEventHandler(RestAPIEventHandler): ... # type: ignore
915
class AsyncChalice(Chalice): # type: ignore
1016
aioboto3: Any
1117
def __init__(
12-
self, *args: Any, aioboto3_session: Optional[Session] = ..., **kwargs: Any
18+
self, *args: Any, aioboto3_session: Session | None = ..., **kwargs: Any
1319
) -> None: ...
1420
lambda_context: Any
1521
current_request: Any

aioboto3-stubs/resources/action.pyi

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
"""
2+
Type annotations for aioboto3.resources.action module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
17
import logging
2-
from typing import Any, Dict, List, Optional, Union
8+
from typing import Any
39

410
from boto3.resources.action import ServiceAction, WaiterAction
511
from boto3.resources.base import ServiceResource
@@ -13,17 +19,17 @@ class AIOServiceAction(ServiceAction):
1319
def __init__(
1420
self,
1521
action_model: Action,
16-
factory: Optional[ResourceFactory] = ...,
17-
service_context: Optional[ServiceContext] = ...,
22+
factory: ResourceFactory | None = ...,
23+
service_context: ServiceContext | None = ...,
1824
) -> None: ...
1925
async def __call__( # type: ignore [override]
2026
self, parent: ServiceResource, *args: Any, **kwargs: Any
21-
) -> Union[ServiceResource, List[ServiceResource], Dict[str, Any]]: ...
27+
) -> ServiceResource | list[ServiceResource] | dict[str, Any]: ...
2228

2329
class AioBatchAction(ServiceAction):
2430
async def __call__( # type: ignore [override]
2531
self, parent: ServiceResource, *args: Any, **kwargs: Any
26-
) -> List[Dict[str, Any]]: ...
32+
) -> list[dict[str, Any]]: ...
2733

2834
class AIOWaiterAction(WaiterAction):
2935
async def __call__( # type: ignore [override]

aioboto3-stubs/resources/base.pyi

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1+
"""
2+
Type annotations for aioboto3.resources.base module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
17
import logging
28
from types import TracebackType
3-
from typing import Optional, Type, TypeVar
9+
from typing import TypeVar
410

511
from boto3.resources.base import ServiceResource
612

7-
_R = TypeVar("_R", bound="AIOBoto3ServiceResource")
13+
_R = TypeVar("_R", bound=AIOBoto3ServiceResource)
814

915
logger: logging.Logger
1016

1117
class AIOBoto3ServiceResource(ServiceResource):
1218
async def __aenter__(self: _R) -> _R: ...
1319
async def __aexit__(
1420
self,
15-
exc_type: Optional[Type[BaseException]],
16-
exc_value: Optional[BaseException],
17-
tb: Optional[TracebackType],
21+
exc_type: type[BaseException] | None,
22+
exc_value: BaseException | None,
23+
tb: TracebackType | None,
1824
) -> None: ...
1925
def close(self) -> None: ...

aioboto3-stubs/resources/collection.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
"""
2+
Type annotations for aioboto3.resources.collection module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
17
import logging
2-
from typing import Any, AsyncIterator, List, NoReturn
8+
from typing import Any, AsyncIterator, NoReturn
39

410
from boto3.resources.base import ServiceResource
511
from boto3.resources.collection import CollectionFactory, CollectionManager, ResourceCollection
@@ -14,7 +20,7 @@ class AIOResourceCollection(ResourceCollection):
1420
def __anext__(self) -> AsyncIterator[Any]: ...
1521
def __aiter__(self) -> AsyncIterator[Any]: ...
1622
def __iter__(self) -> NoReturn: ...
17-
def pages(self) -> AsyncIterator[List[Any]]: ... # type: ignore [override]
23+
def pages(self) -> AsyncIterator[list[Any]]: ... # type: ignore [override]
1824

1925
class AIOCollectionManager(CollectionManager):
2026
def __init__(

aioboto3-stubs/resources/factory.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
Type annotations for aioboto3.resources.factory module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
17
import logging
28
from typing import Any
39

aioboto3-stubs/resources/response.pyi

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
from typing import Any, Dict, List, Union
1+
"""
2+
Type annotations for aioboto3.resources.response module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
7+
from typing import Any
28

39
from boto3.resources.base import ServiceResource
410
from boto3.resources.response import RawHandler, ResourceHandler
511

612
class AIOResourceHandler(ResourceHandler):
713
async def __call__( # type: ignore [override]
8-
self, parent: ServiceResource, params: Dict[str, Any], response: Dict[str, Any]
9-
) -> Union[ServiceResource, List[ServiceResource]]: ...
14+
self, parent: ServiceResource, params: dict[str, Any], response: dict[str, Any]
15+
) -> ServiceResource | list[ServiceResource]: ...
1016

1117
class AIORawHandler(RawHandler):
1218
async def __call__( # type: ignore [override]
13-
self, parent: ServiceResource, params: Dict[str, Any], response: Dict[str, Any]
14-
) -> Dict[str, Any]: ...
19+
self, parent: ServiceResource, params: dict[str, Any], response: dict[str, Any]
20+
) -> dict[str, Any]: ...

aioboto3-stubs/s3/cse.pyi

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
"""
2+
Type annotations for aioboto3.s3.cse module.
3+
4+
Copyright 2024 Vlad Emelianov
5+
"""
6+
17
import asyncio
28
from types import TracebackType
3-
from typing import IO, Any, Dict, Mapping, Optional, Tuple, Type, TypeVar, Union
9+
from typing import IO, Any, Mapping, TypeVar
410

511
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey
612

@@ -25,90 +31,90 @@ class CryptoContext:
2531
async def setup(self) -> None: ...
2632
async def close(self) -> None: ...
2733
async def get_decryption_aes_key(
28-
self, key: bytes, material_description: Dict[str, Any]
34+
self, key: bytes, material_description: dict[str, Any]
2935
) -> bytes: ...
30-
async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: ...
36+
async def get_encryption_aes_key(self) -> tuple[bytes, dict[str, str], str]: ...
3137

3238
class AsymmetricCryptoContext(CryptoContext):
3339
public_key: RSAPublicKey
3440
private_key: RSAPrivateKey
3541
def __init__(
3642
self,
37-
public_key: Optional[RSAPublicKey] = ...,
38-
private_key: Optional[RSAPrivateKey] = ...,
39-
loop: Optional[asyncio.AbstractEventLoop] = ...,
43+
public_key: RSAPublicKey | None = ...,
44+
private_key: RSAPrivateKey | None = ...,
45+
loop: asyncio.AbstractEventLoop | None = ...,
4046
) -> None: ...
4147
async def get_decryption_aes_key(
42-
self, key: bytes, material_description: Dict[str, Any]
48+
self, key: bytes, material_description: dict[str, Any]
4349
) -> bytes: ...
44-
async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: ...
50+
async def get_encryption_aes_key(self) -> tuple[bytes, dict[str, str], str]: ...
4551
@staticmethod
4652
def from_der_public_key(data: bytes) -> RSAPublicKey: ...
4753
@staticmethod
48-
def from_der_private_key(data: bytes, password: Optional[str] = ...) -> RSAPrivateKey: ...
54+
def from_der_private_key(data: bytes, password: str | None = ...) -> RSAPrivateKey: ...
4955

5056
class SymmetricCryptoContext(CryptoContext):
5157
key: bytes
52-
def __init__(self, key: bytes, loop: Optional[asyncio.AbstractEventLoop] = ...) -> None: ...
58+
def __init__(self, key: bytes, loop: asyncio.AbstractEventLoop | None = ...) -> None: ...
5359
async def get_decryption_aes_key(
54-
self, key: bytes, material_description: Dict[str, Any]
60+
self, key: bytes, material_description: dict[str, Any]
5561
) -> bytes: ...
56-
async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: ...
62+
async def get_encryption_aes_key(self) -> tuple[bytes, dict[str, str], str]: ...
5763

5864
class KMSCryptoContext(CryptoContext):
5965
kms_key: str
6066
authenticated_encryption: bool
6167
def __init__(
6268
self,
63-
keyid: Optional[str] = ...,
64-
kms_client_args: Optional[Dict[str, Any]] = ...,
69+
keyid: str | None = ...,
70+
kms_client_args: dict[str, Any] | None = ...,
6571
authenticated_encryption: bool = ...,
6672
) -> None: ...
6773
async def setup(self) -> None: ...
6874
async def close(self) -> None: ...
6975
async def get_decryption_aes_key(
70-
self, key: bytes, material_description: Dict[str, Any]
76+
self, key: bytes, material_description: dict[str, Any]
7177
) -> bytes: ...
72-
async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: ...
78+
async def get_encryption_aes_key(self) -> tuple[bytes, dict[str, str], str]: ...
7379

7480
class MockKMSCryptoContext(KMSCryptoContext):
7581
aes_key: bytes
76-
material_description: Dict[str, Any]
82+
material_description: dict[str, Any]
7783
encrypted_key: bytes
7884
authenticated_encryption: bool
7985
def __init__(
8086
self,
8187
aes_key: bytes,
82-
material_description: Dict[str, Any],
88+
material_description: dict[str, Any],
8389
encrypted_key: bytes,
8490
authenticated_encryption: bool = ...,
8591
) -> None: ...
8692
async def setup(self) -> None: ...
8793
async def close(self) -> None: ...
8894
async def get_decryption_aes_key(
89-
self, key: bytes, material_description: Dict[str, Any]
95+
self, key: bytes, material_description: dict[str, Any]
9096
) -> bytes: ...
91-
async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]: ...
97+
async def get_encryption_aes_key(self) -> tuple[bytes, dict[str, str], str]: ...
9298

9399
class S3CSE:
94100
def __init__(
95-
self, crypto_context: CryptoContext, s3_client_args: Optional[Dict[str, Any]] = ...
101+
self, crypto_context: CryptoContext, s3_client_args: dict[str, Any] | None = ...
96102
) -> None: ...
97103
async def setup(self) -> None: ...
98104
async def close(self) -> None: ...
99105
async def __aenter__(self: _R) -> _R: ...
100106
async def __aexit__(
101107
self,
102-
exc_type: Optional[Type[BaseException]],
103-
exc_val: Optional[BaseException],
104-
tb: Optional[TracebackType],
108+
exc_type: type[BaseException] | None,
109+
exc_val: BaseException | None,
110+
tb: TracebackType | None,
105111
) -> None: ...
106-
async def get_object(self, Bucket: str, Key: str, **kwargs: Any) -> Dict[str, Any]: ...
112+
async def get_object(self, Bucket: str, Key: str, **kwargs: Any) -> dict[str, Any]: ...
107113
async def put_object(
108114
self,
109-
Body: Union[bytes, IO[Any]],
115+
Body: bytes | IO[Any],
110116
Bucket: str,
111117
Key: str,
112-
Metadata: Optional[Mapping[str, Any]] = ...,
118+
Metadata: Mapping[str, Any] | None = ...,
113119
**kwargs: Any,
114120
) -> Any: ...

0 commit comments

Comments
 (0)