The ``implicit_coercion.py`` module =================================== .. py:module:: ansys.tools.variableinterop.utils.implicit_coercion Summary ------- .. py:currentmodule:: implicit_coercion .. tab-set:: .. tab-item:: Functions .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~implicit_coerce_single` - Attempt to coerce the argument into the given type. * - :py:attr:`~implicit_coerce` - Use to decorate functions using the PEP 484 typing system to try and coerce any Description ----------- Provides utilities for implicitly coercing arbitrary Python objects \ into the appropriate ``IVariableValue`` type. .. !! processed by numpydoc !! Module detail ------------- .. py:function:: implicit_coerce_single(arg: Any, arg_type: type) -> Any Attempt to coerce the argument into the given type. This function uses implicit semantics in that lossy conversions are not considered (such as int64->real64 because precision may be lost). :Parameters: **arg** : :obj:`Any` Object to attempt to convert. **arg_type** : :obj:`type` Type of object to convert to. The type must be ``IVariableValue`` or something derived from it. :Returns: :obj:`Any` Converted object :Raises: :obj:`TypeError` If the argument cannot be converted to the supplied type. .. !! processed by numpydoc !! .. py:function:: implicit_coerce(func: Any) -> Any Use to decorate functions using the PEP 484 typing system to try and coerce any arguments that accept the ``IVariableValue`` type or any derived type into an acceptable value. :Parameters: **func** : :obj:`Any` Function to decorate. :Returns: :obj:`Any` Wrapper function. .. !! processed by numpydoc !!