from opentelemetry.semconv.attributes.otel_attributes import OtelStatusCodeValues
def get_ok() -> OtelStatusCodeValues:
return OtelStatusCodeValues.OK
Expected Result
No type violations in get_ok().
Actual Result
Expression of type "Literal['OK']" is incompatible with return type "OtelStatusCodeValues"
"Literal['OK']" is incompatible with "OtelStatusCodeValues"Pylance[reportReturnType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportReturnType)
Describe your environment
opentelemetry-semantic-conventions==0.47b0
What happened?
https://github.com/open-telemetry/opentelemetry-python/pull/3966 added many
Final
annotations to semantic convention literals.However, usage of any annotation for
Enum
member attributes is considered invalid, and a bareFinal
not being flagged appear to be an edge case that was overlooked in at leastpyright
: https://github.com/microsoft/pyright/issues/8543#issuecomment-2251570823This leads to misleading type checker errors.
Steps to Reproduce
Consider:
Expected Result
No type violations in
get_ok()
.Actual Result
Additional context
No response
Would you like to implement a fix?
None