Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semconv: Usage of Final annotation for Enum attributes is an error #4083

Closed
yangskyboxlabs opened this issue Jul 26, 2024 · 1 comment · Fixed by #4085
Closed

semconv: Usage of Final annotation for Enum attributes is an error #4083

yangskyboxlabs opened this issue Jul 26, 2024 · 1 comment · Fixed by #4085
Labels
bug Something isn't working

Comments

@yangskyboxlabs
Copy link

yangskyboxlabs commented Jul 26, 2024

Describe your environment

opentelemetry-semantic-conventions==0.47b0

What happened?

#3966 added many Final annotations to semantic convention literals.

However, usage of any annotation for Enum member attributes is considered invalid, and a bare Final not being flagged appear to be an edge case that was overlooked in at least pyright: microsoft/pyright#8543 (comment)

This leads to misleading type checker errors.

Steps to Reproduce

Consider:

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)

Additional context

No response

Would you like to implement a fix?

None

@yangskyboxlabs yangskyboxlabs added the bug Something isn't working label Jul 26, 2024
@emdneto
Copy link
Member

emdneto commented Jul 26, 2024

Thanks for reporting it. The Final annotation was previously adopted to detect duplication on constants definitions. Maybe no need to use it in Enums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants