Skip to content

Commit 9275ff9

Browse files
authored
Fix lint and py3.8 compatibility issues (#49)
Fix lint and [py3.8 compatibility issues](#49 (comment)) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 596dda6 commit 9275ff9

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_span_metrics_processor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3-
from typing import Optional
3+
from typing import Dict, Optional
44

55
from typing_extensions import override
66

@@ -66,7 +66,7 @@ def on_start(self, span: Span, parent_context: Optional[Context] = None) -> None
6666

6767
@override
6868
def on_end(self, span: ReadableSpan) -> None:
69-
attribute_dict: dict[str, BoundedAttributes] = self._generator.generate_metric_attributes_dict_from_span(
69+
attribute_dict: Dict[str, BoundedAttributes] = self._generator.generate_metric_attributes_dict_from_span(
7070
span, self._resource
7171
)
7272
for attributes in attribute_dict.values():

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_metric_attribute_generator.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3-
from typing import List, Optional
3+
from typing import Dict, List, Optional
44
from unittest import TestCase
55
from unittest.mock import MagicMock
66

@@ -117,7 +117,7 @@ def test_local_root_server_span(self):
117117
self.parent_span_context.is_valid = False
118118
self.span_mock.name = _SPAN_NAME_VALUE
119119

120-
expected_attributes_map: dict[str, BoundedAttributes] = {
120+
expected_attributes_map: Dict[str, BoundedAttributes] = {
121121
SERVICE_METRIC: {
122122
AWS_SPAN_KIND: _LOCAL_ROOT,
123123
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
@@ -126,7 +126,7 @@ def test_local_root_server_span(self):
126126
}
127127

128128
self.span_mock.kind = SpanKind.SERVER
129-
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
129+
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
130130
self.span_mock, self.resource
131131
)
132132
self.assertEqual(actual_attributes_map, expected_attributes_map)
@@ -136,7 +136,7 @@ def test_local_root_internal_span(self):
136136
self.parent_span_context.is_valid = False
137137
self.span_mock.name = _SPAN_NAME_VALUE
138138

139-
expected_attributes_map: dict[str, BoundedAttributes] = {
139+
expected_attributes_map: Dict[str, BoundedAttributes] = {
140140
SERVICE_METRIC: {
141141
AWS_SPAN_KIND: _LOCAL_ROOT,
142142
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
@@ -145,7 +145,7 @@ def test_local_root_internal_span(self):
145145
}
146146

147147
self.span_mock.kind = SpanKind.INTERNAL
148-
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
148+
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
149149
self.span_mock, self.resource
150150
)
151151
self.assertEqual(actual_attributes_map, expected_attributes_map)
@@ -158,7 +158,7 @@ def test_local_root_client_span(self):
158158
[AWS_REMOTE_SERVICE, AWS_REMOTE_OPERATION], [_AWS_REMOTE_SERVICE_VALUE, _AWS_REMOTE_OPERATION_VALUE]
159159
)
160160

161-
expected_attributes_map: dict[str, BoundedAttributes] = {
161+
expected_attributes_map: Dict[str, BoundedAttributes] = {
162162
SERVICE_METRIC: {
163163
AWS_SPAN_KIND: _LOCAL_ROOT,
164164
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
@@ -174,7 +174,7 @@ def test_local_root_client_span(self):
174174
}
175175

176176
self.span_mock.kind = SpanKind.CLIENT
177-
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
177+
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
178178
self.span_mock, self.resource
179179
)
180180
self.assertEqual(actual_attributes_map, expected_attributes_map)
@@ -187,7 +187,7 @@ def test_local_root_consumer_span(self):
187187
[AWS_REMOTE_SERVICE, AWS_REMOTE_OPERATION], [_AWS_REMOTE_SERVICE_VALUE, _AWS_REMOTE_OPERATION_VALUE]
188188
)
189189

190-
expected_attributes_map: dict[str, BoundedAttributes] = {
190+
expected_attributes_map: Dict[str, BoundedAttributes] = {
191191
SERVICE_METRIC: {
192192
AWS_SPAN_KIND: _LOCAL_ROOT,
193193
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
@@ -203,7 +203,7 @@ def test_local_root_consumer_span(self):
203203
}
204204

205205
self.span_mock.kind = SpanKind.CONSUMER
206-
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
206+
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
207207
self.span_mock, self.resource
208208
)
209209
self.assertEqual(actual_attributes_map, expected_attributes_map)
@@ -216,7 +216,7 @@ def test_local_root_producer_span(self):
216216
[AWS_REMOTE_SERVICE, AWS_REMOTE_OPERATION], [_AWS_REMOTE_SERVICE_VALUE, _AWS_REMOTE_OPERATION_VALUE]
217217
)
218218

219-
expected_attributes_map: dict[str, BoundedAttributes] = {
219+
expected_attributes_map: Dict[str, BoundedAttributes] = {
220220
SERVICE_METRIC: {
221221
AWS_SPAN_KIND: _LOCAL_ROOT,
222222
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
@@ -232,7 +232,7 @@ def test_local_root_producer_span(self):
232232
}
233233

234234
self.span_mock.kind = SpanKind.PRODUCER
235-
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
235+
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
236236
self.span_mock, self.resource
237237
)
238238
self.assertEqual(actual_attributes_map, expected_attributes_map)

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_metric_attributes_span_exporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def test_export_delegation_with_two_metrics(self):
174174
DEPENDENCY_METRIC: dependency_metric,
175175
}
176176

177-
self.generator_mock.generate_metric_attributes_dict_from_span.side_effect = (
178-
lambda span, resource: attribute_map if span == span_data_mock and resource == self.test_resource else {}
177+
self.generator_mock.generate_metric_attributes_dict_from_span.side_effect = lambda span, resource: (
178+
attribute_map if span == span_data_mock and resource == self.test_resource else {}
179179
)
180180

181181
self.aws_metric_attributes_span_exporter.export([span_data_mock])

0 commit comments

Comments
 (0)