Skip to content

Commit e640956

Browse files
authored
Reenable pylint broad exception (#2536)
1 parent c1a51fd commit e640956

File tree

8 files changed

+20
-13
lines changed

8 files changed

+20
-13
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,4 +492,4 @@ min-public-methods=2
492492

493493
# Exceptions that will emit a warning when being caught. Defaults to
494494
# "Exception".
495-
overgeneral-exceptions=Exception
495+
overgeneral-exceptions=builtins.Exception

instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from unittest.mock import MagicMock
1818

1919
import aiopg
20+
import psycopg2
2021

2122
import opentelemetry.instrumentation.aiopg
2223
from opentelemetry import trace as trace_api
@@ -384,7 +385,9 @@ def test_span_failed(self):
384385
span.attributes[SpanAttributes.DB_STATEMENT], "Test query"
385386
)
386387
self.assertIs(span.status.status_code, trace_api.StatusCode.ERROR)
387-
self.assertEqual(span.status.description, "Exception: Test Exception")
388+
self.assertEqual(
389+
span.status.description, "ProgrammingError: Test Exception"
390+
)
388391

389392
def test_executemany(self):
390393
db_integration = AiopgIntegration(self.tracer, "testcomponent")
@@ -570,17 +573,17 @@ class MockCursor:
570573
# pylint: disable=unused-argument, no-self-use
571574
async def execute(self, query, params=None, throw_exception=False):
572575
if throw_exception:
573-
raise Exception("Test Exception")
576+
raise psycopg2.ProgrammingError("Test Exception")
574577

575578
# pylint: disable=unused-argument, no-self-use
576579
async def executemany(self, query, params=None, throw_exception=False):
577580
if throw_exception:
578-
raise Exception("Test Exception")
581+
raise psycopg2.ProgrammingError("Test Exception")
579582

580583
# pylint: disable=unused-argument, no-self-use
581584
async def callproc(self, query, params=None, throw_exception=False):
582585
if throw_exception:
583-
raise Exception("Test Exception")
586+
raise psycopg2.ProgrammingError("Test Exception")
584587

585588
def close(self):
586589
pass

instrumentation/opentelemetry-instrumentation-aws-lambda/tests/mocks/lambda_function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def rest_api_handler(event, context):
2222

2323

2424
def handler_exc(event, context):
25+
# pylint: disable=broad-exception-raised
2526
raise Exception("500 internal server error")

instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,16 +419,19 @@ def __init__(self) -> None:
419419
# pylint: disable=unused-argument, no-self-use
420420
def execute(self, query, params=None, throw_exception=False):
421421
if throw_exception:
422+
# pylint: disable=broad-exception-raised
422423
raise Exception("Test Exception")
423424

424425
# pylint: disable=unused-argument, no-self-use
425426
def executemany(self, query, params=None, throw_exception=False):
426427
if throw_exception:
428+
# pylint: disable=broad-exception-raised
427429
raise Exception("Test Exception")
428430
self.query = query
429431
self.params = params
430432

431433
# pylint: disable=unused-argument, no-self-use
432434
def callproc(self, query, params=None, throw_exception=False):
433435
if throw_exception:
436+
# pylint: disable=broad-exception-raised
434437
raise Exception("Test Exception")

instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_client_interceptor_hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def response_hook(span, response):
4747

4848

4949
def request_hook_with_exception(_span, _request):
50-
raise Exception()
50+
raise Exception() # pylint: disable=broad-exception-raised
5151

5252

5353
def response_hook_with_exception(_span, _response):
54-
raise Exception()
54+
raise Exception() # pylint: disable=broad-exception-raised
5555

5656

5757
@pytest.mark.asyncio

instrumentation/opentelemetry-instrumentation-grpc/tests/test_client_interceptor_hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ def response_hook(span, response):
7373

7474

7575
def request_hook_with_exception(_span, _request):
76-
raise Exception()
76+
raise Exception() # pylint: disable=broad-exception-raised
7777

7878

7979
def response_hook_with_exception(_span, _response):
80-
raise Exception()
80+
raise Exception() # pylint: disable=broad-exception-raised
8181

8282

8383
class TestHooks(TestBase):

instrumentation/opentelemetry-instrumentation-psycopg/tests/test_psycopg_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ def __init__(self, *args, **kwargs):
5353
# pylint: disable=unused-argument, no-self-use
5454
async def execute(self, query, params=None, throw_exception=False):
5555
if throw_exception:
56-
raise Exception("Test Exception")
56+
raise psycopg.Error("Test Exception")
5757

5858
# pylint: disable=unused-argument, no-self-use
5959
async def executemany(self, query, params=None, throw_exception=False):
6060
if throw_exception:
61-
raise Exception("Test Exception")
61+
raise psycopg.Error("Test Exception")
6262

6363
# pylint: disable=unused-argument, no-self-use
6464
async def callproc(self, query, params=None, throw_exception=False):
6565
if throw_exception:
66-
raise Exception("Test Exception")
66+
raise psycopg.Error("Test Exception")
6767

6868
async def __aenter__(self, *args, **kwargs):
6969
return self

instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def timeout_exception_callback(*_, **__):
9999

100100
@staticmethod
101101
def base_exception_callback(*_, **__):
102-
raise Exception("test")
102+
raise Exception("test") # pylint: disable=broad-exception-raised
103103

104104
def assert_span(self, exporter=None, num_spans=1):
105105
if exporter is None:

0 commit comments

Comments
 (0)