Skip to content

Commit da7cac0

Browse files
authored
Merge branch 'main' into add-layers-release-flow-to-gha
2 parents 079449c + 25e1f1e commit da7cac0

File tree

8 files changed

+67
-14
lines changed

8 files changed

+67
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# Linter
55
megalinter-reports/
6+
.pre-commit-config.yaml
67

78
# Byte-compiled / optimized / DLL files
89
__pycache__/

newrelic/api/llm_custom_attributes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class WithLlmCustomAttributes(object):
2323
def __init__(self, custom_attr_dict):
2424
transaction = current_transaction()
2525
if not custom_attr_dict or not isinstance(custom_attr_dict, dict):
26-
raise TypeError(
27-
"custom_attr_dict must be a non-empty dictionary. Received type: %s" % type(custom_attr_dict)
28-
)
26+
raise TypeError(f"custom_attr_dict must be a non-empty dictionary. Received type: {type(custom_attr_dict)}")
2927

3028
# Add "llm." prefix to all keys in attribute dictionary
3129
context_attrs = {k if k.startswith("llm.") else f"llm.{k}": v for k, v in custom_attr_dict.items()}

pyproject.toml

+45-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,43 @@ include = '\.pyi?$'
66
profile = "black"
77

88
[tool.pylint.messages_control]
9-
disable = "C0103,C0114,C0115,C0116,C0209,C0302,C0415,E0401,E1120,R0205,R0401,R0801,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R1705,R1710,R1725,W0201,W0212,W0223,W0402,W0603,W0612,W0613,W0702,W0703,W0706,line-too-long,redefined-outer-name"
9+
disable = [
10+
"C0103",
11+
"C0114",
12+
"C0115",
13+
"C0116",
14+
"C0209",
15+
"C0302",
16+
"C0415",
17+
"E0401",
18+
"E1120",
19+
"R0205",
20+
"R0401",
21+
"R0801",
22+
"R0902",
23+
"R0903",
24+
"R0904",
25+
"R0911",
26+
"R0912",
27+
"R0913",
28+
"R0914",
29+
"R0915",
30+
"R1705",
31+
"R1710",
32+
"R1725",
33+
"W0201",
34+
"W0212",
35+
"W0223",
36+
"W0402",
37+
"W0603",
38+
"W0612",
39+
"W0613",
40+
"W0702",
41+
"W0703",
42+
"W0706",
43+
"line-too-long",
44+
"redefined-outer-name",
45+
]
1046

1147
[tool.pylint.format]
1248
max-line-length = "120"
@@ -16,3 +52,11 @@ good-names = "exc,val,tb"
1652

1753
[tool.bandit]
1854
skips = ["B110", "B101", "B404"]
55+
56+
[tool.flynt]
57+
line-length = 999999
58+
aggressive = true
59+
transform-concats = true
60+
transform-joins = true
61+
exclude = ["newrelic/packages/", "setup.py"]
62+
# setup.py needs to not immediately crash on Python 2 to log error messages, so disable fstrings

setup.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
if python_version >= (3, 7):
2121
pass
2222
else:
23-
error_msg = "The New Relic Python agent only supports Python 3.7+. We recommend upgrading to a newer version of Python."
24-
23+
error_msg = (
24+
"The New Relic Python agent only supports Python 3.7+. We recommend upgrading to a newer version of Python."
25+
)
26+
2527
try:
2628
# Lookup table for the last agent versions to support each Python version.
2729
last_supported_version_lookup = {
@@ -36,7 +38,10 @@
3638

3739
if last_supported_version:
3840
python_version_str = "%s.%s" % (python_version[0], python_version[1])
39-
error_msg += " The last agent version to support Python %s was v%s." % (python_version_str, last_supported_version)
41+
error_msg += " The last agent version to support Python %s was v%s." % (
42+
python_version_str,
43+
last_supported_version,
44+
)
4045
except Exception:
4146
pass
4247

tests/cross_agent/test_ecs_data.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@
1313
# limitations under the License.
1414

1515
import os
16+
1617
import pytest
17-
import newrelic.common.utilization as u
18-
from fixtures.ecs_container_id.ecs_mock_server import mock_server, bad_response_mock_server
18+
from fixtures.ecs_container_id.ecs_mock_server import (
19+
bad_response_mock_server,
20+
mock_server,
21+
)
1922
from test_pcf_utilization_data import Environ
2023

24+
import newrelic.common.utilization as u
25+
2126

2227
@pytest.mark.parametrize("env_key", ["ECS_CONTAINER_METADATA_URI_V4", "ECS_CONTAINER_METADATA_URI"])
2328
def test_ecs_docker_container_id(env_key, mock_server):
24-
mock_endpoint = "http://localhost:%d" % mock_server.port
29+
mock_endpoint = f"http://localhost:{int(mock_server.port)}"
2530
env_dict = {env_key: mock_endpoint}
2631

2732
with Environ(env_dict):
@@ -41,7 +46,7 @@ def test_ecs_docker_container_id_bad_uri(env_dict, mock_server):
4146

4247

4348
def test_ecs_docker_container_id_bad_response(bad_response_mock_server):
44-
mock_endpoint = "http://localhost:%d" % bad_response_mock_server.port
49+
mock_endpoint = f"http://localhost:{int(bad_response_mock_server.port)}"
4550
env_dict = {"ECS_CONTAINER_METADATA_URI": mock_endpoint}
4651

4752
with Environ(env_dict):

tests/datastore_motor/test_collection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def exercise_motor(db):
8282
await collection.options()
8383
collection.watch()
8484

85-
new_name = MONGODB_COLLECTION + "_renamed"
85+
new_name = f"{MONGODB_COLLECTION}_renamed"
8686
await collection.rename(new_name)
8787
await db[new_name].drop()
8888
await collection.drop()

tests/datastore_pymongo/test_async_collection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def _exercise_mongo(db):
8989
await collection.find_one_and_update({"x": 301}, {"$inc": {"x": 300}})
9090
await collection.options()
9191

92-
new_name = MONGODB_COLLECTION + "_renamed"
92+
new_name = f"{MONGODB_COLLECTION}_renamed"
9393
await collection.rename(new_name)
9494
await db[new_name].drop()
9595
await collection.drop()

tests/datastore_pymongo/test_collection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _exercise_mongo_v4(db):
127127
collection.find_one_and_update({"x": 301}, {"$inc": {"x": 300}})
128128
collection.options()
129129

130-
new_name = MONGODB_COLLECTION + "_renamed"
130+
new_name = f"{MONGODB_COLLECTION}_renamed"
131131
collection.rename(new_name)
132132
db[new_name].drop()
133133
collection.drop()

0 commit comments

Comments
 (0)