@@ -224,6 +224,24 @@ def _get_class_from_paths(root_cls, some_path: list[str], other_path: list[str])
224
224
return cls , full_path
225
225
226
226
227
+ def _is_deprecated (obj ) -> bool | None :
228
+ """Whether the object is deprecated in a specific Fluent version."""
229
+ if FluentVersion (obj ._version ) >= FluentVersion .v252 :
230
+ # "_deprecated_version" is part of generated data since 25R2
231
+ deprecated_version = getattr (obj , "_deprecated_version" , None )
232
+ else :
233
+ deprecated_version = obj .get_attrs (["deprecated-version" ])
234
+ if deprecated_version :
235
+ deprecated_version = deprecated_version .get ("attrs" , deprecated_version )
236
+ deprecated_version = (
237
+ deprecated_version .get ("deprecated-version" ) if deprecated_version else None
238
+ )
239
+ return deprecated_version and (
240
+ FluentVersion (float (deprecated_version )) <= FluentVersion .v222
241
+ or FluentVersion (obj ._version ) >= FluentVersion (deprecated_version )
242
+ )
243
+
244
+
227
245
class Base :
228
246
"""Provides the base class for settings and command objects.
229
247
@@ -401,19 +419,6 @@ def get_attr(
401
419
return None
402
420
return val
403
421
404
- def _is_deprecated (self ) -> bool :
405
- """Whether the object is deprecated in a specific Fluent version.'"""
406
- deprecated_version = self .get_attrs (["deprecated-version" ])
407
- if deprecated_version :
408
- deprecated_version = deprecated_version .get ("attrs" , deprecated_version )
409
- deprecated_version = (
410
- deprecated_version .get ("deprecated-version" ) if deprecated_version else None
411
- )
412
- return deprecated_version and (
413
- float (deprecated_version ) <= 22.2
414
- or FluentVersion (self ._version ) >= FluentVersion (deprecated_version )
415
- )
416
-
417
422
def is_active (self ) -> bool :
418
423
"""Whether the object is active."""
419
424
attr = self .get_attr (_InlineConstants .is_active )
@@ -950,7 +955,7 @@ def _command_query_name_filter(
950
955
for name in names :
951
956
if name not in excluded and name .startswith (prefix ):
952
957
child = getattr (parent , name )
953
- if child .is_active () and not child . _is_deprecated ():
958
+ if child .is_active () and not _is_deprecated (child ):
954
959
ret .append ([name , child .__class__ .__bases__ [0 ].__name__ , child .__doc__ ])
955
960
return ret
956
961
@@ -1064,7 +1069,7 @@ def get_active_child_names(self):
1064
1069
ret = []
1065
1070
for child_name in self .child_names :
1066
1071
child = getattr (self , child_name )
1067
- if child .is_active () and not child . _is_deprecated ():
1072
+ if child .is_active () and not _is_deprecated (child ):
1068
1073
ret .append (child_name )
1069
1074
return ret
1070
1075
@@ -1073,7 +1078,7 @@ def get_active_command_names(self):
1073
1078
ret = []
1074
1079
for command_name in self .command_names :
1075
1080
command = getattr (self , command_name )
1076
- if command .is_active () and not command . _is_deprecated ():
1081
+ if command .is_active () and not _is_deprecated (command ):
1077
1082
ret .append (command_name )
1078
1083
return ret
1079
1084
@@ -1082,7 +1087,7 @@ def get_active_query_names(self):
1082
1087
ret = []
1083
1088
for query_name in self .query_names :
1084
1089
query = getattr (self , query_name )
1085
- if query .is_active () and not query . _is_deprecated ():
1090
+ if query .is_active () and not _is_deprecated (query ):
1086
1091
ret .append (query_name )
1087
1092
return ret
1088
1093
@@ -1092,7 +1097,8 @@ def __dir__(self):
1092
1097
[
1093
1098
child
1094
1099
for child in self .child_names + self .command_names + self .query_names
1095
- if getattr (self , child )._is_deprecated ()
1100
+ if getattr (self , child ).is_active ()
1101
+ and _is_deprecated (getattr (self , child ))
1096
1102
]
1097
1103
)
1098
1104
@@ -1109,7 +1115,7 @@ def get_completer_info(self, prefix="", excluded=None) -> List[List[str]]:
1109
1115
for child_name in self .child_names :
1110
1116
if child_name not in excluded and child_name .startswith (prefix ):
1111
1117
child = getattr (self , child_name )
1112
- if child .is_active () and not child . _is_deprecated ():
1118
+ if child .is_active () and not _is_deprecated (child ):
1113
1119
ret .append (
1114
1120
[
1115
1121
child_name ,
@@ -1649,7 +1655,8 @@ def __dir__(self):
1649
1655
[
1650
1656
child
1651
1657
for child in self .argument_names
1652
- if getattr (self , child )._is_deprecated ()
1658
+ if getattr (self , child ).is_active ()
1659
+ and _is_deprecated (getattr (self , child ))
1653
1660
]
1654
1661
)
1655
1662
@@ -1666,7 +1673,7 @@ def get_completer_info(self, prefix="", excluded=None) -> List[List[str]]:
1666
1673
for argument_name in self .argument_names :
1667
1674
if argument_name not in excluded and argument_name .startswith (prefix ):
1668
1675
argument = getattr (self , argument_name )
1669
- if argument .is_active () and not argument . _is_deprecated ():
1676
+ if argument .is_active () and not _is_deprecated (argument ):
1670
1677
ret .append (
1671
1678
[
1672
1679
argument_name ,
0 commit comments