Skip to content

Commit ed92e5a

Browse files
committed
Ruff format
1 parent 55d5f61 commit ed92e5a

File tree

24 files changed

+159
-57
lines changed

24 files changed

+159
-57
lines changed

newrelic/core/agent_control_health.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,8 @@ def update_to_healthy_status(self, protocol_error=False, collector_error=False):
172172
# session. This function allows us to update to a healthy status if so based on the error type
173173
# Since this function is only called when we are in scenario where the agent functioned as expected, we check to
174174
# see if the previous status was unhealthy so we know to update it
175-
if (
176-
(protocol_error
177-
and self.status_code in PROTOCOL_ERROR_CODES)
178-
or (collector_error
179-
and self.status_code == HealthStatus.FAILED_NR_CONNECTION.value)
175+
if (protocol_error and self.status_code in PROTOCOL_ERROR_CODES) or (
176+
collector_error and self.status_code == HealthStatus.FAILED_NR_CONNECTION.value
180177
):
181178
self.status_code = HealthStatus.HEALTHY.value
182179
self.status_message = HEALTHY_STATUS_MESSAGE

tests/agent_features/_test_code_level_metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ def __call__(self):
7272
TYPE_CONSTRUCTOR_CLASS_INSTANCE = ExerciseTypeConstructor()
7373
TYPE_CONSTRUCTOR_CALLABLE_CLASS_INSTANCE = ExerciseTypeConstructorCallable()
7474

75-
exercise_lambda = lambda: None # noqa: E731
75+
exercise_lambda = lambda: None
7676
exercise_partial = functools.partial(exercise_function)

tests/agent_features/test_distributed_tracing.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ def test_distributed_trace_attributes(span_events, accept_payload):
141141
_forgone_error_attributes = {"intrinsic": _forgone_error_intrinsics, "agent": [], "user": []}
142142
else:
143143
_required_intrinsics = distributed_trace_intrinsics
144-
_forgone_txn_intrinsics = _forgone_error_intrinsics = [*inbound_payload_intrinsics, "grandparentId", "parentId", "parentSpanId"]
144+
_forgone_txn_intrinsics = _forgone_error_intrinsics = [
145+
*inbound_payload_intrinsics,
146+
"grandparentId",
147+
"parentId",
148+
"parentSpanId",
149+
]
145150

146151
_required_attributes = {"intrinsic": _required_intrinsics, "agent": [], "user": []}
147152
_forgone_txn_attributes = {"intrinsic": _forgone_txn_intrinsics, "agent": [], "user": []}

tests/component_graphqlserver/test_graphql.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,26 @@ def test_query_and_mutation(target_application):
102102
("GraphQL/operation/GraphQLServer/query/<anonymous>/storage", 1),
103103
(_view_metrics[framework], 1),
104104
]
105-
_test_query_unscoped_metrics = [("GraphQL/all", 1), ("GraphQL/GraphQLServer/all", 1), ("GraphQL/allWeb", 1), ("GraphQL/GraphQLServer/allWeb", 1), *_test_query_scoped_metrics]
105+
_test_query_unscoped_metrics = [
106+
("GraphQL/all", 1),
107+
("GraphQL/GraphQLServer/all", 1),
108+
("GraphQL/allWeb", 1),
109+
("GraphQL/GraphQLServer/allWeb", 1),
110+
*_test_query_scoped_metrics,
111+
]
106112

107113
_test_mutation_scoped_metrics = [
108114
("GraphQL/resolve/GraphQLServer/storage_add", 1),
109115
("GraphQL/operation/GraphQLServer/mutation/<anonymous>/storage_add", 1),
110116
(_view_metrics[framework], 1),
111117
]
112-
_test_mutation_unscoped_metrics = [("GraphQL/all", 1), ("GraphQL/GraphQLServer/all", 1), ("GraphQL/allWeb", 1), ("GraphQL/GraphQLServer/allWeb", 1), *_test_mutation_scoped_metrics]
118+
_test_mutation_unscoped_metrics = [
119+
("GraphQL/all", 1),
120+
("GraphQL/GraphQLServer/all", 1),
121+
("GraphQL/allWeb", 1),
122+
("GraphQL/GraphQLServer/allWeb", 1),
123+
*_test_mutation_scoped_metrics,
124+
]
113125

114126
_expected_mutation_operation_attributes = {
115127
"graphql.operation.type": "mutation",
@@ -204,7 +216,12 @@ def test_exception_in_middleware(target_application):
204216
(f"GraphQL/operation/GraphQLServer/query/MyQuery/{field}", 1),
205217
(f"GraphQL/resolve/GraphQLServer/{field}", 1),
206218
]
207-
_test_exception_rollup_metrics = [("Errors/all", 1), ("Errors/allWeb", 1), ("Errors/WebTransaction/GraphQL/component_graphqlserver.test_graphql:error_middleware", 1), *_test_exception_scoped_metrics]
219+
_test_exception_rollup_metrics = [
220+
("Errors/all", 1),
221+
("Errors/allWeb", 1),
222+
("Errors/WebTransaction/GraphQL/component_graphqlserver.test_graphql:error_middleware", 1),
223+
*_test_exception_scoped_metrics,
224+
]
208225

