orange-airport-64592
11/01/2022, 1:58 AMArgument of type "dict[str, str | int]" cannot be assigned to parameter "variables" of type "Input[Mapping[str, Input[str]]] | None" in function "__init__"
Type "dict[str, str | int]" cannot be assigned to type "Input[Mapping[str, Input[str]]] | None"
"dict[str, str | int]" is incompatible with "Mapping[str, Input[str]]"
TypeVar "_VT_co@Mapping" is covariant
Type "str | int" cannot be assigned to type "Input[str]"
Type "int" cannot be assigned to type "Input[str]"
"dict[str, str | int]" is incompatible with protocol "Awaitable[Mapping[str, Input[str]]]"
"__await__" is not present
"dict[str, str | int]" is incompatible with "Output[Mapping[str, Input[str]]]"
...PylancereportGeneralTypeIssues
This is my code :
aws.lambda_.FunctionEnvironmentArgs(
variables={
"DESTN_BUCKET": s3_zip_log_bucket_name,
"RDS_HOSTNAME": "<http://xxxx.ap-east-1.rds.amazonaws.com|xxxx.ap-east-1.rds.amazonaws.com>",
"RDS_USERNAME": "admin",
"RDS_PASSWORD": db_password,
"RDS_PORT": "3306",
"TTL": 172800,
},
),
I think is need to do that to make dict convert to Input, But I don't know to do
miniature-musician-31262
11/01/2022, 4:23 AMsome_dict = {
"THING": "one",
"OTHER_THING": 2,
}
fn = aws.lambda_.Function("fn",
runtime="python3.9",
handler="handler.handler",
role=role.arn,
code=pulumi.FileArchive("./function"),
environment=aws.lambda_.FunctionEnvironmentArgs(
variables=some_dict,
))
orange-airport-64592
11/01/2022, 5:54 AMsome_dict = {
"THING": "one",
"OTHER_THING": 2,
}
fn = aws.lambda_.Function("fn",
runtime="python3.9",
handler="handler.handler",
role=role.arn,
code=pulumi.FileArchive("./function"),
environment=aws.lambda_.FunctionEnvironmentArgs(
variables=some_dict,
))
I can not understand, It looks like my codes, but it works! Just eluded pylance’s inspection?miniature-musician-31262
11/01/2022, 3:15 PMs3_zip_log_bucket_name
and db_password
values coming from, though? Are they plain strings, or outputs of some other resource?fierce-ability-58936
11/01/2022, 9:34 PM...
"RDS_PORT": "3306",
"TTL": "172800",
...
these will be env vars anyway, so they will be strings.variables = {
"DESTN_BUCKET": "blah",
"RDS_HOSTNAME": "<http://xxxx.ap-east-1.rds.amazonaws.com|xxxx.ap-east-1.rds.amazonaws.com>",
"RDS_USERNAME": "admin",
"RDS_PASSWORD": "blah",
"RDS_PORT": "3306",
"TTL": 172800,
}
then it works.
It seems, the variables type is inferred as dict[str, Unknown]
variables = {
"DES (variable) variables: dict[str, Unknown]
but if you define the type properly, then it becomes an error:
variables: dict[str, str] = {
"DESTN_BUCKET": "blah",
"RDS_HOSTNAME": "<http://xxxx.ap-east-1.rds.amazonaws.com|xxxx.ap-east-1.rds.amazonaws.com>",
"RDS_USERNAME": "admin",
"RDS_PASSWORD": "blah",
"RDS_PORT": "3306",
E "TTL": 172800, ■ Expression of type "dict[str, str | int]" cannot be assigned to declared type "dict[str, str]" "Literal[172800]" is incompatible with "str"
}
Add quotes to TTL and it works 🙂Input[str]
as either str
or Output[str]
In fact, in the SDK it's defined as a Union
Input = Union[T, Awaitable[T], "Output[T]"]
orange-airport-64592
11/02/2022, 2:34 AMs3_zip_log_bucket_name
and db_password
values are string too, I find the key is
"TTL": 172800
When I remove this line, It is fine.fierce-ability-58936
11/02/2022, 7:59 PM