diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7e6db10..bc906e0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,10 @@ Change log - Value propagation of string tensors no longer raises an erroneous ``ValueError`` in some instances. +**Deprecation** + +- Importing :func:`spox._future.operator_overloading`` now triggers a ``DeprecationWarning``. The function will be removed in a future release. Consider using ``ndonnx`` as an alternative. + **Other changes** - The adaption logic is not using inferred values as initializers anymore. diff --git a/src/spox/_future.py b/src/spox/_future.py index ecaa5c7..7cd8d0a 100644 --- a/src/spox/_future.py +++ b/src/spox/_future.py @@ -3,6 +3,7 @@ """Module containing experimental Spox features that may be standard in the future.""" +import warnings from collections.abc import Iterable from contextlib import contextmanager from typing import Optional, Union @@ -164,7 +165,7 @@ def not_(self, a: Var) -> Var: @contextmanager -def operator_overloading( +def _operator_overloading( op, type_promotion: bool = False, constant_promotion: bool = True ): """Enable operator overloading on Var for this block. @@ -209,6 +210,17 @@ def operator_overloading( Var._operator_dispatcher = prev_dispatcher +def __getattr__(name): + if name == "operator_overloading": + warnings.warn( + "using 'operator_overloading' is deprecated, consider using https://github.com/Quantco/ndonnx instead", + DeprecationWarning, + ) + return _operator_overloading + + raise AttributeError(f"module {__name__} has no attribute {name}") + + __all__ = [ # Type warning levels "TypeWarningLevel", @@ -220,6 +232,4 @@ def operator_overloading( "ValuePropBackend", "set_value_prop_backend", "value_prop_backend", - # Operator overloading on Var - "operator_overloading", ]