@@ -329,20 +329,19 @@ def is_active(self) -> bool:
329329 attr = self .get_attr (_InlineConstants .is_active )
330330 return False if attr is False else True
331331
332- def _is_stable (self ) -> bool :
332+ def _check_stable (self ) -> None :
333333 """Whether the object is stable."""
334- if self .is_active ():
335- attr = self .get_attr (_InlineConstants .is_stable )
336- else :
337- attr = True
338- attr = False if attr is False else True
339- if attr is False :
334+ if not self .is_active ():
335+ return
336+ attr = self .get_attr (_InlineConstants .is_stable )
337+ attr = True if attr is None else attr
338+ if not attr :
340339 warnings .warn (
341- f"The API feature at { self .path } is not stable. "
340+ f"The API feature at ' { self .path } ' is not stable. "
342341 f"It is not guaranteed that it is fully validated and "
343- f"there is no commitment to its backwards compatibility."
342+ f"there is no commitment to its backwards compatibility." ,
343+ UnstableSettingWarning ,
344344 )
345- return attr
346345
347346 def is_read_only (self ) -> bool :
348347 """Whether the object is read-only."""
@@ -520,6 +519,12 @@ class DeprecatedSettingWarning(FutureWarning):
520519 pass
521520
522521
522+ class UnstableSettingWarning (UserWarning ):
523+ """Provides unstable settings warning."""
524+
525+ pass
526+
527+
523528_show_warning_orig = warnings .showwarning
524529
525530
@@ -991,24 +996,26 @@ def get_completer_info(self, prefix="", excluded=None) -> List[List[str]]:
991996 return ret
992997
993998 def _get_parent_of_active_child_names (self , name ):
994- parents = ""
995- path_list = []
996- for parent in self .get_active_child_names ():
997- try :
998- if hasattr (getattr (self , parent ), str (name )):
999- path_list .append (f" { self .python_path } .{ parent } .{ str (name )} " )
1000- if len (parents ) != 0 :
1001- parents += ", " + parent
1002- else :
1003- parents += parent
1004- except AttributeError :
1005- pass
1006- if len (path_list ):
1007- print (f"\n { str (name )} can be accessed from the following paths: \n " )
1008- for path in path_list :
1009- print (path )
1010- if len (parents ):
1011- return f"\n { name } is a child of { parents } \n "
999+ with warnings .catch_warnings ():
1000+ warnings .filterwarnings (action = "ignore" , category = UnstableSettingWarning )
1001+ parents = ""
1002+ path_list = []
1003+ for parent in self .get_active_child_names ():
1004+ try :
1005+ if hasattr (getattr (self , parent ), str (name )):
1006+ path_list .append (f" { self .python_path } .{ parent } .{ str (name )} " )
1007+ if len (parents ) != 0 :
1008+ parents += ", " + parent
1009+ else :
1010+ parents += parent
1011+ except AttributeError :
1012+ pass
1013+ if len (path_list ):
1014+ print (f"\n { str (name )} can be accessed from the following paths: \n " )
1015+ for path in path_list :
1016+ print (path )
1017+ if len (parents ):
1018+ return f"\n { name } is a child of { parents } \n "
10121019
10131020 def __getattribute__ (self , name ):
10141021 if name in super ().__getattribute__ ("child_names" ):
@@ -1024,7 +1031,10 @@ def __getattribute__(self, name):
10241031 )
10251032 return alias_obj
10261033 try :
1027- return super ().__getattribute__ (name )
1034+ attr = super ().__getattribute__ (name )
1035+ if name in super ().__getattribute__ ("_child_classes" ):
1036+ attr ._check_stable ()
1037+ return attr
10281038 except AttributeError as ex :
10291039 self ._get_parent_of_active_child_names (name )
10301040 error_msg = allowed_name_error_message (
0 commit comments