Skip to content

Commit 5ac38d7

Browse files
authored
Merge branch 'main' into fix-ruff-lint
2 parents 9174981 + 5f4be34 commit 5ac38d7

8 files changed

Lines changed: 76 additions & 283 deletions

File tree

.github/workflows/mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
id: ml
4242
# You can override MegaLinter flavor used to have faster performances
4343
# More info at https://megalinter.io/flavors/
44-
uses: oxsecurity/megalinter/flavors/python@ec124f7998718d79379a3c5b39f5359952baf21d # 8.4.2
44+
uses: oxsecurity/megalinter/flavors/python@146333030da68e2e58c6ff826633824fabe01eaf # 8.5.0
4545
env:
4646
# All available variables are described in documentation
4747
# https://megalinter.io/configuration/

.mega-linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be
1919
- YAML_V8R
2020
- YAML_YAMLLINT
2121

22+
PYTHON_DEFAULT_STYLE: ruff
2223
PYTHON_RUFF_CONFIG_FILE: pyproject.toml
2324
PYTHON_RUFF_FORMAT_CONFIG_FILE: pyproject.toml
2425
MARKDOWN_MARKDOWN_LINK_CHECK_FILTER_REGEX_EXCLUDE: "tests/.*"

newrelic/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3983,7 +3983,9 @@ def _process_module_builtin_defaults():
39833983
)
39843984
_process_module_definition("gearman.worker", "newrelic.hooks.application_gearman", "instrument_gearman_worker")
39853985

3986-
_process_module_definition("aiobotocore.client", "newrelic.hooks.external_aiobotocore", "instrument_aiobotocore_client")
3986+
_process_module_definition(
3987+
"aiobotocore.client", "newrelic.hooks.external_aiobotocore", "instrument_aiobotocore_client"
3988+
)
39873989

