sat: disable deprecated warnings in cp_model.py
User can reenable them using: ```py from ortools.sat.python import cp_model cp_model.enable_warnings = True ```
This commit is contained in:
@@ -184,7 +184,7 @@ _IndexOrSeries = Union[pd.Index, pd.Series]
|
||||
|
||||
|
||||
# Helper functions.
|
||||
|
||||
enable_warnings = False
|
||||
|
||||
# warnings.deprecated is python3.13+. Not compatible with Open Source (3.10+).
|
||||
# pylint: disable=g-bare-generic
|
||||
@@ -193,6 +193,7 @@ def deprecated(message: str) -> Callable[[Callable], Callable]:
|
||||
|
||||
def deprecated_decorator(func) -> Callable:
|
||||
def deprecated_func(*args, **kwargs):
|
||||
if enable_warnings:
|
||||
warnings.warn(
|
||||
f"{func.__name__} is a deprecated function. {message}",
|
||||
category=DeprecationWarning,
|
||||
@@ -210,6 +211,7 @@ def deprecated_method(func, old_name: str) -> Callable:
|
||||
"""Wrapper that warns about a deprecated method."""
|
||||
|
||||
def deprecated_func(*args, **kwargs) -> Any:
|
||||
if enable_warnings:
|
||||
warnings.warn(
|
||||
f"{old_name} is a deprecated function. Use {func.__name__} instead.",
|
||||
category=DeprecationWarning,
|
||||
|
||||
Reference in New Issue
Block a user