Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After Pulumi 3.113.0 we started getting Never's for pulumi applied outputs in mypy #16027

Open
rshade opened this issue Apr 22, 2024 · 1 comment
Assignees
Labels
area/sdks Pulumi language SDKs customer/lighthouse Lighthouse customer bugs kind/bug Some behavior is incorrect or out of spec language/python
Milestone

Comments

@rshade
Copy link
Contributor

rshade commented Apr 22, 2024

What happened?

We upgraded an existing stack to pulumi 3.113.0 and mypy started throwing the following errors:

mypy __main__.py
__main__.py:15: error: Argument 1 to "all" of "Output" has incompatible type "Output[str]"; expected "Union[Never, Awaitable[Never], Output[Never]]"  [arg-type]
__main__.py:15: error: Argument 2 to "all" of "Output" has incompatible type "Output[bool]"; expected "Union[Never, Awaitable[Never], Output[Never]]"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)

Example

"""A Random Python Pulumi program"""

from pulumi import Input, Output

should_print: Input[bool] = True
example_text: Input[str] = "hello World"


def example_print(text: str, should_print: bool) -> str:
    if should_print:
        print(text)
    return text


Output.all(Output.from_input(example_text), Output.from_input(should_print)).apply(
    lambda args: example_print(args[0], args[1])
)

Output of pulumi about

pulumi about
CLI
Version 3.113.3
Go Version go1.22.2
Go Compiler gc

Plugins
KIND NAME VERSION
resource aws 6.32.0
language python unknown
resource random 4.16.1

Host
OS ubuntu
Version 20.04
Arch x86_64

This project is written in python: version='3.8.10'

Dependencies:
NAME VERSION
mypy 1.9.0
pip 24.0
pkg_resources 0.0.0
pulumi_aws 6.32.0
pulumi_random 4.16.1
pyright 1.1.359
wheel 0.43.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@rshade rshade added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team customer/lighthouse Lighthouse customer bugs labels Apr 22, 2024
@Frassle Frassle added area/sdks Pulumi language SDKs language/python and removed needs-triage Needs attention from the triage team labels Apr 22, 2024
@Frassle Frassle self-assigned this Apr 22, 2024
@justinvp justinvp added this to the 0.104 milestone Apr 26, 2024
@Frassle
Copy link
Member

Frassle commented May 3, 2024

Output.from_input seems to be the problem:

res1 = MyResource("testResource1")

reveal_type(res1.nested_numbers)
reveal_type(res1.nested_numbers.apply(lambda x: x))
reveal_type(res1.nested_numbers.apply(lambda x: x["foo"]))
reveal_type(Output.from_input(res1.nested_numbers))
reveal_type(Output.from_input(res1.nested_numbers).apply(lambda x: x))
lib/test/langhost/output_nested/__main__.py:48: note: Revealed type is "pulumi.output.Output[builtins.dict[Any, Any]]"
lib/test/langhost/output_nested/__main__.py:49: note: Revealed type is "pulumi.output.Output[builtins.dict[Any, Any]]"
lib/test/langhost/output_nested/__main__.py:50: note: Revealed type is "pulumi.output.Output[Any]"
lib/test/langhost/output_nested/__main__.py:51: note: Revealed type is "pulumi.output.Output[Never]"
lib/test/langhost/output_nested/__main__.py:52: note: Revealed type is "pulumi.output.Output[Never]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdks Pulumi language SDKs customer/lighthouse Lighthouse customer bugs kind/bug Some behavior is incorrect or out of spec language/python
Projects
None yet
Development

No branches or pull requests

3 participants