Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Running mypy on sdk resources #773 #4360
base: main
Are you sure you want to change the base?
Running mypy on sdk resources #773 #4360
Changes from 4 commits
3ab4dc7
c38154e
5c6d89b
fc6c6e5
822e841
192db0c
853c00f
2ddbd55
d42a650
99f1ff4
825c727
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be typed, https://github.com/python/importlib_metadata/blob/main/importlib_metadata/__init__.py#L1039C42-L1039C43
Need to check if we are exporting it from our util module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is - https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py#L28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basedpyright: Import "opentelemetry.util._importlib_metadata" could not be resolved. This results in following errors when mypy is executed -
opentelemetry-sdk/src/opentelemetry/sdk/error_handler/init.py:119: error: Type of variable becomes "Any" due to an unfollowed import [no-any-unimported]
opentelemetry-sdk/src/opentelemetry/sdk/error_handler/init.py:119: error: Expression has type "Any" [misc]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xrmx Please let me know if the above errors can be handled differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean something like this
error_handler_entry_points : Entrypoints = entry_points(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok. I added:
I've confirmed.
mypy
cannot findopentelemetry/util
, so it convertsentry_points
toAny
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy: MYPYPATH={toxinidir}/opentelemetry-api/src/:{toxinidir}/opentelemetry-semantic-conventions/src/:{toxinidir}/opentelemetry-sdk/src/:{toxinidir}/tests/opentelemetry-test-utils/src/
includes
{toxinidir}/opentelemetry-api/src/
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so my point is that it should have been found, but it's not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I changed
from importlib_metadata import (
to
from importlib.metadata import (
in https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py
mypy is able to find the imports.
importlib_metadata
is valid for python < 3.8.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update the PR to change
importlib_metadata
toimortlib.metadata
and will removeignore
in the files -opentelemetry-api/src/opentelemetry/context/__init__. opentelemetry-api/src/opentelemetry/propagate/__init__.py opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py opentelemetry-api/src/opentelemetry/util/_providers.py