From fc54bf4f121ba208facb50070590934c553dd40b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:04:58 +0000 Subject: [PATCH 1/2] build(deps): bump black from 22.12.0 to 23.3.0 Bumps [black](https://github.com/psf/black) from 22.12.0 to 23.3.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/22.12.0...23.3.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- linter-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linter-requirements.txt b/linter-requirements.txt index 5e7ec1c52e..66ec7c7d18 100644 --- a/linter-requirements.txt +++ b/linter-requirements.txt @@ -1,5 +1,5 @@ mypy==1.2.0 -black==22.12.0 +black==23.3.0 flake8==5.0.4 types-certifi types-redis From 3bd63832415640f54238308dc86ed11a4b74fdb4 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Wed, 7 Jun 2023 11:01:51 +0200 Subject: [PATCH 2/2] reformat --- sentry_sdk/client.py | 2 +- sentry_sdk/integrations/atexit.py | 1 - sentry_sdk/integrations/django/__init__.py | 3 +-- sentry_sdk/integrations/django/asgi.py | 1 - sentry_sdk/integrations/django/middleware.py | 1 - sentry_sdk/integrations/django/views.py | 1 - sentry_sdk/integrations/starlite.py | 1 - sentry_sdk/integrations/trytond.py | 1 - sentry_sdk/sessions.py | 2 +- tests/integrations/gcp/test_gcp.py | 1 - tests/integrations/grpc/grpc_test_service_pb2.py | 1 - tests/integrations/redis/test_redis.py | 1 - tests/integrations/rediscluster/test_rediscluster.py | 1 - tests/integrations/rq/test_rq.py | 1 - tests/integrations/sqlalchemy/test_sqlalchemy.py | 1 - tests/integrations/stdlib/test_httplib.py | 2 -- tests/test_conftest.py | 3 --- tests/tracing/test_http_headers.py | 1 - tests/tracing/test_sampling.py | 2 -- 19 files changed, 3 insertions(+), 24 deletions(-) diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 204b99ce0c..9ebc177158 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -444,7 +444,7 @@ def _update_session_from_event( if session.user_agent is None: headers = (event.get("request") or {}).get("headers") - for (k, v) in iteritems(headers or {}): + for k, v in iteritems(headers or {}): if k.lower() == "user-agent": user_agent = v break diff --git a/sentry_sdk/integrations/atexit.py b/sentry_sdk/integrations/atexit.py index 225f8e1e3f..af70dd9fc9 100644 --- a/sentry_sdk/integrations/atexit.py +++ b/sentry_sdk/integrations/atexit.py @@ -11,7 +11,6 @@ from sentry_sdk._types import TYPE_CHECKING if TYPE_CHECKING: - from typing import Any from typing import Optional diff --git a/sentry_sdk/integrations/django/__init__.py b/sentry_sdk/integrations/django/__init__.py index 16db058d29..4248a0652c 100644 --- a/sentry_sdk/integrations/django/__init__.py +++ b/sentry_sdk/integrations/django/__init__.py @@ -475,7 +475,6 @@ def _got_request_exception(request=None, **kwargs): hub = Hub.current integration = hub.get_integration(DjangoIntegration) if integration is not None: - if request is not None and integration.transaction_style == "url": with hub.configure_scope() as scope: _attempt_resolve_again(request, scope, integration.transaction_style) @@ -504,7 +503,7 @@ def cookies(self): ] clean_cookies = {} # type: Dict[str, Union[str, AnnotatedValue]] - for (key, val) in self.request.COOKIES.items(): + for key, val in self.request.COOKIES.items(): if key in privacy_cookies: clean_cookies[key] = SENSITIVE_DATA_SUBSTITUTE else: diff --git a/sentry_sdk/integrations/django/asgi.py b/sentry_sdk/integrations/django/asgi.py index 7f40671526..41ebe18e62 100644 --- a/sentry_sdk/integrations/django/asgi.py +++ b/sentry_sdk/integrations/django/asgi.py @@ -61,7 +61,6 @@ def patch_channels_asgi_handler_impl(cls): from sentry_sdk.integrations.django import DjangoIntegration if channels.__version__ < "3.0.0": - old_app = cls.__call__ async def sentry_patched_asgi_handler(self, receive, send): diff --git a/sentry_sdk/integrations/django/middleware.py b/sentry_sdk/integrations/django/middleware.py index 5ef0b0838e..aa8023dbd4 100644 --- a/sentry_sdk/integrations/django/middleware.py +++ b/sentry_sdk/integrations/django/middleware.py @@ -126,7 +126,6 @@ def sentry_wrapped_method(*args, **kwargs): class SentryWrappingMiddleware( _asgi_middleware_mixin_factory(_check_middleware_span) # type: ignore ): - async_capable = getattr(middleware, "async_capable", False) def __init__(self, get_response=None, *args, **kwargs): diff --git a/sentry_sdk/integrations/django/views.py b/sentry_sdk/integrations/django/views.py index 716d738ce8..c1034d0d85 100644 --- a/sentry_sdk/integrations/django/views.py +++ b/sentry_sdk/integrations/django/views.py @@ -49,7 +49,6 @@ def sentry_patched_make_view_atomic(self, *args, **kwargs): integration = hub.get_integration(DjangoIntegration) if integration is not None and integration.middleware_spans: - if ( iscoroutinefunction is not None and wrap_async_view is not None diff --git a/sentry_sdk/integrations/starlite.py b/sentry_sdk/integrations/starlite.py index 2a5a6150bb..62ebc8bddc 100644 --- a/sentry_sdk/integrations/starlite.py +++ b/sentry_sdk/integrations/starlite.py @@ -69,7 +69,6 @@ def patch_app_init() -> None: old__init__ = Starlite.__init__ def injection_wrapper(self: "Starlite", *args: "Any", **kwargs: "Any") -> None: - after_exception = kwargs.pop("after_exception", []) kwargs.update( after_exception=[ diff --git a/sentry_sdk/integrations/trytond.py b/sentry_sdk/integrations/trytond.py index 625c1eeda3..6f1aff2f15 100644 --- a/sentry_sdk/integrations/trytond.py +++ b/sentry_sdk/integrations/trytond.py @@ -22,7 +22,6 @@ def __init__(self): # type: () -> None @staticmethod def setup_once(): # type: () -> None - app.wsgi_app = sentry_sdk.integrations.wsgi.SentryWsgiMiddleware(app.wsgi_app) def error_handler(e): # type: (Exception) -> None diff --git a/sentry_sdk/sessions.py b/sentry_sdk/sessions.py index a8f2aedd99..520fbbc059 100644 --- a/sentry_sdk/sessions.py +++ b/sentry_sdk/sessions.py @@ -93,7 +93,7 @@ def flush(self): envelope.add_session(session) - for (attrs, states) in pending_aggregates.items(): + for attrs, states in pending_aggregates.items(): if len(envelope.items) == MAX_ENVELOPE_ITEMS: self.capture_func(envelope) envelope = Envelope() diff --git a/tests/integrations/gcp/test_gcp.py b/tests/integrations/gcp/test_gcp.py index 938749ccf4..930ee1ffd5 100644 --- a/tests/integrations/gcp/test_gcp.py +++ b/tests/integrations/gcp/test_gcp.py @@ -93,7 +93,6 @@ def init_sdk(timeout_warning=False, **extra_init_args): @pytest.fixture def run_cloud_function(): def inner(code, subprocess_kwargs=()): - events = [] envelopes = [] return_value = None diff --git a/tests/integrations/grpc/grpc_test_service_pb2.py b/tests/integrations/grpc/grpc_test_service_pb2.py index c68f255b4a..94765dae2c 100644 --- a/tests/integrations/grpc/grpc_test_service_pb2.py +++ b/tests/integrations/grpc/grpc_test_service_pb2.py @@ -19,7 +19,6 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "grpc_test_service_pb2", globals()) if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None _GRPCTESTMESSAGE._serialized_start = 45 _GRPCTESTMESSAGE._serialized_end = 76 diff --git a/tests/integrations/redis/test_redis.py b/tests/integrations/redis/test_redis.py index a596319c8b..ad23967873 100644 --- a/tests/integrations/redis/test_redis.py +++ b/tests/integrations/redis/test_redis.py @@ -184,7 +184,6 @@ def test_data_truncation_custom(sentry_init, capture_events): def test_breadcrumbs(sentry_init, capture_events): - sentry_init( integrations=[RedisIntegration(max_data_size=30)], send_default_pii=True, diff --git a/tests/integrations/rediscluster/test_rediscluster.py b/tests/integrations/rediscluster/test_rediscluster.py index d00aeca350..c4b5a8e7d3 100644 --- a/tests/integrations/rediscluster/test_rediscluster.py +++ b/tests/integrations/rediscluster/test_rediscluster.py @@ -14,7 +14,6 @@ @pytest.fixture(autouse=True) def monkeypatch_rediscluster_classes(reset_integrations): - try: pipeline_cls = rediscluster.pipeline.ClusterPipeline except AttributeError: diff --git a/tests/integrations/rq/test_rq.py b/tests/integrations/rq/test_rq.py index fb25b65a03..ac95ae3c24 100644 --- a/tests/integrations/rq/test_rq.py +++ b/tests/integrations/rq/test_rq.py @@ -93,7 +93,6 @@ def test_transport_shutdown(sentry_init, capture_events_forksafe): def test_transaction_with_error( sentry_init, capture_events, DictionaryContaining # noqa:N803 ): - sentry_init(integrations=[RqIntegration()], traces_sample_rate=1.0) events = capture_events() diff --git a/tests/integrations/sqlalchemy/test_sqlalchemy.py b/tests/integrations/sqlalchemy/test_sqlalchemy.py index edeab6e983..064af3c4f1 100644 --- a/tests/integrations/sqlalchemy/test_sqlalchemy.py +++ b/tests/integrations/sqlalchemy/test_sqlalchemy.py @@ -75,7 +75,6 @@ class Address(Base): sys.version_info < (3,), reason="This sqla usage seems to be broken on Py2" ) def test_transactions(sentry_init, capture_events, render_span_tree): - sentry_init( integrations=[SqlalchemyIntegration()], _experiments={"record_sql_params": True}, diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index 769d3dfef5..fe3f1e196f 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -165,7 +165,6 @@ def test_outgoing_trace_headers(sentry_init, monkeypatch): op="greeting.sniff", trace_id="12312012123120121231201212312012", ) as transaction: - HTTPSConnection("www.squirrelchasers.com").request("GET", "/top-chasers") (request_str,) = mock_send.call_args[0] @@ -326,7 +325,6 @@ def test_option_trace_propagation_targets( op="greeting.sniff", trace_id="12312012123120121231201212312012", ) as transaction: - HTTPSConnection(host).request("GET", path) (request_str,) = mock_send.call_args[0] diff --git a/tests/test_conftest.py b/tests/test_conftest.py index 8a2d4cee24..1b006ed12e 100644 --- a/tests/test_conftest.py +++ b/tests/test_conftest.py @@ -24,7 +24,6 @@ def test_string_containing( test_string, expected_result, StringContaining # noqa: N803 ): - assert (test_string == StringContaining("dogs")) is expected_result @@ -49,7 +48,6 @@ def test_string_containing( def test_dictionary_containing( test_dict, expected_result, DictionaryContaining # noqa: N803 ): - assert ( test_dict == DictionaryContaining({"dogs": "yes", "cats": "maybe"}) ) is expected_result @@ -98,7 +96,6 @@ def test_object_described_by( attrs_only_result, ObjectDescribedBy, # noqa: N803 ): - assert ( test_obj == ObjectDescribedBy(type=Dog, attrs={"name": "Maisey", "age": 7}) ) is type_and_attrs_result diff --git a/tests/tracing/test_http_headers.py b/tests/tracing/test_http_headers.py index 46af3c790e..5d4bb2932e 100644 --- a/tests/tracing/test_http_headers.py +++ b/tests/tracing/test_http_headers.py @@ -12,7 +12,6 @@ @pytest.mark.parametrize("sampled", [True, False, None]) def test_to_traceparent(sentry_init, sampled): - transaction = Transaction( name="/interactions/other-dogs/new-dog", op="greeting.sniff", diff --git a/tests/tracing/test_sampling.py b/tests/tracing/test_sampling.py index 6391aeee76..376a4e09dc 100644 --- a/tests/tracing/test_sampling.py +++ b/tests/tracing/test_sampling.py @@ -76,7 +76,6 @@ def test_uses_traces_sample_rate_correctly( sentry_init(traces_sample_rate=traces_sample_rate) with mock.patch.object(random, "random", return_value=0.5): - transaction = start_transaction(name="dogpark") assert transaction.sampled is expected_decision @@ -93,7 +92,6 @@ def test_uses_traces_sampler_return_value_correctly( sentry_init(traces_sampler=mock.Mock(return_value=traces_sampler_return_value)) with mock.patch.object(random, "random", return_value=0.5): - transaction = start_transaction(name="dogpark") assert transaction.sampled is expected_decision