These were found by running `python -m pylint ./lib/test
--rcfile=.pylintrc` in the python SDK folder. Currently we don't
consistently run pylint (or mypy for that matter) against the test
folder and it's built up a number of issues before we can turn it on.
This PR fixes some of the smaller less common ones, a baby step towards
getting the tests fully linted and type checked. Each issue is resolved
in a single commit named for the pylint issue it fixed.
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