Repository: open-telemetry/opentelemetry-python

Issue:
update pylint to 2.11.0
The version of pylint in this repo is falling behind. I tried running it w/ pylint 2.11.0 and came across a bunch of warnings in the following categories:

- [x] #2130
- [x] #2125
- [x] #2126
- [x] #2132
- [x] #2134

I will submit separate PRs for each of those, before submitting a PR to bump pylint to 2.11.0.


Discussion:

Resolving patch:
diff --git a/opentelemetry-api/src/opentelemetry/util/_time.py b/opentelemetry-api/src/opentelemetry/util/_time.py
--- a/opentelemetry-api/src/opentelemetry/util/_time.py
+++ b/opentelemetry-api/src/opentelemetry/util/_time.py
@@ -17,7 +17,7 @@
 
 if version_info.minor < 7:
     getLogger(__name__).warning(  # pylint: disable=logging-not-lazy
-        "You are using Python 3.%s. This version does not support timestamps "
+        "You are using Python 3.%s. This version does not support timestamps "  # pylint: disable=C0209
         "with nanosecond precision and the OpenTelemetry SDK will use "
         "millisecond precision instead. Please refer to PEP 564 for more "
         "information. Please upgrade to Python 3.7 or newer to use nanosecond "
diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py
--- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py
+++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py
@@ -71,11 +71,11 @@ def _pip_check():
     'opentelemetry-instrumentation-flask 1.0.1 has requirement opentelemetry-sdk<2.0,>=1.0, but you have opentelemetry-sdk 0.5.'
     To not be too restrictive, we'll only check for relevant packages.
     """
-    check_pipe = subprocess.Popen(
+    with subprocess.Popen(
         [sys.executable, "-m", "pip", "check"], stdout=subprocess.PIPE
-    )
-    pip_check = check_pipe.communicate()[0].decode()
-    pip_check_lower = pip_check.lower()
+    ) as check_pipe:
+        pip_check = check_pipe.communicate()[0].decode()
+        pip_check_lower = pip_check.lower()
     for package_tup in libraries.values():
         for package in package_tup:
             if package.lower() in pip_check_lower:


Test patch:
diff --git a/opentelemetry-api/tests/trace/test_proxy.py b/opentelemetry-api/tests/trace/test_proxy.py
--- a/opentelemetry-api/tests/trace/test_proxy.py
+++ b/opentelemetry-api/tests/trace/test_proxy.py
@@ -22,8 +22,10 @@
 
 class TestProvider(trace._DefaultTracerProvider):
     def get_tracer(
-        self, instrumentation_module_name, instrumentaiton_library_version=None
-    ):
+        self,
+        instrumenting_module_name: str,
+        instrumenting_library_version: str = "",
+    ) -> trace.Tracer:
         return TestTracer()
 
 
diff --git a/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py b/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py
--- a/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py
+++ b/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py
@@ -16,8 +16,6 @@
 from abc import abstractmethod
 from unittest.mock import Mock
 
-import opentelemetry.sdk.trace as trace
-import opentelemetry.sdk.trace.id_generator as id_generator
 import opentelemetry.trace as trace_api
 from opentelemetry.context import Context, get_current
 from opentelemetry.propagators.b3 import (  # pylint: disable=no-name-in-module,import-error
@@ -25,6 +23,8 @@
     B3SingleFormat,
 )
 from opentelemetry.propagators.textmap import DefaultGetter
+from opentelemetry.sdk import trace
+from opentelemetry.sdk.trace import id_generator
 from opentelemetry.trace.propagation import _SPAN_KEY
 
 
diff --git a/shim/opentelemetry-opentracing-shim/tests/testbed/test_listener_per_request/test_asyncio.py b/shim/opentelemetry-opentracing-shim/tests/testbed/test_listener_per_request/test_asyncio.py
--- a/shim/opentelemetry-opentracing-shim/tests/testbed/test_listener_per_request/test_asyncio.py
+++ b/shim/opentelemetry-opentracing-shim/tests/testbed/test_listener_per_request/test_asyncio.py
@@ -10,22 +10,23 @@
 from .response_listener import ResponseListener
 
 
+async def task(message, listener):
+    res = f"{message}::response"
+    listener.on_response(res)
+    return res
+
+
 class Client:
     def __init__(self, tracer, loop):
         self.tracer = tracer
         self.loop = loop
 
-    async def task(self, message, listener):
-        res = f"{message}::response"
-        listener.on_response(res)
-        return res
-
     def send_sync(self, message):
         span = self.tracer.start_span("send")
         span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
 
         listener = ResponseListener(span)
-        return self.loop.run_until_complete(self.task(message, listener))
+        return self.loop.run_until_complete(task(message, listener))
 
 
 class TestAsyncio(OpenTelemetryTestCase):