From 6290c2eb42e4c75bbd190e4f079dce363379255a Mon Sep 17 00:00:00 2001 From: Chris Kleinknecht Date: Fri, 26 Jul 2019 16:00:25 -0700 Subject: [PATCH 1/4] Lint SDK package --- tox.ini | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index f9761bcc01e..0c3335263bc 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,8 @@ commands_pre = commands = mypy: mypy --namespace-packages opentelemetry-api/src/opentelemetry/ ; For test code, we don't want to enforce the full mypy strictness - mypy: mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/ + mypy: mypy --namespace-packages --config-file=mypy-relaxed.ini \ + opentelemetry-api/tests/ test-{api,sdk}: python -m unittest discover [testenv:lint] @@ -36,13 +37,16 @@ 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 = From 638f2240c13ae3fee8fa970b773ff7079170b583 Mon Sep 17 00:00:00 2001 From: Chris Kleinknecht Date: Fri, 26 Jul 2019 16:26:17 -0700 Subject: [PATCH 2/4] Deal with my own lint violations --- .pylintrc | 2 ++ opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py | 5 ++++- opentelemetry-sdk/src/opentelemetry/sdk/util.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) 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-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(): From ab3c4bc8a9485a7e97f90502b18926b1861f8829 Mon Sep 17 00:00:00 2001 From: Chris Kleinknecht Date: Fri, 26 Jul 2019 16:34:24 -0700 Subject: [PATCH 3/4] Use single-line imports in sort order --- .isort.cfg | 2 ++ opentelemetry-api/src/opentelemetry/loader.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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/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 From b9a8d462df6809bff59663e0a4145b1e4bbbc8d8 Mon Sep 17 00:00:00 2001 From: Chris Kleinknecht Date: Fri, 26 Jul 2019 16:48:05 -0700 Subject: [PATCH 4/4] No line continuations in toxfile --- tox.ini | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index 0c3335263bc..cd711243618 100644 --- a/tox.ini +++ b/tox.ini @@ -25,8 +25,7 @@ commands_pre = commands = mypy: mypy --namespace-packages opentelemetry-api/src/opentelemetry/ ; For test code, we don't want to enforce the full mypy strictness - mypy: mypy --namespace-packages --config-file=mypy-relaxed.ini \ - opentelemetry-api/tests/ + mypy: mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/ test-{api,sdk}: python -m unittest discover [testenv:lint] @@ -42,10 +41,8 @@ commands_pre = commands = ; Prefer putting everything in one pylint command to profit from duplication ; warnings. - 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/ + 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]