Skip to content

Commit

Permalink
Fix lint and py3.8 compatibility issues (#49)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thpierce authored Feb 8, 2024
1 parent 596dda6 commit 9275ff9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from typing import Optional
from typing import Dict, Optional

from typing_extensions import override

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

@override
def on_end(self, span: ReadableSpan) -> None:
attribute_dict: dict[str, BoundedAttributes] = self._generator.generate_metric_attributes_dict_from_span(
attribute_dict: Dict[str, BoundedAttributes] = self._generator.generate_metric_attributes_dict_from_span(
span, self._resource
)
for attributes in attribute_dict.values():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from typing import List, Optional
from typing import Dict, List, Optional
from unittest import TestCase
from unittest.mock import MagicMock

Expand Down Expand Up @@ -117,7 +117,7 @@ def test_local_root_server_span(self):
self.parent_span_context.is_valid = False
self.span_mock.name = _SPAN_NAME_VALUE

expected_attributes_map: dict[str, BoundedAttributes] = {
expected_attributes_map: Dict[str, BoundedAttributes] = {
SERVICE_METRIC: {
AWS_SPAN_KIND: _LOCAL_ROOT,
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
Expand All @@ -126,7 +126,7 @@ def test_local_root_server_span(self):
}

self.span_mock.kind = SpanKind.SERVER
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
self.span_mock, self.resource
)
self.assertEqual(actual_attributes_map, expected_attributes_map)
Expand All @@ -136,7 +136,7 @@ def test_local_root_internal_span(self):
self.parent_span_context.is_valid = False
self.span_mock.name = _SPAN_NAME_VALUE

expected_attributes_map: dict[str, BoundedAttributes] = {
expected_attributes_map: Dict[str, BoundedAttributes] = {
SERVICE_METRIC: {
AWS_SPAN_KIND: _LOCAL_ROOT,
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
Expand All @@ -145,7 +145,7 @@ def test_local_root_internal_span(self):
}

self.span_mock.kind = SpanKind.INTERNAL
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
self.span_mock, self.resource
)
self.assertEqual(actual_attributes_map, expected_attributes_map)
Expand All @@ -158,7 +158,7 @@ def test_local_root_client_span(self):
[AWS_REMOTE_SERVICE, AWS_REMOTE_OPERATION], [_AWS_REMOTE_SERVICE_VALUE, _AWS_REMOTE_OPERATION_VALUE]
)

expected_attributes_map: dict[str, BoundedAttributes] = {
expected_attributes_map: Dict[str, BoundedAttributes] = {
SERVICE_METRIC: {
AWS_SPAN_KIND: _LOCAL_ROOT,
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
Expand All @@ -174,7 +174,7 @@ def test_local_root_client_span(self):
}

self.span_mock.kind = SpanKind.CLIENT
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
self.span_mock, self.resource
)
self.assertEqual(actual_attributes_map, expected_attributes_map)
Expand All @@ -187,7 +187,7 @@ def test_local_root_consumer_span(self):
[AWS_REMOTE_SERVICE, AWS_REMOTE_OPERATION], [_AWS_REMOTE_SERVICE_VALUE, _AWS_REMOTE_OPERATION_VALUE]
)

expected_attributes_map: dict[str, BoundedAttributes] = {
expected_attributes_map: Dict[str, BoundedAttributes] = {
SERVICE_METRIC: {
AWS_SPAN_KIND: _LOCAL_ROOT,
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
Expand All @@ -203,7 +203,7 @@ def test_local_root_consumer_span(self):
}

self.span_mock.kind = SpanKind.CONSUMER
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
self.span_mock, self.resource
)
self.assertEqual(actual_attributes_map, expected_attributes_map)
Expand All @@ -216,7 +216,7 @@ def test_local_root_producer_span(self):
[AWS_REMOTE_SERVICE, AWS_REMOTE_OPERATION], [_AWS_REMOTE_SERVICE_VALUE, _AWS_REMOTE_OPERATION_VALUE]
)

expected_attributes_map: dict[str, BoundedAttributes] = {
expected_attributes_map: Dict[str, BoundedAttributes] = {
SERVICE_METRIC: {
AWS_SPAN_KIND: _LOCAL_ROOT,
AWS_LOCAL_SERVICE: _SERVICE_NAME_VALUE,
Expand All @@ -232,7 +232,7 @@ def test_local_root_producer_span(self):
}

self.span_mock.kind = SpanKind.PRODUCER
actual_attributes_map: dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
actual_attributes_map: Dict[str, BoundedAttributes] = _GENERATOR.generate_metric_attributes_dict_from_span(
self.span_mock, self.resource
)
self.assertEqual(actual_attributes_map, expected_attributes_map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def test_export_delegation_with_two_metrics(self):
DEPENDENCY_METRIC: dependency_metric,
}

self.generator_mock.generate_metric_attributes_dict_from_span.side_effect = (
lambda span, resource: attribute_map if span == span_data_mock and resource == self.test_resource else {}
self.generator_mock.generate_metric_attributes_dict_from_span.side_effect = lambda span, resource: (
attribute_map if span == span_data_mock and resource == self.test_resource else {}
)

self.aws_metric_attributes_span_exporter.export([span_data_mock])
Expand Down

0 comments on commit 9275ff9

Please sign in to comment.