-
Notifications
You must be signed in to change notification settings - Fork 649
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?
Conversation
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.
Are these changes need to type check sdk resources? We are already checking it AFAICS, per mypy: mypy --install-types --non-interactive --namespace-packages --explicit-package-bases opentelemetry-sdk/src/opentelemetry/sdk/resources
in tox.ini
.
CHANGELOG.md
Outdated
@@ -274,7 +277,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
## Version 1.21.0/0.42b0 (2023-11-01) | |||
|
|||
- Fix `SumAggregation` | |||
 ([#3390](https://github.com/open-telemetry/opentelemetry-python/pull/3390)) | |||
 ([#3390](https://github.com/open-telemetry/opentelemetry-python/pull/3390)) |
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.
Here there is some strange unicode chars instead of a space, the parens should be aligned to the F
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.
Sorry, figured out it was my ide setting.
return None | ||
|
||
plugin_handled = False | ||
|
||
error_handler_entry_points = entry_points( | ||
error_handler_entry_points = entry_points( # type: ignore |
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.
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.
I mean something like this
error_handler_entry_points : Entrypoints = entry_points(
Sorry, I should have added the changes that resulted in the above error.
These errors
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]
are happening after adding the type error_handler_entry_points : Entrypoints = entry_points(
@@ -184,7 +184,7 @@ def collect(self, point_attributes: Attributes) -> List[Exemplar]: | |||
exemplars = [ | |||
e | |||
for e in ( | |||
bucket.collect(point_attributes) | |||
bucket.collect(point_attributes) # type: ignore |
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.
Why we need ignore here?
This does not execute mypy on sdk/src folder. Will add |
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 may be nice to enable https://docs.astral.sh/ruff/rules/blanket-type-ignore/#blanket-type-ignore-pgh003 to make it easier to understand on review what's the purpose of the ignores @xrmx
Description
Addressing running mypy on opentelemetry-sdk iteratively so we don't have to make one big change addressing all mypy issues at once.
Fixes # (issue)
Type of change
Run mypy against SDK resources
How Has This Been Tested?
I executed the following tox commands:
Checklist: