@@ -41,7 +41,6 @@ class RequirementLevel(Enum):
4141class StabilityLevel (Enum ):
4242 STABLE = 1
4343 EXPERIMENTAL = 2
44- DEPRECATED = 3
4544
4645
4746@dataclass
@@ -82,9 +81,7 @@ def is_enum(self):
8281 return isinstance (self .attr_type , EnumAttributeType )
8382
8483 @staticmethod
85- def parse (
86- prefix , semconv_stability , yaml_attributes
87- ) -> "Dict[str, SemanticAttribute]" :
84+ def parse (prefix , yaml_attributes ) -> "Dict[str, SemanticAttribute]" :
8885 """This method parses the yaml representation for semantic attributes
8986 creating the respective SemanticAttribute objects.
9087 """
@@ -179,21 +176,13 @@ def parse(
179176 raise ValidationError .from_yaml_pos (position , msg )
180177
181178 tag = attribute .get ("tag" , "" ).strip ()
182- stability , deprecated = SemanticAttribute .parse_stability_deprecated (
183- attribute .get ("stability" ), attribute . get ( "deprecated" ), position_data
179+ stability = SemanticAttribute .parse_stability (
180+ attribute .get ("stability" ), position_data
184181 )
185- if (
186- semconv_stability == StabilityLevel .DEPRECATED
187- and stability is not StabilityLevel .DEPRECATED
188- ):
189- position = (
190- position_data ["stability" ]
191- if "stability" in position_data
192- else position_data ["deprecated" ]
193- )
194- msg = f"Semantic convention stability set to deprecated but attribute '{ attr_id } ' is { stability } "
195- raise ValidationError .from_yaml_pos (position , msg )
196- stability = stability or semconv_stability or StabilityLevel .EXPERIMENTAL
182+ deprecated = SemanticAttribute .parse_deprecated (
183+ attribute .get ("deprecated" ), position_data
184+ )
185+
197186 sampling_relevant = (
198187 AttributeType .to_bool ("sampling_relevant" , attribute )
199188 if attribute .get ("sampling_relevant" )
@@ -291,44 +280,31 @@ def parse_attribute(attribute):
291280 return attr_type , str (brief ), examples
292281
293282 @staticmethod
294- def parse_stability_deprecated (stability , deprecated , position_data ):
295- if deprecated is not None and stability is None :
296- stability = "deprecated"
297- if deprecated is not None :
298- if stability is not None and stability != "deprecated" :
299- position = position_data ["deprecated" ]
300- msg = f"There is a deprecation message but the stability is set to '{ stability } '"
301- raise ValidationError .from_yaml_pos (position , msg )
302- if AttributeType .get_type (deprecated ) != "string" or deprecated == "" :
303- position = position_data ["deprecated" ]
304- msg = (
305- "Deprecated field expects a string that specifies why the attribute is deprecated and/or what"
306- " to use instead! "
307- )
308- raise ValidationError .from_yaml_pos (position , msg )
309- deprecated = deprecated .strip ()
310- if stability is not None :
311- stability = SemanticAttribute .check_stability (
312- stability ,
313- position_data ["stability" ]
314- if "stability" in position_data
315- else position_data ["deprecated" ],
316- )
317- return stability , deprecated
318-
319- @staticmethod
320- def check_stability (stability_value , position ):
283+ def parse_stability (stability , position_data ):
284+ if stability is None :
285+ return StabilityLevel .EXPERIMENTAL
321286
322287 stability_value_map = {
323- "deprecated" : StabilityLevel .DEPRECATED ,
324288 "experimental" : StabilityLevel .EXPERIMENTAL ,
325289 "stable" : StabilityLevel .STABLE ,
326290 }
327- val = stability_value_map .get (stability_value )
291+ val = stability_value_map .get (stability )
328292 if val is not None :
329293 return val
330- msg = f"Value '{ stability_value } ' is not allowed as a stability marker"
331- raise ValidationError .from_yaml_pos (position , msg )
294+ msg = f"Value '{ stability } ' is not allowed as a stability marker"
295+ raise ValidationError .from_yaml_pos (position_data ["stability" ], msg )
296+
297+ @staticmethod
298+ def parse_deprecated (deprecated , position_data ):
299+ if deprecated is not None :
300+ if AttributeType .get_type (deprecated ) != "string" or deprecated == "" :
301+ msg = (
302+ "Deprecated field expects a string that specifies why the attribute is deprecated and/or what"
303+ " to use instead! "
304+ )
305+ raise ValidationError .from_yaml_pos (position_data ["deprecated" ], msg )
306+ return deprecated .strip ()
307+ return None
332308
333309 def equivalent_to (self , other : "SemanticAttribute" ):
334310 if self .attr_id is not None :
0 commit comments