Skip to content

Commit

Permalink
Remove unused imports (#2007)
Browse files Browse the repository at this point in the history
Fixes #2006

Co-authored-by: alrex <[email protected]>
  • Loading branch information
ocelotl and alrex authored Aug 4, 2021
1 parent 65670cf commit e2eb73c
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 36 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[flake8]
ignore =
E501 # line too long, defer to black
F401 # unused import, defer to pylint
W503 # allow line breaks before binary ops
W504 # allow line breaks after binary ops
E203 # allow whitespace before ':' (https://github.com/psf/black#slices)
Expand Down
1 change: 0 additions & 1 deletion docs/getting_started/otlpcollector_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

# otcollector.py
import time

from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

import logging
from abc import ABC, abstractmethod
from collections.abc import Mapping, Sequence
from collections.abc import Sequence
from os import environ
from time import sleep
from typing import Any, Callable, Dict, Generic, List, Optional
from typing import Sequence as TypingSequence
from typing import Text, TypeVar
from urllib import parse
from urllib.parse import urlparse

from backoff import expo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@

import requests

from opentelemetry.exporter.zipkin.encoder import (
DEFAULT_MAX_TAG_VALUE_LENGTH,
Encoder,
Protocol,
)
from opentelemetry.exporter.zipkin.encoder import Protocol
from opentelemetry.exporter.zipkin.json.v1 import JsonV1Encoder
from opentelemetry.exporter.zipkin.json.v2 import JsonV2Encoder
from opentelemetry.exporter.zipkin.node_endpoint import IpInput, NodeEndpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Zipkin Export Encoders for JSON formats
"""

import abc
from typing import Dict, List

from opentelemetry.exporter.zipkin.encoder import Encoder, JsonEncoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@

import requests

from opentelemetry.exporter.zipkin.encoder import (
DEFAULT_MAX_TAG_VALUE_LENGTH,
Encoder,
Protocol,
)
from opentelemetry.exporter.zipkin.proto.http.v2 import ProtobufEncoder
from opentelemetry.exporter.zipkin.node_endpoint import IpInput, NodeEndpoint
from opentelemetry.sdk.environment_variables import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from opentelemetry.exporter.zipkin.proto.http.v2.gen import zipkin_pb2
from opentelemetry.exporter.zipkin.node_endpoint import NodeEndpoint
from opentelemetry.sdk.trace import Event
from opentelemetry.trace import Span, SpanContext, SpanKind
from opentelemetry.trace import Span, SpanKind


class ProtobufEncoder(Encoder):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
from opentelemetry.context.context import Context, _RuntimeContext

if (3, 5, 3) <= version_info < (3, 7):
import aiocontextvars # type: ignore # pylint:disable=unused-import,import-error
import aiocontextvars # type: ignore # pylint:disable=import-error

aiocontextvars # pylint:disable=pointless-statement

elif (3, 4) < version_info <= (3, 5, 2):
import opentelemetry.context.aiocontextvarsfix # pylint:disable=unused-import
import opentelemetry.context.aiocontextvarsfix # pylint:disable=wrong-import-position

opentelemetry.context.aiocontextvarsfix # pylint:disable=pointless-statement


class ContextVarsRuntimeContext(_RuntimeContext):
Expand Down
13 changes: 6 additions & 7 deletions opentelemetry-api/tests/context/test_contextvars_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@
# limitations under the License.

import unittest
from sys import version_info
from unittest.mock import patch

from opentelemetry import context

from .base_context import ContextTestCases

try:
import contextvars # pylint: disable=unused-import

from opentelemetry.context.contextvars_context import (
ContextVarsRuntimeContext,
)
except ImportError:
if version_info.minor < 7:
raise unittest.SkipTest("contextvars not available")

from opentelemetry.context.contextvars_context import ( # pylint:disable=wrong-import-position
ContextVarsRuntimeContext,
)


class TestContextVarsContext(ContextTestCases.BaseTest):
def setUp(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
default_instrumentations,
libraries,
)
from opentelemetry.instrumentation.version import __version__ as version

logger = logging.getLogger(__file__)

Expand Down
12 changes: 5 additions & 7 deletions opentelemetry-sdk/tests/context/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import asyncio
import unittest
from sys import version_info
from unittest.mock import patch

from opentelemetry import context
Expand All @@ -23,15 +24,12 @@
InMemorySpanExporter,
)

try:
import contextvars # pylint: disable=unused-import

from opentelemetry.context.contextvars_context import (
ContextVarsRuntimeContext,
)
except ImportError:
if version_info.minor < 7:
raise unittest.SkipTest("contextvars not available")

from opentelemetry.context.contextvars_context import ( # pylint:disable=wrong-import-position
ContextVarsRuntimeContext,
)

_SPAN_NAMES = [
"test_span1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import time
from unittest.mock import patch

from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import time
from unittest.mock import patch

from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import opentelemetry.trace as trace
from opentelemetry import baggage
from opentelemetry.context import Context, get_current
from opentelemetry.context import Context
from opentelemetry.propagators.textmap import (
CarrierT,
Getter,
Expand Down

0 comments on commit e2eb73c

Please sign in to comment.