Skip to content

Commit

Permalink
Handful of mypy fixes in the python test code (#16091)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frassle committed May 2, 2024
1 parent dc12644 commit f0085de
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import pulumi

lst = []
lst: list[int] = []
lst[0]
2 changes: 1 addition & 1 deletion sdk/python/lib/test/langhost/future_failure/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, name, value, opts):

resA = MyResource("resourceA", "foo", None)

fut = asyncio.Future()
fut: asyncio.Future[str] = asyncio.Future()
fut.set_exception(Exception("oh no"))
resB = MyResource("resourceB", fut, ResourceOptions(depends_on=[resA]))

Expand Down
4 changes: 3 additions & 1 deletion sdk/python/lib/test/langhost/large_resource/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import functools
from pulumi import CustomResource
from pulumi import CustomResource, Output

long_string = "a" * 1024 * 1024 * 5


class MyResource(CustomResource):
largeStringProp: Output[str]

def __init__(self, name):
CustomResource.__init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import functools
from pulumi import CustomResource
from pulumi import CustomResource, Output


class MyResource(CustomResource):
outprop: Output[str]
outintprop: Output[int]

def __init__(self, name):
CustomResource.__init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def in_prop(self) -> Optional[pulumi.Input[str]]:

@in_prop.setter
def in_prop(self, value: pulumi.Input[str]):
pulumi.set(self, "in_prop")
pulumi.set(self, "in_prop", value)


class MyResource(pulumi.ComponentResource):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


class MyResource(CustomResource):
outprop: Output[str]

def __init__(self, name, args, opts=None):
CustomResource.__init__(
self,
Expand Down
4 changes: 3 additions & 1 deletion sdk/python/lib/test/langhost/stack_output/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.
import pulumi

from typing import Any, Dict


class TestClass:
def __init__(self):
Expand All @@ -22,7 +24,7 @@ def __init__(self):

my_test_class_instance = TestClass()

recursive = {"a": 1}
recursive: Dict[str, Any] = {"a": 1}
recursive["b"] = 2
recursive["c"] = recursive

Expand Down
6 changes: 3 additions & 3 deletions sdk/python/lib/test/test_next_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,12 @@ async def test_distinguished_unknown_output(self):
self.assertFalse(await out.is_known())

def create_output(self, val: Any, is_known: bool, is_secret: Optional[bool] = None):
fut = asyncio.Future()
fut: asyncio.Future[Any] = asyncio.Future()
fut.set_result(val)
known_fut = asyncio.Future()
known_fut: asyncio.Future[bool] = asyncio.Future()
known_fut.set_result(is_known)
if is_secret is not None:
is_secret_fut = asyncio.Future()
is_secret_fut: asyncio.Future[bool] = asyncio.Future()
is_secret_fut.set_result(True)
return Output(set(), fut, known_fut, is_secret_fut)
return Output(set(), fut, known_fut)
Expand Down
10 changes: 8 additions & 2 deletions sdk/python/lib/test/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ def __init__(
foo: Optional[pulumi.Input[str]] = None,
bar: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
baz: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
nested: Optional[pulumi.Input[pulumi.InputType["NestedArgs"]]] = None
nested: Optional[
pulumi.Input[pulumi.InputType["OutputFromInputTests.NestedArgs"]]
] = None
):
if foo is not None:
pulumi.set(self, "foo", foo)
Expand Down Expand Up @@ -199,7 +201,11 @@ def baz(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:

@property
@pulumi.getter
def nested(self) -> Optional[pulumi.Input[pulumi.InputType["NestedArgs"]]]:
def nested(
self,
) -> Optional[
pulumi.Input[pulumi.InputType["OutputFromInputTests.NestedArgs"]]
]:
return pulumi.get(self, "nested")

@pulumi.input_type
Expand Down

0 comments on commit f0085de

Please sign in to comment.