Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint SDK package #65

Merged
merged 4 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[settings]
force_single_line=True
from_first=True
from_first=True
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion opentelemetry-api/src/opentelemetry/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is uglier than combined imports, but to use isort we need the same style: either single lines or combined everywhere. Without this change isort was failing for other files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually looks better to me.

import importlib
import os
import sys
Expand Down
5 changes: 4 additions & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down