Skip to content
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

Point pylint to the root directory of every package #2658

Merged
merged 10 commits into from
Jul 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self, channel):
Args:
channel: A grpc.Channel.
"""
# pylint: disable=invalid-name
self.SimpleMethod = channel.unary_unary(
"/GRPCTestServer/SimpleMethod",
request_serializer=test__server__pb2.Request.SerializeToString,
Expand All @@ -37,6 +38,9 @@ def __init__(self, channel):
class GRPCTestServerServicer:
"""Missing associated documentation comment in .proto file"""

# pylint: disable=invalid-name
# pylint: disable=no-self-use

def SimpleMethod(self, request, context):
"""Missing associated documentation comment in .proto file"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
Expand All @@ -62,7 +66,9 @@ def BidirectionalStreamingMethod(self, request_iterator, context):
raise NotImplementedError("Method not implemented!")


def add_GRPCTestServerServicer_to_server(servicer, server):
def add_GRPCTestServerServicer_to_server(
servicer, server
): # pylint: disable=invalid-name
rpc_method_handlers = {
"SimpleMethod": grpc.unary_unary_rpc_method_handler(
servicer.SimpleMethod,
Expand Down Expand Up @@ -95,6 +101,7 @@ def add_GRPCTestServerServicer_to_server(servicer, server):
class GRPCTestServer:
"""Missing associated documentation comment in .proto file"""

# pylint: disable=invalid-name
@staticmethod
def SimpleMethod(
request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class TestLoad(TestCase):
@patch(
"opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points"
)
def test_load_configurators(self, iter_mock):
def test_load_configurators(
self, iter_mock
): # pylint: disable=no-self-use
# Add multiple entry points but only specify the 2nd in the environment variable.
ep_mock1 = Mock()
ep_mock1.name = "custom_configurator1"
Expand Down Expand Up @@ -62,9 +64,8 @@ def test_load_configurators(self, iter_mock):
"opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points"
)
def test_load_configurators_no_ep(
self,
iter_mock,
):
self, iter_mock
): # pylint: disable=no-self-use
iter_mock.return_value = ()
# Confirm method does not crash if not entry points exist.
_load._load_configurators()
Expand Down Expand Up @@ -214,6 +215,7 @@ def test_load_distro_error(self, iter_mock, isinstance_mock):
)
def test_load_instrumentors(self, iter_mock, dep_mock):
# Mock opentelemetry_pre_instrument entry points
# pylint: disable=too-many-locals
pre_ep_mock1 = Mock()
pre_ep_mock1.name = "pre1"
pre_mock1 = Mock()
Expand Down Expand Up @@ -285,7 +287,9 @@ def test_load_instrumentors(self, iter_mock, dep_mock):
@patch(
"opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points"
)
def test_load_instrumentors_dep_conflict(self, iter_mock, dep_mock):
def test_load_instrumentors_dep_conflict(
self, iter_mock, dep_mock
): # pylint: disable=no-self-use
ep_mock1 = Mock()
ep_mock1.name = "instr1"

Expand Down
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
Loading