Skip to content

Commit

Permalink
Fix lint for sdk-extension-aws
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 3, 2024
1 parent d54ab8e commit 68658ba
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from opentelemetry.sdk.extension.aws.trace import AwsXRayIdGenerator
from opentelemetry.sdk.extension.aws.trace import ( # pylint: disable=no-name-in-module
AwsXRayIdGenerator,
)

id_generator = AwsXRayIdGenerator()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
from unittest.mock import patch

from opentelemetry.sdk.extension.aws.resource._lambda import (
from opentelemetry.sdk.extension.aws.resource._lambda import ( # pylint: disable=no-name-in-module
AwsLambdaResourceDetector,
)
from opentelemetry.semconv.resource import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict
from unittest.mock import mock_open, patch

from opentelemetry.sdk.extension.aws.resource.beanstalk import (
from opentelemetry.sdk.extension.aws.resource.beanstalk import ( # pylint: disable=no-name-in-module
AwsBeanstalkResourceDetector,
)
from opentelemetry.semconv.resource import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
from collections import OrderedDict
from unittest.mock import patch

from opentelemetry.sdk.extension.aws.resource.ec2 import AwsEc2ResourceDetector
from opentelemetry.sdk.extension.aws.resource.ec2 import ( # pylint: disable=no-name-in-module
AwsEc2ResourceDetector,
)
from opentelemetry.semconv.resource import (
CloudPlatformValues,
CloudProviderValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import unittest
from collections import OrderedDict
from os.path import dirname, join
from unittest.mock import mock_open, patch

from opentelemetry.sdk.extension.aws.resource.ecs import AwsEcsResourceDetector
from opentelemetry.sdk.extension.aws.resource.ecs import ( # pylint: disable=no-name-in-module
AwsEcsResourceDetector,
)
from opentelemetry.semconv.resource import (
CloudPlatformValues,
CloudProviderValues,
Expand All @@ -33,8 +35,10 @@


def _read_file(filename: str) -> str:
with open(os.path.join(os.path.dirname(__file__), "ecs", filename)) as f:
return f.read()
with open(
join(dirname(__file__), "ecs", filename), encoding="utf-8"
) as file:
return file.read()


MetadataV4Uri = "mock-uri-4"
Expand Down Expand Up @@ -63,13 +67,15 @@ def _http_get_function_ec2(url: str, *args, **kwargs) -> str:
return MetadataV4ContainerResponseEc2
if url == f"{MetadataV4Uri}/task":
return MetadataV4TaskResponseEc2
return None


def _http_get_function_fargate(url: str, *args, **kwargs) -> str:
if url == MetadataV4Uri:
return MetadataV4ContainerResponseFargate
if url == f"{MetadataV4Uri}/task":
return MetadataV4TaskResponseFargate
return None


class AwsEcsResourceDetectorTest(unittest.TestCase):
Expand Down Expand Up @@ -150,7 +156,6 @@ def test_simple_create_metadata_v4_launchtype_ec2(
):
mock_http_get_function.side_effect = _http_get_function_ec2
actual = AwsEcsResourceDetector().detect()
self.maxDiff = None
self.assertDictEqual(
actual.attributes.copy(),
OrderedDict(
Expand Down Expand Up @@ -215,7 +220,6 @@ def test_simple_create_metadata_v4_launchtype_fargate(
):
mock_http_get_function.side_effect = _http_get_function_fargate
actual = AwsEcsResourceDetector().detect()
self.maxDiff = None
self.assertDictEqual(
actual.attributes.copy(),
OrderedDict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
from collections import OrderedDict
from unittest.mock import mock_open, patch

from opentelemetry.sdk.extension.aws.resource.eks import AwsEksResourceDetector
from opentelemetry.sdk.extension.aws.resource.eks import ( # pylint: disable=no-name-in-module
AwsEksResourceDetector,
)
from opentelemetry.semconv.resource import (
CloudPlatformValues,
CloudProviderValues,
Expand Down

0 comments on commit 68658ba

Please sign in to comment.