pulumi/sdk/python/lib/test
Will Jones e65c2aa368
Don't incorrectly emit deprecated warnings (#16400)
Presently, the Python SDK incorrectly emits deprecation warnings for
properties even if user code does not reference them. This is due to
various pieces of code in the SDK that enumerate properties e.g. for the
purpose of serialisation/RPC calls. In enumerating properties, their
getters are invoked, triggering the deprecation warnings.

There isn't currently a way for us to detect which properties may or may
not be deprecated and handle them appropriately, so this commit
introduces one. Deprecation messages are moved into a new decorator,
`@pulumi.deprecated`. This decorator accepts a `Callable` and wraps it,
making two changes:

* Before the decorated `Callable`'s execution, deprecation messages are
printed.
* The returned `Callable` is tagged with a new reserved property,
`_pulumi_deprecated_callable`, which references the wrapped `Callable`
(that is, the original `Callable` whose invocation will _not_ produce
deprecation warnings).

With this in place, we subsequently make the following two changes:

* We modify the SDK enumeration code (specifically that in
`input_type_to_dict` to check for `_pulumi_deprecated_callable`
properties and use them where appropriate to invoke getters without
triggering deprecation warnings.
* We modify Python code generation so that instead of emitting
statements to print deprecation warnings, we simply emit applications of
the `@pulumi.deprecated` decorator instead.

This commit adds some Python unit tests to exercise the decorator and
manual testing has been performed using the AWS Classic SDK.

Fixes #15894
2024-06-17 16:04:55 +00:00
..
automation Add removeStack options to NodeJS Auto API SDK (#16333) 2024-06-14 08:35:06 +00:00
data/lazy_import_test [sdk/python] Workaround lazy module regression (#16038) 2024-04-24 06:53:59 +00:00
langhost Handful of mypy fixes in the python test code (#16091) 2024-05-02 17:46:52 +00:00
provider Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
runtime Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
__init__.py Fix a couple of issues when projecting Protobuf and UNKNOWN in Python (#1468) 2018-06-06 16:09:07 -07:00
conftest.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
helpers.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_broken_dynamic_provider.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_config.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_deprecated.py Don't incorrectly emit deprecated warnings (#16400) 2024-06-17 16:04:55 +00:00
test_invoke.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_monitor_termination.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_next_serialize.py More descriptive exception in serialize_property (#16098) 2024-05-10 11:34:18 +00:00
test_output.py Handful of mypy fixes in the python test code (#16091) 2024-05-02 17:46:52 +00:00
test_resource.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_runtime_to_json.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_stack_reference.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_stack_registers_outputs.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_translate_output_properties.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_types_input_type.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_types_input_type_types.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_types_output_type.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_types_resource_types.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00
test_urn.py Use black to format lib/test (#16028) 2024-04-23 08:29:58 +00:00
test_utils.py Start mypy linting lib/test (#16040) 2024-04-30 12:54:13 +00:00