I get this flycheck error pointing to the runtime=_lambda..
variable:
Argument of type "(cls: Runtime) -> Runtime" cannot be assigned to parameter "runtime" of type "Runtime" in function "__init__" Type "(cls: Runtime) -> Runtime" cannot be assigned to type "Runtime"
# create lambda function
# executed as root
function = _lambda.Function(self,
"lambda_function",
runtime=_lambda.Runtime.PYTHON_3_7,
handler="lambda_handler.main",
code=_lambda.Code.from_asset("./lambda"),
environment={
'EC2_INSTANCE_ID':
instance.instance_id,
'S3_OUTPUT':
output_s3.s3_url_for_object(),
'S3_INPUT':
input_s3.s3_url_for_object()
})
It's a rather cosmetic IDE issue, the code itself works
This was a bug in jsii
, the library CDK uses to transpile TypeScript (the language in which CDK is written) to Python.
Here is the PR that fixed it. The fix was released in 1.64.0
If you are using a version before 1.64.0, you can use casting to suppress the error:
import typing
...
function = lambda_.Function(
self,
"function",
...
runtime=typing.cast(lambda_.Runtime, lambda_.Runtime.PYTHON_3_7)
)
Or just append # type: ignore
to the end of the line to disable type checking on that particular line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With