Skip to content

Commit b6e49ba

Browse files
authored
Remove unused imports (open-telemetry#646)
* Remove unused imports Fixes open-telemetry#645 * Fix lint * Import trace_tween_factory * Fix lint * Fix lint * Fix pylint * Try without using the symbol * Fix isort * Revert "Fix isort" This reverts commit 4dbd914. * Revert "Try without using the symbol" This reverts commit d94f955.
1 parent cc57aac commit b6e49ba

File tree

21 files changed

+10
-36
lines changed
  • instrumentation
    • opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg
    • opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto
    • opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi
    • opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django
    • opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch
    • opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi
    • opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx
    • opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2
    • opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql
    • opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache
    • opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo
    • opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid
    • opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis
    • opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3
  • tests/opentelemetry-docker-tests/tests/sqlalchemy_tests

21 files changed

+10
-36
lines changed

.flake8

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[flake8]
22
ignore =
33
E501 # line too long, defer to black
4-
F401 # unused import, defer to pylint
54
W503 # allow line breaks before binary ops
65
W504 # allow line breaks after binary ops
76
E203 # allow whitespace before ':' (https://github.com/psf/black#slices)

instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
import asyncpg
4040
import wrapt
41-
from asyncpg import exceptions
4241

4342
from opentelemetry import trace
4443
from opentelemetry.instrumentation.asyncpg.package import _instruments

instrumentation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
from opentelemetry.instrumentation.boto.version import __version__
5353
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
5454
from opentelemetry.instrumentation.utils import unwrap
55-
from opentelemetry.sdk.trace import Resource
5655
from opentelemetry.semconv.trace import SpanAttributes
5756
from opentelemetry.trace import SpanKind, get_tracer
5857

instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
from opentelemetry.instrumentation.utils import unwrap
4949
from opentelemetry.semconv.trace import SpanAttributes
5050
from opentelemetry.trace import SpanKind, TracerProvider, get_tracer
51-
from opentelemetry.trace.status import Status, StatusCode
5251

5352
logger = logging.getLogger(__name__)
5453

instrumentation/opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from django.http import HttpRequest, HttpResponse
2121

2222
from opentelemetry.context import attach, detach
23-
from opentelemetry.instrumentation.django.version import __version__
2423
from opentelemetry.instrumentation.propagators import (
2524
get_global_response_propagator,
2625
)

instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
from opentelemetry.instrumentation.utils import unwrap
6161
from opentelemetry.semconv.trace import SpanAttributes
6262
from opentelemetry.trace import SpanKind, get_tracer
63-
from opentelemetry.trace.status import Status, StatusCode
6463

6564
logger = getLogger(__name__)
6665

instrumentation/opentelemetry-instrumentation-fastapi/src/opentelemetry/instrumentation/fastapi/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from typing import Collection
1818

1919
import fastapi
20-
from starlette import middleware
2120
from starlette.routing import Match
2221

2322
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware

instrumentation/opentelemetry-instrumentation-httpx/src/opentelemetry/instrumentation/httpx/__init__.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@
1616
import typing
1717

1818
import httpx
19-
import wrapt
2019

2120
from opentelemetry import context
2221
from opentelemetry.instrumentation.httpx.package import _instruments
2322
from opentelemetry.instrumentation.httpx.version import __version__
2423
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
25-
from opentelemetry.instrumentation.utils import (
26-
http_status_to_status_code,
27-
unwrap,
28-
)
24+
from opentelemetry.instrumentation.utils import http_status_to_status_code
2925
from opentelemetry.propagate import inject
3026
from opentelemetry.semconv.trace import SpanAttributes
31-
from opentelemetry.trace import SpanKind, Tracer, TracerProvider, get_tracer
27+
from opentelemetry.trace import SpanKind, TracerProvider, get_tracer
3228
from opentelemetry.trace.span import Span
3329
from opentelemetry.trace.status import Status
3430

instrumentation/opentelemetry-instrumentation-jinja2/src/opentelemetry/instrumentation/jinja2/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from typing import Collection
4444

4545
import jinja2
46-
from wrapt import ObjectProxy
4746
from wrapt import wrap_function_wrapper as _wrap
4847

4948
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor

instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4747
from opentelemetry.instrumentation.mysql.package import _instruments
4848
from opentelemetry.instrumentation.mysql.version import __version__
49-
from opentelemetry.trace import get_tracer
5049

5150

5251
class MySQLInstrumentor(BaseInstrumentor):

instrumentation/opentelemetry-instrumentation-pymemcache/src/opentelemetry/instrumentation/pymemcache/__init__.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,13 @@
4141
from typing import Collection
4242

4343
import pymemcache
44-
from wrapt import ObjectProxy
4544
from wrapt import wrap_function_wrapper as _wrap
4645

4746
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4847
from opentelemetry.instrumentation.pymemcache.package import _instruments
4948
from opentelemetry.instrumentation.pymemcache.version import __version__
5049
from opentelemetry.instrumentation.utils import unwrap
51-
from opentelemetry.semconv.trace import (
52-
DbSystemValues,
53-
NetTransportValues,
54-
SpanAttributes,
55-
)
50+
from opentelemetry.semconv.trace import NetTransportValues, SpanAttributes
5651
from opentelemetry.trace import SpanKind, get_tracer
5752

5853
logger = logging.getLogger(__name__)

instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
from pymongo import monitoring
4343

44-
from opentelemetry import trace
4544
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4645
from opentelemetry.instrumentation.pymongo.package import _instruments
4746
from opentelemetry.instrumentation.pymongo.version import __version__

instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,11 @@
7878
---
7979
"""
8080

81-
import typing
8281
from typing import Collection
8382

8483
from pyramid.config import Configurator
8584
from pyramid.path import caller_package
8685
from pyramid.settings import aslist
87-
from wrapt import ObjectProxy
8886
from wrapt import wrap_function_wrapper as _wrap
8987

9088
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
@@ -94,9 +92,12 @@
9492
trace_tween_factory,
9593
)
9694
from opentelemetry.instrumentation.pyramid.package import _instruments
97-
from opentelemetry.instrumentation.pyramid.version import __version__
9895
from opentelemetry.instrumentation.utils import unwrap
99-
from opentelemetry.trace import TracerProvider, get_tracer
96+
97+
# test_automatic.TestAutomatic.test_tween_list needs trace_tween_factory to be
98+
# imported in this module. The next line is necessary to avoid a lint error
99+
# from importing an unused symbol.
100+
trace_tween_factory # pylint: disable=pointless-statement
100101

101102

102103
def _traced_init(wrapped, instance, args, kwargs):

instrumentation/opentelemetry-instrumentation-redis/src/opentelemetry/instrumentation/redis/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from typing import Collection
4646

4747
import redis
48-
from wrapt import ObjectProxy, wrap_function_wrapper
48+
from wrapt import wrap_function_wrapper
4949

5050
from opentelemetry import trace
5151
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor

instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
4747
from opentelemetry.instrumentation.sqlite3.package import _instruments
4848
from opentelemetry.instrumentation.sqlite3.version import __version__
49-
from opentelemetry.trace import get_tracer
5049

5150
# No useful attributes of sqlite3 connection object
5251
_CONNECTION_ATTRIBUTES = {}

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/mixins.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
import contextlib
1616
import logging
1717
import threading
18-
import unittest
1918

20-
from sqlalchemy import Column, Integer, String, create_engine, insert
19+
from sqlalchemy import Column, Integer, String, create_engine
2120
from sqlalchemy.ext.declarative import declarative_base
2221
from sqlalchemy.orm import close_all_sessions, scoped_session, sessionmaker
2322

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_instrument.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import os
16-
import unittest
1716

1817
import sqlalchemy
1918

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mssql.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import os
16-
import unittest
1716

1817
import pytest
1918
from sqlalchemy.exc import ProgrammingError

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_mysql.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import os
16-
import unittest
1716

1817
import pytest
1918
from sqlalchemy.exc import ProgrammingError

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_postgres.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import os
16-
import unittest
1716

1817
import psycopg2
1918
import pytest

tests/opentelemetry-docker-tests/tests/sqlalchemy_tests/test_sqlite.py

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import unittest
16-
1715
import pytest
1816
from sqlalchemy.exc import OperationalError
1917

0 commit comments

Comments
 (0)