39883990
_process_module_definition(
39893991
"aiobotocore.endpoint", "newrelic.hooks.external_aiobotocore", "instrument_aiobotocore_endpoint"

newrelic/hooks/external_aiobotocore.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Copyright 2010 New Relic, Inc.
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");

newrelic/hooks/external_botocore.py

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ def extract_firehose_agent_attrs(instance, *args, **kwargs):
137137
region = instance._client_config.region_name
138138
if account_id and region:
139139
agent_attrs["cloud.platform"] = "aws_kinesis_delivery_streams"
140-
agent_attrs[
141-
"cloud.resource_id"
142-
] = f"arn:aws:firehose:{region}:{account_id}:deliverystream/{stream_name}"
140+
agent_attrs["cloud.resource_id"] = (
141+
f"arn:aws:firehose:{region}:{account_id}:deliverystream/{stream_name}"
142+
)
143143
except Exception as e:
144144
_logger.debug("Failed to capture AWS Kinesis Delivery Stream (Firehose) info.", exc_info=True)
145145
return agent_attrs
@@ -497,18 +497,8 @@ def extract_bedrock_cohere_model_streaming_response(response_body, bedrock_attrs
497497

498498
NULL_EXTRACTOR = lambda *args: {} # Empty extractor that returns nothing
499499
MODEL_EXTRACTORS = [ # Order is important here, avoiding dictionaries
500-
(
501-
"amazon.titan-embed",
502-
extract_bedrock_titan_embedding_model_request,
503-
NULL_EXTRACTOR,
504-
NULL_EXTRACTOR,
505-
),
506-
(
507-
"cohere.embed",
508-
extract_bedrock_cohere_embedding_model_request,
509-
NULL_EXTRACTOR,
510-
NULL_EXTRACTOR,
511-
),
500+
("amazon.titan-embed", extract_bedrock_titan_embedding_model_request, NULL_EXTRACTOR, NULL_EXTRACTOR),
501+
("cohere.embed", extract_bedrock_cohere_embedding_model_request, NULL_EXTRACTOR, NULL_EXTRACTOR),
512502
(
513503
"amazon.titan",
514504
extract_bedrock_titan_text_model_request,
@@ -547,11 +537,7 @@ def handle_bedrock_exception(
547537
exc, is_embedding, model, span_id, trace_id, request_extractor, request_body, ft, transaction
548538
):
549539
try:
550-
bedrock_attrs = {
551-
"model": model,
552-
"span_id": span_id,
553-
"trace_id": trace_id,
554-
}
540+
bedrock_attrs = {"model": model, "span_id": span_id, "trace_id": trace_id}
555541
try:
556542
request_extractor(request_body, bedrock_attrs)
557543
except json.decoder.JSONDecodeError:
@@ -572,9 +558,7 @@ def handle_bedrock_exception(
572558
notice_error_attributes.update({"completion_id": str(uuid.uuid4())})
573559

574560
if ft:
575-
ft.notice_error(
576-
attributes=notice_error_attributes,
577-
)
561+
ft.notice_error(attributes=notice_error_attributes)
578562

579563
ft.__exit__(*sys.exc_info())
580564
error_attributes["duration"] = ft.duration * 1000
@@ -866,9 +850,7 @@ def record_error(self, transaction, exc):
866850
}
867851
notice_error_attributes.update({"completion_id": str(uuid.uuid4())})
868852

869-
ft.notice_error(
870-
attributes=notice_error_attributes,
871-
)
853+
ft.notice_error(attributes=notice_error_attributes)
872854

873855
ft.__exit__(*sys.exc_info())
874856
error_attributes["duration"] = ft.duration * 1000
@@ -983,13 +965,7 @@ def handle_chat_completion_event(transaction, bedrock_attrs):
983965

984966

985967
def dynamodb_datastore_trace(
986-
product,
987-
target,
988-
operation,
989-
host=None,
990-
port_path_or_id=None,
991-
database_name=None,
992-
async_wrapper=None,
968+
product, target, operation, host=None, port_path_or_id=None, database_name=None, async_wrapper=None
993969
):
994970
@function_wrapper
995971
def _nr_dynamodb_datastore_trace_wrapper_(wrapped, instance, args, kwargs):
@@ -1076,9 +1052,9 @@ def _nr_dynamodb_datastore_trace_wrapper_(wrapped, instance, args, kwargs):
10761052
partition = "aws-us-gov"
10771053

10781054
if partition and region and account_id and _target:
1079-
agent_attrs[
1080-
"cloud.resource_id"
1081-
] = f"arn:{partition}:dynamodb:{region}:{account_id:012d}:table/{_target}"
1055+
agent_attrs["cloud.resource_id"] = (
1056+
f"arn:{partition}:dynamodb:{region}:{account_id:012d}:table/{_target}"
1057+
)
10821058
agent_attrs["db.system"] = "DynamoDB"
10831059

10841060
except Exception as e:
@@ -1119,14 +1095,7 @@ def _nr_aws_function_trace_wrapper_(wrapped, instance, args, kwargs):
11191095
_destination_name = destination_name(*args, **kwargs) if destination_name is not None else None
11201096
name = f"{operation}/{_destination_name}" if _destination_name else operation
11211097

1122-
trace = FunctionTrace(
1123-
name=name,
1124-
group=library,
1125-
params=params,
1126-
terminal=terminal,
1127-
parent=parent,
1128-
source=wrapped,
1129-
)
1098+
trace = FunctionTrace(name=name, group=library, params=params, terminal=terminal, parent=parent, source=wrapped)
11301099

11311100
# Attach extracted agent attributes.
11321101
_agent_attrs = extract_agent_attrs(instance, *args, **kwargs) if extract_agent_attrs is not None else {}

tests/datastore_aiomysql/test_sqlalchemy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ async def exercise(engine):
5656
cursor = await conn.execute(ABCTable.select())
5757

5858
rows = [row async for row in cursor]
59-
6059
assert rows == input_rows, f"Expected: {input_rows}, Got: {rows}"
6160

6261
await conn.execute(ABCTable.update().where(ABCTable.columns.a == 1).values((4, 4.0, "4.0")))

0 commit comments

Comments
 (0)