33This module provides the Base Property class.
44"""
55import uuid
6+ import warnings
67
78from . import base
89from . import dtypes
1213from .util import format_cardinality
1314
1415
16+ MSG_VALUE_DEPRECATION = "The attribute 'value' is deprecated and will be removed, " \
17+ "use 'values' instead."
18+
19+
1520def odml_tuple_import (t_count , new_value ):
1621 """
1722 Checks via a heuristic if the values in a string fit the general
@@ -131,6 +136,8 @@ def __init__(self, name=None, values=None, parent=None, unit=None,
131136 self ._values = []
132137 self .values = values
133138 if not values and (value or isinstance (value , (bool , int ))):
139+ # Using stacklevel=2 to avoid file name and code line in the message output.
140+ warnings .warn (MSG_VALUE_DEPRECATION , category = DeprecationWarning , stacklevel = 2 )
134141 self .values = value
135142
136143 self .parent = parent
@@ -285,7 +292,9 @@ def value(self):
285292 """
286293 Deprecated alias of 'values'. Will be removed with the next minor release.
287294 """
288- print ("The attribute 'value' is deprecated. Please use 'values' instead." )
295+ # Using stacklevel=2 to avoid file name and code line in the message output.
296+ warnings .warn (MSG_VALUE_DEPRECATION , category = DeprecationWarning , stacklevel = 2 )
297+
289298 return self .values
290299
291300 @value .setter
@@ -295,7 +304,8 @@ def value(self, new_value):
295304
296305 :param new_value: a single value or list of values.
297306 """
298- print ("The attribute 'value' is deprecated. Please use 'values' instead." )
307+ # Using stacklevel=2 to avoid file name and code line in the message output.
308+ warnings .warn (MSG_VALUE_DEPRECATION , category = DeprecationWarning , stacklevel = 2 )
299309 self .values = new_value
300310
301311 def value_str (self , index = 0 ):
0 commit comments