209226
# Attributes
210227
_expected_exception_resolver_attributes = {
@@ -247,7 +264,12 @@ def test_exception_in_resolver(target_application, field):
247264
(f"GraphQL/operation/GraphQLServer/query/MyQuery/{field}", 1),
248265
(f"GraphQL/resolve/GraphQLServer/{field}", 1),
249266
]
250-
_test_exception_rollup_metrics = [("Errors/all", 1), ("Errors/allWeb", 1), (f"Errors/WebTransaction/GraphQL/{txn_name}", 1), *_test_exception_scoped_metrics]
267+
_test_exception_rollup_metrics = [
268+
("Errors/all", 1),
269+
("Errors/allWeb", 1),
270+
(f"Errors/WebTransaction/GraphQL/{txn_name}", 1),
271+
*_test_exception_scoped_metrics,
272+
]
251273

252274
# Attributes
253275
_expected_exception_resolver_attributes = {
@@ -302,7 +324,12 @@ def test_exception_in_validation(target_application, is_graphql_2, query, exc_cl
302324
exc_class = callable_name(GraphQLError)
303325

304326
_test_exception_scoped_metrics = [("GraphQL/operation/GraphQLServer/<unknown>/<anonymous>/<unknown>", 1)]
305-
_test_exception_rollup_metrics = [("Errors/all", 1), ("Errors/allWeb", 1), (f"Errors/WebTransaction/GraphQL/{txn_name}", 1), *_test_exception_scoped_metrics]
327+
_test_exception_rollup_metrics = [
328+
("Errors/all", 1),
329+
("Errors/allWeb", 1),
330+
(f"Errors/WebTransaction/GraphQL/{txn_name}", 1),
331+
*_test_exception_scoped_metrics,
332+
]
306333

307334
# Attributes
308335
_expected_exception_operation_attributes = {

tests/datastore_aredis/test_trace_node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,26 @@ async def _exercise_db():
8080
@override_application_settings(_enable_instance_settings)
8181
@validate_tt_collector_json(datastore_params=_enabled_required, datastore_forgone_params=_enabled_forgone)
8282
@background_task()
83-
def test_trace_node_datastore_params_enable_instance(loop): # noqa: F811
83+
def test_trace_node_datastore_params_enable_instance(loop):
8484
loop.run_until_complete(_exercise_db())
8585

8686

8787
@override_application_settings(_disable_instance_settings)
8888
@validate_tt_collector_json(datastore_params=_disabled_required, datastore_forgone_params=_disabled_forgone)
8989
@background_task()
90-
def test_trace_node_datastore_params_disable_instance(loop): # noqa: F811
90+
def test_trace_node_datastore_params_disable_instance(loop):
9191
loop.run_until_complete(_exercise_db())
9292

9393

9494
@override_application_settings(_instance_only_settings)
9595
@validate_tt_collector_json(datastore_params=_instance_only_required, datastore_forgone_params=_instance_only_forgone)
9696
@background_task()
97-
def test_trace_node_datastore_params_instance_only(loop): # noqa: F811
97+
def test_trace_node_datastore_params_instance_only(loop):
9898
loop.run_until_complete(_exercise_db())
9999

100100

101101
@override_application_settings(_database_only_settings)
102102
@validate_tt_collector_json(datastore_params=_database_only_required, datastore_forgone_params=_database_only_forgone)
103103
@background_task()
104-
def test_trace_node_datastore_params_database_only(loop): # noqa: F811
104+
def test_trace_node_datastore_params_database_only(loop):
105105
loop.run_until_complete(_exercise_db())

tests/datastore_elasticsearch/test_async_mget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import pytest
1616
from conftest import ES_MULTIPLE_SETTINGS, ES_VERSION
1717
from elasticsearch import AsyncElasticsearch
18-
from testing_support.fixture.event_loop import event_loop as loop # noqa: F401
18+
from testing_support.fixture.event_loop import event_loop as loop
1919
from testing_support.fixtures import override_application_settings
2020
from testing_support.util import instance_hostname
2121
from testing_support.validators.validate_transaction_metrics import validate_transaction_metrics

tests/datastore_elasticsearch/test_async_trace_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
from conftest import ES_SETTINGS, ES_VERSION
16-
from testing_support.fixture.event_loop import event_loop as loop # noqa: F401
16+
from testing_support.fixture.event_loop import event_loop as loop
1717
from testing_support.fixtures import override_application_settings, validate_tt_parenting
1818
from testing_support.util import instance_hostname
1919
from testing_support.validators.validate_tt_collector_json import validate_tt_collector_json

tests/external_aiobotocore/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class MotoService:
6969

7070
_services = {} # {name: instance}
7171

72-
def __init__(self, service_name, port = None, ssl = False):
72+
def __init__(self, service_name, port=None, ssl=False):
7373
self._service_name = service_name
7474

7575
if port:

tests/external_aiobotocore/test_bedrock_chat_completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
chat_completion_streaming_expected_events,
3434
)
3535
from testing_support.fixtures import override_llm_token_callback_settings, reset_core_stats_engine, validate_attributes
36-
from testing_support.ml_testing_utils import ( # noqa: F401
36+
from testing_support.ml_testing_utils import (
3737
add_token_count_to_events,
3838
disabled_ai_monitoring_record_content_settings,
3939
disabled_ai_monitoring_settings,

tests/external_aiobotocore/test_bedrock_embeddings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
embedding_payload_templates,
2727
)
2828
from testing_support.fixtures import override_llm_token_callback_settings, reset_core_stats_engine, validate_attributes
29-
from testing_support.ml_testing_utils import ( # noqa: F401
29+
from testing_support.ml_testing_utils import (
3030
add_token_count_to_events,
3131
disabled_ai_monitoring_record_content_settings,
3232
disabled_ai_monitoring_settings,

0 commit comments

Comments
 (0)