-
Notifications
You must be signed in to change notification settings - Fork 628
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
Improve type hints in opentelemetry.instrumentation.utils
#3128
base: main
Are you sure you want to change the base?
Improve type hints in opentelemetry.instrumentation.utils
#3128
Conversation
@@ -44,9 +44,9 @@ | |||
|
|||
|
|||
def extract_attributes_from_object( | |||
obj: any, attributes: Sequence[str], existing: Dict[str, str] = None | |||
obj: Any, attributes: Sequence[str], existing: Dict[str, str] | None = None |
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 is the most important change. any
cannot be used as Any
.
@@ -81,7 +83,7 @@ def http_status_to_status_code( | |||
return StatusCode.ERROR | |||
|
|||
|
|||
def unwrap(obj: Union[object, str], attr: str): | |||
def unwrap(obj: object, attr: str): |
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's a type of redundancy here, since str
is an object
.
But on the first line of this function, the type checker is able to infer if it's a str
or 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.
The union has been added for humans more than for type checkers
No description provided.