Open sodul opened 2 months ago
Hello! THank you for the report.
Looks like this output type is not compatible with the corresponding input type. I will take a look.
Unfortunately, these types are incompatible. Does rewriting code as
new_rule: LifecycleRuleOutputTypeDef = {
'ID': 'rule_name',
'Expiration': {'Days': 1},
'Filter': {'Prefix': 'prefix'},
'NoncurrentVersionExpiration': {'NoncurrentDays': 1},
'AbortIncompleteMultipartUpload': {'DaysAfterInitiation': 1},
'Status': 'Enabled',
}
work for you?
It does not seem to help. We are going to use # type: ignore
for now:
rules: list[LifecycleRuleTypeDef]
rules = client.get_bucket_lifecycle_configuration( # type: ignore[assignment]
Bucket='bucket_name'
)['Rules']
Not in the example above but the next line we have is:
config: BucketLifecycleConfigurationTypeDef = {'Rules': rules}
And mypy was failing with this error:
Incompatible types (expression has type "list[LifecycleRuleOutputTypeDef]", TypedDict item "Rules" has type "Sequence[LifecycleRuleTypeDef]") [typeddict-item] (1,955:64)
As far as I understand, before you used mypy-boto3-s3 1.34.65
. There was a bug fixed in #244 that incompatible output shapes were used instead of separating output and input shapes in case of conflict.
For this particular shape input and output definitions are not compatible. So, type: ignore
looks like the easiest solution.
pyright
changes the way it compares TypedDicts in https://github.com/microsoft/pyright/releases/tag/1.1.333 release. So, since TypedDicts are invariant, output TypedDict cannot be assigned to an input TypedDict.
I will cross-check again tomorrow.
Describe the bug After upgrading to 1.34.92 (confirmed with 1.34.93) our codebase is getting 2 new mypy errors with:
InventoryConfigurationOutputTypeDef
vsInventoryConfigurationTypeDef
LifecycleRuleOutputTypeDef
vsLifecycleRuleTypeDef
To Reproduce Steps to reproduce the behavior: Add code that works with the output as input. InventoryConfigurationOutputTypeDef, LifecycleRuleOutputTypeDef
boto3-stubs[s3]
mypy
/pyright
on the following code sampleActual output
Expected output
no error
Additional context Your OS macOS and linux,
boto3-stubs
installation method,boto3
version, etc.Relates to #208