Skip to content

Fix lint and py3.8 compatibility issues #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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