From f609450b63814b366b77ce5793cc0c813402cfb4 Mon Sep 17 00:00:00 2001 From: Chris Kleinknecht Date: Fri, 26 Jul 2019 16:53:07 -0700 Subject: [PATCH] Lint SDK package (#65) --- .isort.cfg | 2 ++ .pylintrc | 2 ++ opentelemetry-api/src/opentelemetry/loader.py | 5 ++++- opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py | 5 ++++- opentelemetry-sdk/src/opentelemetry/sdk/util.py | 2 +- tox.ini | 7 ++++--- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index 3d19a1c6e01..20d62f8ecba 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,2 +1,4 @@ [settings] +force_single_line=True +from_first=True from_first=True diff --git a/.pylintrc b/.pylintrc index 0345f53ad60..23f9b090cd0 100644 --- a/.pylintrc +++ b/.pylintrc @@ -63,6 +63,8 @@ confidence= disable=missing-docstring, fixme, # Warns about FIXME, TODO, etc. comments. too-few-public-methods, # Might be good to re-enable this later. + too-many-instance-attributes, + too-many-arguments # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/opentelemetry-api/src/opentelemetry/loader.py b/opentelemetry-api/src/opentelemetry/loader.py index cf2069edb42..9e28846b8c5 100644 --- a/opentelemetry-api/src/opentelemetry/loader.py +++ b/opentelemetry-api/src/opentelemetry/loader.py @@ -61,7 +61,10 @@ def my_factory_for_t(api_type: typing.Type[T]) -> typing.Optional[T]: means that the Python interpreter was invoked with the ``-E`` or ``-I`` flag). """ -from typing import Callable, Optional, Type, TypeVar +from typing import Callable +from typing import Optional +from typing import Type +from typing import TypeVar import importlib import os import sys diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index 47d5b5bdad2..2508f7c59e3 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -23,13 +23,14 @@ from opentelemetry.sdk import util try: + # pylint: disable=ungrouped-imports from collections.abc import MutableMapping from collections.abc import Sequence except ImportError: + # pylint: disable=no-name-in-module,ungrouped-imports from collections import MutableMapping from collections import Sequence - MAX_NUM_ATTRIBUTES = 32 MAX_NUM_EVENTS = 128 MAX_NUM_LINKS = 32 @@ -81,6 +82,7 @@ def from_seq(cls, maxlen, seq): if len(seq) > maxlen: raise ValueError bounded_list = cls(maxlen) + # pylint: disable=protected-access bounded_list._dq = deque(seq, maxlen=maxlen) return bounded_list @@ -137,6 +139,7 @@ def from_map(cls, maxlen, mapping): if len(mapping) > maxlen: raise ValueError bounded_dict = cls(maxlen) + # pylint: disable=protected-access bounded_dict._dict = mapping return bounded_dict diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/util.py b/opentelemetry-sdk/src/opentelemetry/sdk/util.py index 7e386ce44a2..9886206fb79 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/util.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/util.py @@ -15,7 +15,7 @@ import time try: - time_ns = time.time_ns # noqa + time_ns = time.time_ns # pylint: disable=invalid-name # Python versions < 3.7 except AttributeError: def time_ns(): diff --git a/tox.ini b/tox.ini index f9761bcc01e..cd711243618 100644 --- a/tox.ini +++ b/tox.ini @@ -36,13 +36,14 @@ deps = commands_pre = pip install -e {toxinidir}/opentelemetry-api + pip install -e {toxinidir}/opentelemetry-sdk commands = ; Prefer putting everything in one pylint command to profit from duplication ; warnings. - pylint opentelemetry-api/src/opentelemetry/ opentelemetry-api/tests/ - flake8 opentelemetry-api/src/opentelemetry/ opentelemetry-api/tests/ - isort --check-only --recursive opentelemetry-api/src + pylint opentelemetry-api/src/opentelemetry/ opentelemetry-api/tests/ opentelemetry-sdk/src/opentelemetry/ opentelemetry-sdk/tests/ + flake8 opentelemetry-api/src/opentelemetry/ opentelemetry-api/tests/ opentelemetry-sdk/src/opentelemetry/ opentelemetry-sdk/tests/ + isort --check-only --recursive opentelemetry-api/src opentelemetry-sdk/src [testenv:docs] deps =