Skip to content

Commit

Permalink
Start mypy linting lib/test (#16040)
Browse files Browse the repository at this point in the history
This fixes up a load of '[un]expected return statement' errors in the
tests. Mostly property getters which I've filled in with `pulumi.get`
but some of the tests were explictly checking things worked when the
getter was an empty method body.
  • Loading branch information
Frassle committed Apr 30, 2024
1 parent f35e98e commit 3d37290
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 102 deletions.
4 changes: 2 additions & 2 deletions sdk/python/lib/test/langhost/invoke_types/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def __init__(self, first_value: str, second_value: float):

@property
@pulumi.getter(name="firstValue")
def first_value(self) -> str: ...
def first_value(self) -> str: ... # type: ignore

@property
@pulumi.getter(name="secondValue")
def second_value(self) -> float: ...
def second_value(self) -> float: ... # type: ignore


@pulumi.output_type
Expand Down
28 changes: 14 additions & 14 deletions sdk/python/lib/test/langhost/types/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(
# Property with empty getter/setter bodies.
@property
@pulumi.getter(name="firstValue")
def first_value(self) -> pulumi.Input[str]: ...
def first_value(self) -> pulumi.Input[str]: ... # type: ignore

@first_value.setter
def first_value(self, value: pulumi.Input[str]):
Expand All @@ -203,10 +203,10 @@ def second_value(self, value: Optional[pulumi.Input[float]]):
# passed to the getter decorator.
@property
@pulumi.getter
def third(self) -> Optional[pulumi.Input[str]]: ...
def third(self) -> Optional[pulumi.Input[str]]: ... # type: ignore

@third.setter
def third(self, value: Optional[pulumi.Input[str]]): ...
def third(self, value: Optional[pulumi.Input[str]]): ... # type: ignore

# Another single word property name that doesn't require a name to be
# passed to the getter decorator, this time using the decorator with
Expand All @@ -232,7 +232,7 @@ def __init__(
# Property with empty getter/setter bodies.
@property
@pulumi.getter(name="firstValue")
def first_value(self) -> str: ...
def first_value(self) -> str: ... # type: ignore

# Property with explicitly specified getter/setter bodies.
@property
Expand All @@ -244,14 +244,14 @@ def second_value(self) -> Optional[float]:
# passed to the getter decorator.
@property
@pulumi.getter
def third(self) -> str: ...
def third(self) -> str: ... # type: ignore

# Another single word property name that doesn't require a name to be
# passed to the getter decorator, this time using the decorator with
# parens.
@property
@pulumi.getter
def fourth(self) -> str: ...
def fourth(self) -> str: ... # type: ignore


class SupplementaryResource(pulumi.CustomResource):
Expand Down Expand Up @@ -330,7 +330,7 @@ def __init__(
# Property with empty getter/setter bodies.
@property
@pulumi.getter(name="firstValue")
def first_value(self) -> pulumi.Input[str]: ...
def first_value(self) -> pulumi.Input[str]: ... # type: ignore

@first_value.setter
def first_value(self, value: pulumi.Input[str]):
Expand All @@ -350,20 +350,20 @@ def second_value(self, value: Optional[pulumi.Input[float]]):
# passed to the getter decorator.
@property
@pulumi.getter
def third(self) -> Optional[pulumi.Input[str]]: ...
def third(self) -> Optional[pulumi.Input[str]]: ... # type: ignore

@third.setter
def third(self, value: Optional[pulumi.Input[str]]): ...
def third(self, value: Optional[pulumi.Input[str]]): ... # type: ignore

# Another single word property name that doesn't require a name to be
# passed to the getter decorator, this time using the decorator with
# parens.
@property
@pulumi.getter()
def fourth(self) -> Optional[pulumi.Input[str]]: ...
def fourth(self) -> Optional[pulumi.Input[str]]: ... # type: ignore

@fourth.setter
def fourth(self, value: Optional[pulumi.Input[str]]): ...
def fourth(self, value: Optional[pulumi.Input[str]]): ... # type: ignore


@pulumi.output_type
Expand All @@ -379,7 +379,7 @@ def __init__(
# Property with empty getter/setter bodies.
@property
@pulumi.getter(name="firstValue")
def first_value(self) -> str: ...
def first_value(self) -> str: ... # type: ignore

# Property with explicitly specified getter/setter bodies.
@property
Expand All @@ -391,14 +391,14 @@ def second_value(self) -> Optional[float]:
# passed to the getter decorator.
@property
@pulumi.getter
def third(self) -> str: ...
def third(self) -> str: ... # type: ignore

# Another single word property name that doesn't require a name to be
# passed to the getter decorator, this time using the decorator with
# parens.
@property
@pulumi.getter()
def fourth(self) -> str: ...
def fourth(self) -> str: ... # type: ignore

def _translate_property(self, prop):
return CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop
Expand Down
26 changes: 13 additions & 13 deletions sdk/python/lib/test/test_next_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ def __init__(self, values: list, items: list, keys: list):
# Property with empty body.
@property
@pulumi.getter
def values(self) -> str:
def values(self) -> str: # type: ignore
"""Values docstring."""
...

# Property with empty body.
@property
@pulumi.getter
def items(self) -> str:
def items(self) -> str: # type: ignore
"""Items docstring."""
...

# Property with empty body.
@property
@pulumi.getter
def keys(self) -> str:
def keys(self) -> str: # type: ignore
"""Keys docstring."""
...

Expand Down Expand Up @@ -1350,11 +1350,11 @@ def __init__(self, the_first: str, the_second: Mapping[str, str]):

@property
@pulumi.getter(name="theFirst")
def the_first(self) -> str: ...
def the_first(self) -> str: ... # type: ignore

@property
@pulumi.getter(name="theSecond")
def the_second(self) -> Mapping[str, str]: ...
def the_second(self) -> Mapping[str, str]: ... # type: ignore


@pulumi.input_type
Expand All @@ -1373,15 +1373,15 @@ def __init__(

@property
@pulumi.getter(name="someValue")
def some_value(self) -> pulumi.Input[str]: ...
def some_value(self) -> pulumi.Input[str]: ... # type: ignore

@property
@pulumi.getter(name="someFoo")
def some_foo(self) -> pulumi.Input[pulumi.InputType[SomeFooArgs]]: ...
def some_foo(self) -> pulumi.Input[pulumi.InputType[SomeFooArgs]]: ... # type: ignore

@property
@pulumi.getter(name="someBar")
def some_bar(
def some_bar( # type: ignore
self,
) -> pulumi.Input[Mapping[str, pulumi.Input[pulumi.InputType[SomeFooArgs]]]]: ...

Expand All @@ -1394,11 +1394,11 @@ def __init__(self, the_first: str, the_second: Mapping[str, str]):

@property
@pulumi.getter(name="theFirst")
def the_first(self) -> str: ...
def the_first(self) -> str: ... # type: ignore

@property
@pulumi.getter(name="theSecond")
def the_second(self) -> Mapping[str, str]: ...
def the_second(self) -> Mapping[str, str]: ... # type: ignore


@pulumi.output_type
Expand All @@ -1415,15 +1415,15 @@ def __init__(

@property
@pulumi.getter(name="someValue")
def some_value(self) -> str: ...
def some_value(self) -> str: ... # type: ignore

@property
@pulumi.getter(name="someFoo")
def some_foo(self) -> SomeFooOutput: ...
def some_foo(self) -> SomeFooOutput: ... # type: ignore

@property
@pulumi.getter(name="someBar")
def some_bar(self) -> Mapping[str, SomeFooOutput]: ...
def some_bar(self) -> Mapping[str, SomeFooOutput]: ... # type: ignore


class TypeMetaDataSerializationTests(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/lib/test/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def check_opts(i, name, opts):
res = MockResource(name, opts)
return pulumi.Output.all(dep.urn, res.urn).apply(lambda urns: check(i, urns))

return pulumi.Output.all(
pulumi.Output.all(
[
check_opts(i, f"res{i}", opts)
for i, opts in enumerate(depends_on_variations(dep))
Expand Down

0 comments on commit 3d37290

Please sign in to comment.