-
Notifications
You must be signed in to change notification settings - Fork 706
Running mypy on sdk resources #773 #4360
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
3ab4dc7
c38154e
5c6d89b
fc6c6e5
822e841
192db0c
853c00f
2ddbd55
d42a650
99f1ff4
825c727
ce4c3a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -61,6 +61,7 @@ def _handle(self, error: Exception, *args, **kwargs): | |||||
|
||||||
from abc import ABC, abstractmethod | ||||||
from logging import getLogger | ||||||
from typing import Optional | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather prefer to use |
||||||
|
||||||
from opentelemetry.util._importlib_metadata import entry_points | ||||||
|
||||||
|
@@ -69,7 +70,7 @@ def _handle(self, error: Exception, *args, **kwargs): | |||||
|
||||||
class ErrorHandler(ABC): | ||||||
@abstractmethod | ||||||
def _handle(self, error: Exception, *args, **kwargs): | ||||||
def _handle(self, error: Exception, *args, **kwargs) -> None: # type: ignore | ||||||
""" | ||||||
Handle an exception | ||||||
""" | ||||||
|
@@ -83,7 +84,7 @@ class _DefaultErrorHandler(ErrorHandler): | |||||
""" | ||||||
|
||||||
# pylint: disable=useless-return | ||||||
def _handle(self, error: Exception, *args, **kwargs): | ||||||
def _handle(self, error: Exception, *args, **kwargs) -> None: # type: ignore | ||||||
logger.exception("Error handled by default error handler: ") | ||||||
return None | ||||||
|
||||||
|
@@ -105,12 +106,12 @@ def __new__(cls) -> "GlobalErrorHandler": | |||||
|
||||||
return cls._instance | ||||||
|
||||||
def __enter__(self): | ||||||
def __enter__(self) -> None: | ||||||
pass | ||||||
|
||||||
# pylint: disable=no-self-use | ||||||
def __exit__(self, exc_type, exc_value, traceback): | ||||||
if exc_value is None: | ||||||
def __exit__(self, exc_type, exc_value, traceback) -> Optional[bool]: # type: ignore | ||||||
if exc_value is None: # type: ignore | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If above applied, the ignore is not needed.
Suggested change
|
||||||
return None | ||||||
|
||||||
plugin_handled = False | ||||||
|
@@ -120,11 +121,11 @@ def __exit__(self, exc_type, exc_value, traceback): | |||||
) | ||||||
|
||||||
for error_handler_entry_point in error_handler_entry_points: | ||||||
error_handler_class = error_handler_entry_point.load() | ||||||
error_handler_class = error_handler_entry_point.load() # type: ignore | ||||||
|
||||||
if issubclass(error_handler_class, exc_value.__class__): | ||||||
if issubclass(error_handler_class, exc_value.__class__): # type: ignore | ||||||
try: | ||||||
error_handler_class()._handle(exc_value) | ||||||
error_handler_class()._handle(exc_value) # type: ignore | ||||||
plugin_handled = True | ||||||
|
||||||
# pylint: disable=broad-exception-caught | ||||||
|
@@ -133,11 +134,11 @@ def __exit__(self, exc_type, exc_value, traceback): | |||||
"%s error while handling error" | ||||||
" %s by error handler %s", | ||||||
error_handling_error.__class__.__name__, | ||||||
exc_value.__class__.__name__, | ||||||
error_handler_class.__name__, | ||||||
exc_value.__class__.__name__, # type: ignore | ||||||
error_handler_class.__name__, # type: ignore | ||||||
) | ||||||
|
||||||
if not plugin_handled: | ||||||
_DefaultErrorHandler()._handle(exc_value) | ||||||
_DefaultErrorHandler()._handle(exc_value) # type: ignore | ||||||
|
||||||
return True |
Uh oh!
There was an error while loading. Please reload this page.