Incorrectly typed `aioboto.dynamodb.BatchWriter`
YaraslauZhylko opened this issue ยท 10 comments
Describe the bug
aioboto3.dynamodb.BatchWriter
might be incorrectly typed.
To Reproduce
Steps to reproduce the behavior:
-
Use fully correct and working
aioboto3
code suggested byaioboto3
docs:import aioboto3 session = aioboto3.Session() async with session.resource("dynamodb") as resource: table = await resource.Table("SomeTable") async with table.batch_writer() as batch: await batch.delete_item(Key={"id": "123"}) await batch.delete_item(Key={"id": "456"})
-
Run
mypy
. -
Get an error.
Actual output
test.py:6: error: "Coroutine[Any, Any, Any]" has no attribute "__aenter__" [attr-defined]
test.py:6: error: "Coroutine[Any, Any, Any]" has no attribute "__aexit__" [attr-defined]
Expected output
No errors.
Additional context
- Linux OS
- Python 3.11.4
types-aiobotocore-dynamodb==2.5.2
(generated usingmypy-boto3-builder==7.14.5
).
Thank you for the report!
I added a fix for this. Now Table
is inherited from aioboto3.dynamodb.table.CustomTableResource
, which is annotated in types-aioboto3
package. I will release a fix today.
Fixed in mypy_boto3_builder 7.14.8
. Please test and let me know if it works as it should.
I released a new version of types-aiobotocore-dynamodb 2.5.0.post2
with the hotfix.
This particular error is fixed.
But there seems to be some new issues:
Module "types_aiobotocore_dynamodb.type_defs" has no attribute "UpdateItemOutputTableTypeDef"; maybe "UpdateItemOutputOutputTypeDef"? [attr-defined]
The error is caused by this import:
from types_aiobotocore_dynamodb.type_defs import UpdateItemOutputTableTypeDef
That was not the case in 2.5.0.post1
or 2.5.2
. There was no error importing UpdateItemOutputTableTypeDef
.
Yes, this is due to the new naming introduced in 7.14.7
. All output shapes now have OutputTypeDef
postfix to differentiate them from input shapes. The issue was that some shapes are used both as input (not all keys are required) and as output (all keys are present). To avoid a name clash, I added OutputTypeDef
postfix, even if the underlying shape itself has Output
in the shape name.
Please update your code, the correct name is UpdateItemOutputOutputTypeDef
now.
It does seem to work correctly with the new naming in 2.5.0.post2
. Thanks for fixing it.
Should we expect the fixed to be released in 2.5.3
any time soon?
@YaraslauZhylko yes, I am going to update 2.5.2
as well. No rename required, I am working on a new update that will be compatible with pre-7.14.7
TypeDef
name generation.
@YaraslauZhylko just released types-aiobotocore-dynamodb 2.5.0.post3
. Please test it and let me know if it works as it should.
Also, there is types-aiobotocore-dynamodb 2.5.2.post1
with the fix included.
@vemel 2.5.0.post3
and 2.5.2.post1
work without renaming. ๐
Will there by any other updates today (like 2.5.3
) or should I stay with 2.5.2.post1
for now?
@YaraslauZhylko aiobotocore 2.5.3
has not been released yet. types-aiobotocore
version is always the same as the corresponding aiobotocore
version, plus post releases in case of urgent fixes.
So, 2.5.2.post1
is the latest, no more updates for today.
Feel free to close the issue if it is resolved.