From 3f5bbe7ba6f0b1285b845895153b4be5a6352e69 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 14:17:30 +0200 Subject: [PATCH 01/13] Updated tooling --- linter-requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linter-requirements.txt b/linter-requirements.txt index 9ba7fa1cf2..4dc125435b 100644 --- a/linter-requirements.txt +++ b/linter-requirements.txt @@ -1,11 +1,11 @@ mypy==1.5.1 black==23.7.0 -flake8==5.0.4 +flake8==6.1.0 types-certifi types-redis types-setuptools pymongo # There is no separate types module. loguru # There is no separate types module. -flake8-bugbear==22.12.6 -pep8-naming==0.13.2 +flake8-bugbear==23.7.10 +pep8-naming==0.13.3 pre-commit # local linting From 9593d1ae41725831e23bb80aaa789eba4e0cfdc1 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 15:14:37 +0200 Subject: [PATCH 02/13] moving back --- linter-requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linter-requirements.txt b/linter-requirements.txt index 4dc125435b..a5037fc8e2 100644 --- a/linter-requirements.txt +++ b/linter-requirements.txt @@ -1,11 +1,11 @@ mypy==1.5.1 black==23.7.0 -flake8==6.1.0 +flake8==5.0.4 types-certifi types-redis types-setuptools pymongo # There is no separate types module. loguru # There is no separate types module. -flake8-bugbear==23.7.10 +flake8-bugbear==22.12.6 pep8-naming==0.13.3 pre-commit # local linting From 634497c61be037de882c3d60b9caddd6772a62ae Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 15:20:13 +0200 Subject: [PATCH 03/13] Trying something --- linter-requirements.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linter-requirements.txt b/linter-requirements.txt index a5037fc8e2..f51c6e6560 100644 --- a/linter-requirements.txt +++ b/linter-requirements.txt @@ -1,11 +1,12 @@ mypy==1.5.1 black==23.7.0 -flake8==5.0.4 +flake8==6.1.0 types-certifi types-redis types-setuptools pymongo # There is no separate types module. loguru # There is no separate types module. -flake8-bugbear==22.12.6 +flake8-bugbear==23.7.10 pep8-naming==0.13.3 pre-commit # local linting +pycodestyle==2.9.1 From 67d8497771f15f92e40bad0031472d7c20ab72d5 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 16:19:45 +0200 Subject: [PATCH 04/13] ping --- linter-requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linter-requirements.txt b/linter-requirements.txt index f51c6e6560..9c975bcc43 100644 --- a/linter-requirements.txt +++ b/linter-requirements.txt @@ -1,6 +1,6 @@ mypy==1.5.1 black==23.7.0 -flake8==6.1.0 +flake8==6.0.0 types-certifi types-redis types-setuptools @@ -9,4 +9,3 @@ loguru # There is no separate types module. flake8-bugbear==23.7.10 pep8-naming==0.13.3 pre-commit # local linting -pycodestyle==2.9.1 From e3c5cb3f54ddffe2084875dfe474f4e763494858 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 16:25:50 +0200 Subject: [PATCH 05/13] ping --- linter-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/linter-requirements.txt b/linter-requirements.txt index 9c975bcc43..e75bc0cf2c 100644 --- a/linter-requirements.txt +++ b/linter-requirements.txt @@ -9,3 +9,4 @@ loguru # There is no separate types module. flake8-bugbear==23.7.10 pep8-naming==0.13.3 pre-commit # local linting +pyflakes==2.5.0 From 4a79f4b0d7398628372ad1a491e5da3fdfe96b27 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 16:28:54 +0200 Subject: [PATCH 06/13] maybe the right pin --- linter-requirements.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/linter-requirements.txt b/linter-requirements.txt index e75bc0cf2c..d1108f8eae 100644 --- a/linter-requirements.txt +++ b/linter-requirements.txt @@ -1,12 +1,11 @@ -mypy==1.5.1 -black==23.7.0 -flake8==6.0.0 +mypy +black +flake8==5.0.4 # flake8 depends on pyflakes>=3.0.0 and this dropped support for Python 2 "# type:" comments types-certifi types-redis types-setuptools pymongo # There is no separate types module. loguru # There is no separate types module. -flake8-bugbear==23.7.10 -pep8-naming==0.13.3 +flake8-bugbear +pep8-naming pre-commit # local linting -pyflakes==2.5.0 From c0fd5be5a87530fa01c79892bd754bfa9d8dcb71 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 16:33:31 +0200 Subject: [PATCH 07/13] Tell dependabot to ignore new flake8 versions --- .github/dependabot.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index eadcd59879..cd65472a76 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,6 +12,9 @@ updates: - dependency-name: pytest versions: - "> 3.7.3" + - dependency-name: flake8 + versions: + - "> 5.0.4" - dependency-name: pytest-cov versions: - "> 2.8.1" @@ -43,6 +46,6 @@ updates: open-pull-requests-limit: 10 - package-ecosystem: "github-actions" directory: "/" - schedule: + schedule: interval: weekly open-pull-requests-limit: 10 From d05d8471d7b8e77a6f5f2ac44a4063e66347c719 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 16:47:31 +0200 Subject: [PATCH 08/13] Fixed linting --- tests/integrations/wsgi/test_wsgi.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/integrations/wsgi/test_wsgi.py b/tests/integrations/wsgi/test_wsgi.py index 3616c7cc2f..0b76bf6887 100644 --- a/tests/integrations/wsgi/test_wsgi.py +++ b/tests/integrations/wsgi/test_wsgi.py @@ -126,21 +126,21 @@ def test_transaction_with_error( sentry_init, crashing_app, capture_events, DictionaryContaining # noqa:N803 ): def dogpark(environ, start_response): - raise Exception("Fetch aborted. The ball was not returned.") + raise ValueError("Fetch aborted. The ball was not returned.") sentry_init(send_default_pii=True, traces_sample_rate=1.0) app = SentryWsgiMiddleware(dogpark) client = Client(app) events = capture_events() - with pytest.raises(Exception): + with pytest.raises(ValueError): client.get("http://dogs.are.great/sit/stay/rollover/") error_event, envelope = events assert error_event["transaction"] == "generic WSGI request" assert error_event["contexts"]["trace"]["op"] == "http.server" - assert error_event["exception"]["values"][0]["type"] == "Exception" + assert error_event["exception"]["values"][0]["type"] == "ValueError" assert error_event["exception"]["values"][0]["mechanism"]["type"] == "wsgi" assert error_event["exception"]["values"][0]["mechanism"]["handled"] is False assert ( @@ -189,14 +189,14 @@ def test_has_trace_if_performance_enabled( ): def dogpark(environ, start_response): capture_message("Attempting to fetch the ball") - raise Exception("Fetch aborted. The ball was not returned.") + raise ValueError("Fetch aborted. The ball was not returned.") sentry_init(traces_sample_rate=1.0) app = SentryWsgiMiddleware(dogpark) client = Client(app) events = capture_events() - with pytest.raises(Exception): + with pytest.raises(ValueError): client.get("http://dogs.are.great/sit/stay/rollover/") msg_event, error_event, transaction_event = events @@ -223,14 +223,14 @@ def test_has_trace_if_performance_disabled( ): def dogpark(environ, start_response): capture_message("Attempting to fetch the ball") - raise Exception("Fetch aborted. The ball was not returned.") + raise ValueError("Fetch aborted. The ball was not returned.") sentry_init() app = SentryWsgiMiddleware(dogpark) client = Client(app) events = capture_events() - with pytest.raises(Exception): + with pytest.raises(ValueError): client.get("http://dogs.are.great/sit/stay/rollover/") msg_event, error_event = events @@ -248,7 +248,7 @@ def test_trace_from_headers_if_performance_enabled( ): def dogpark(environ, start_response): capture_message("Attempting to fetch the ball") - raise Exception("Fetch aborted. The ball was not returned.") + raise ValueError("Fetch aborted. The ball was not returned.") sentry_init(traces_sample_rate=1.0) app = SentryWsgiMiddleware(dogpark) @@ -258,7 +258,7 @@ def dogpark(environ, start_response): trace_id = "582b43a4192642f0b136d5159a501701" sentry_trace_header = "{}-{}-{}".format(trace_id, "6e8f22c393e68f19", 1) - with pytest.raises(Exception): + with pytest.raises(ValueError): client.get( "http://dogs.are.great/sit/stay/rollover/", headers={"sentry-trace": sentry_trace_header}, @@ -286,7 +286,7 @@ def test_trace_from_headers_if_performance_disabled( ): def dogpark(environ, start_response): capture_message("Attempting to fetch the ball") - raise Exception("Fetch aborted. The ball was not returned.") + raise ValueError("Fetch aborted. The ball was not returned.") sentry_init() app = SentryWsgiMiddleware(dogpark) @@ -296,7 +296,7 @@ def dogpark(environ, start_response): trace_id = "582b43a4192642f0b136d5159a501701" sentry_trace_header = "{}-{}-{}".format(trace_id, "6e8f22c393e68f19", 1) - with pytest.raises(Exception): + with pytest.raises(ValueError): client.get( "http://dogs.are.great/sit/stay/rollover/", headers={"sentry-trace": sentry_trace_header}, From c2162fb61074476e3026501783d450778986f07b Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 16:50:56 +0200 Subject: [PATCH 09/13] Fixed more linting --- tests/test_crons.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_crons.py b/tests/test_crons.py index c7c8ea96b4..9ea98df2ac 100644 --- a/tests/test_crons.py +++ b/tests/test_crons.py @@ -61,7 +61,7 @@ def test_decorator_error(sentry_init): with mock.patch( "sentry_sdk.crons.decorator.capture_checkin" ) as fake_capture_checking: - with pytest.raises(Exception): + with pytest.raises(ZeroDivisionError): result = _break_world("Grace") assert "result" not in locals() @@ -109,7 +109,7 @@ def test_contextmanager_error(sentry_init): with mock.patch( "sentry_sdk.crons.decorator.capture_checkin" ) as fake_capture_checking: - with pytest.raises(Exception): + with pytest.raises(ZeroDivisionError): result = _break_world_contextmanager("Grace") assert "result" not in locals() From 7e6088539caac45a03bfdf35d874f1b4a4961da2 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 16:54:04 +0200 Subject: [PATCH 10/13] More linting fixes --- tests/integrations/celery/test_celery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index f97132f1a6..b13e19ebaa 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -375,7 +375,7 @@ def dummy_task(self): # Curious: Cannot use delay() here or py2.7-celery-4.2 crashes res = dummy_task.apply_async() - with pytest.raises(Exception): + with pytest.raises(Exception): # noqa: B017 # Celery 4.1 raises a gibberish exception res.wait() From c4383148f55727aedfa690e8c8d1f2218812823c Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 17:19:04 +0200 Subject: [PATCH 11/13] Even more, the fun never stops --- tests/integrations/logging/test_logging.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integrations/logging/test_logging.py b/tests/integrations/logging/test_logging.py index de1c55e26f..92d0674c09 100644 --- a/tests/integrations/logging/test_logging.py +++ b/tests/integrations/logging/test_logging.py @@ -185,11 +185,11 @@ def test_logging_captured_warnings(sentry_init, capture_events, recwarn): events = capture_events() logging.captureWarnings(True) - warnings.warn("first") - warnings.warn("second") + warnings.warn("first", stacklevel=2) + warnings.warn("second", stacklevel=2) logging.captureWarnings(False) - warnings.warn("third") + warnings.warn("third", stacklevel=2) assert len(events) == 2 From 007dc80f5f3bd9e26215719730be37de34f6c88a Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 17:23:38 +0200 Subject: [PATCH 12/13] fix (or rather ignoring) --- tests/integrations/stdlib/test_httplib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index 8072bf2773..d50bf42e21 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -114,7 +114,7 @@ def test_httplib_misuse(sentry_init, capture_events, request): conn.request("GET", "/200") - with pytest.raises(Exception): + with pytest.raises(Exception): # noqa: B017 # This raises an exception, because we didn't call `getresponse` for # the previous request yet. # From 5ad786f896cbeca8923aec7dc6477cb3c55f3517 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Wed, 6 Sep 2023 17:30:48 +0200 Subject: [PATCH 13/13] Also tell dependabot to ignore jsonschema that do not support Python 2 --- .github/dependabot.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cd65472a76..d375588780 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,9 +12,12 @@ updates: - dependency-name: pytest versions: - "> 3.7.3" - - dependency-name: flake8 + - dependency-name: flake8 # Later versions dropped Python 2 support versions: - "> 5.0.4" + - dependency-name: jsonschema # Later versions dropped Python 2 support + versions: + - "> 3.2.0" - dependency-name: pytest-cov versions: - "> 2.8.1"