Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2c7c20

Browse files
author
alrex
authored
use {} instead of dict() (open-telemetry#2133)
* use {} instead of dict() * fix lint
1 parent c40f10d commit a2c7c20

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

opentelemetry-api/tests/attributes/test_attributes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def test_attribute_key_validation(self):
4343

4444
def test_clean_attribute(self):
4545
self.assertInvalid([1, 2, 3.4, "ss", 4])
46-
self.assertInvalid([dict(), 1, 2, 3.4, 4])
46+
self.assertInvalid([{}, 1, 2, 3.4, 4])
4747
self.assertInvalid(["sw", "lf", 3.4, "ss"])
4848
self.assertInvalid([1, 2, 3.4, 5])
49-
self.assertInvalid(dict())
49+
self.assertInvalid({})
5050
self.assertInvalid([1, True])
5151
self.assertValid(True)
5252
self.assertValid("hi")

opentelemetry-sdk/tests/resources/test_resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def test_invalid_resource_attribute_values(self):
213213
resource = resources.Resource(
214214
{
215215
resources.SERVICE_NAME: "test",
216-
"non-primitive-data-type": dict(),
216+
"non-primitive-data-type": {},
217217
"invalid-byte-type-attribute": b"\xd8\xe1\xb7\xeb\xa8\xe5 \xd2\xb7\xe1",
218218
"": "empty-key-value",
219219
None: "null-key-value",

opentelemetry-sdk/tests/trace/test_sampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_is_sampled(self):
5050
class TestSamplingResult(unittest.TestCase):
5151
def test_ctr(self):
5252
attributes = {"asd": "test"}
53-
trace_state = dict()
53+
trace_state = {}
5454
# pylint: disable=E1137
5555
trace_state["test"] = "123"
5656
result = sampling.SamplingResult(

opentelemetry-sdk/tests/trace/test_trace.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,10 @@ def test_attributes(self):
637637
def test_invalid_attribute_values(self):
638638
with self.tracer.start_as_current_span("root") as root:
639639
root.set_attributes(
640-
{"correct-value": "foo", "non-primitive-data-type": dict()}
640+
{"correct-value": "foo", "non-primitive-data-type": {}}
641641
)
642642

643-
root.set_attribute("non-primitive-data-type", dict())
643+
root.set_attribute("non-primitive-data-type", {})
644644
root.set_attribute(
645645
"list-of-mixed-data-types-numeric-first",
646646
[123, False, "string"],
@@ -649,9 +649,7 @@ def test_invalid_attribute_values(self):
649649
"list-of-mixed-data-types-non-numeric-first",
650650
[False, 123, "string"],
651651
)
652-
root.set_attribute(
653-
"list-with-non-primitive-data-type", [dict(), 123]
654-
)
652+
root.set_attribute("list-with-non-primitive-data-type", [{}, 123])
655653
root.set_attribute("list-with-numeric-and-bool", [1, True])
656654

657655
root.set_attribute("", 123)
@@ -772,9 +770,9 @@ def test_invalid_event_attributes(self):
772770

773771
with self.tracer.start_as_current_span("root") as root:
774772
root.add_event("event0", {"attr1": True, "attr2": ["hi", False]})
775-
root.add_event("event0", {"attr1": dict()})
773+
root.add_event("event0", {"attr1": {}})
776774
root.add_event("event0", {"attr1": [[True]]})
777-
root.add_event("event0", {"attr1": [dict()], "attr2": [1, 2]})
775+
root.add_event("event0", {"attr1": [{}], "attr2": [1, 2]})
778776

779777
self.assertEqual(len(root.events), 4)
780778
self.assertEqual(root.events[0].attributes, {"attr1": True})

0 commit comments

Comments
 (0)