Skip to content

Commit

Permalink
Update several files
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Nov 18, 2023
1 parent a528981 commit 89c30fd
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 43 deletions.
11 changes: 2 additions & 9 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ limit-inference-results=100

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
load-plugins=pylint.extensions.no_self_use

# Pickle collected data for later comparisons.
persistent=yes
Expand Down Expand Up @@ -68,14 +68,14 @@ disable=missing-docstring,
duplicate-code,
ungrouped-imports, # Leave this up to isort
wrong-import-order, # Leave this up to isort
bad-continuation, # Leave this up to black
line-too-long, # Leave this up to black
exec-used,
super-with-arguments, # temp-pylint-upgrade
isinstance-second-argument-not-valid-type, # temp-pylint-upgrade
raise-missing-from, # temp-pylint-upgrade
unused-argument, # temp-pylint-upgrade
redefined-builtin,
cyclic-import,

# 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 Expand Up @@ -263,13 +263,6 @@ max-line-length=79
# Maximum number of lines in a module.
max-module-lines=1000

# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,
dict-separator

# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
Expand Down
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pylint==2.11.0
pylint==3.0.2
flake8~=3.7
isort~=5.8
black~=22.3.0
Expand All @@ -8,7 +8,7 @@ sphinx~=7.1
sphinx-rtd-theme==2.0.0rc4
sphinx-autodoc-typehints~=1.25
pytest==7.1.3
pytest-cov>=2.8
pytest-cov~=4.1
readme-renderer~=24.0
# This version of grpcio-tools ships with protoc 3.19.4 which appears to be compatible with
# both protobuf 3.19.x and 4.x (see https://github.com/protocolbuffers/protobuf/issues/11123).
Expand Down
7 changes: 3 additions & 4 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ sphinx-jekyll-builder==0.3.0
./shim/opentelemetry-opentracing-shim

# Required by instrumentation and exporter packages
ddtrace>=0.34.0
grpcio~=1.27
Deprecated>=1.2.6
django>=2.2
Deprecated~=1.2
django~=4.2
flask~=1.0
opentracing~=2.2.0
thrift>=0.10.0
thrift~=0.10
wrapt>=1.0.0,<2.0.0
# temporary fix. we should update the jinja, flask deps
# See https://github.com/pallets/markupsafe/issues/282
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self, thrift_url="", auth=None, timeout_in_millis=None):
if auth is not None:
auth_header = f"{auth[0]}:{auth[1]}"
decoded = base64.b64encode(auth_header.encode()).decode("ascii")
basic_auth = dict(Authorization=f"Basic {decoded}")
basic_auth = {"Authorization": f"Basic {decoded}"}
self.http_transport.setCustomHeaders(basic_auth)

def submit(self, batch: jaeger.Batch):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_logger_provider() -> LoggerProvider:
"""Gets the current global :class:`~.LoggerProvider` object."""
global _LOGGER_PROVIDER # pylint: disable=global-statement
if _LOGGER_PROVIDER is None:
if _OTEL_PYTHON_LOGGER_PROVIDER not in environ.keys():
if _OTEL_PYTHON_LOGGER_PROVIDER not in environ:
# TODO: return proxy
_LOGGER_PROVIDER = NoOpLoggerProvider()
return _LOGGER_PROVIDER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
_logger = getLogger(__name__)


# pylint: disable=invalid-name
_ProxyInstrumentT = Union[
_ProxyCounter,
_ProxyHistogram,
Expand Down Expand Up @@ -760,7 +761,7 @@ def get_meter_provider() -> MeterProvider:
"""Gets the current global :class:`~.MeterProvider` object."""

if _METER_PROVIDER is None:
if OTEL_PYTHON_METER_PROVIDER not in environ.keys():
if OTEL_PYTHON_METER_PROVIDER not in environ:
return _PROXY_METER_PROVIDER

meter_provider: MeterProvider = _load_provider( # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class CallbackOptions:


InstrumentT = TypeVar("InstrumentT", bound="Instrument")
# pylint: disable=invalid-name
CallbackT = Union[
Callable[[CallbackOptions], Iterable[Observation]],
Generator[Iterable[Observation], CallbackOptions, None],
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-api/src/opentelemetry/propagators/textmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from opentelemetry.context.context import Context

CarrierT = typing.TypeVar("CarrierT")
# pylint: disable=invalid-name
CarrierValT = typing.Union[typing.List[str], str]


Expand Down
5 changes: 4 additions & 1 deletion opentelemetry-api/tests/context/test_contextvars_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
from opentelemetry import context
from opentelemetry.context.contextvars_context import ContextVarsRuntimeContext

from .base_context import ContextTestCases
# pylint: disable=import-error,no-name-in-module
from tests.context.base_context import ContextTestCases


class TestContextVarsContext(ContextTestCases.BaseTest):
# pylint: disable=invalid-name
def setUp(self) -> None:
super().setUp()
self.mock_runtime = patch.object(
Expand All @@ -30,6 +32,7 @@ def setUp(self) -> None:
)
self.mock_runtime.start()

# pylint: disable=invalid-name
def tearDown(self) -> None:
super().tearDown()
self.mock_runtime.stop()
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ def aggregate(self, measurement: Measurement) -> None:

# 3. Determine if a change of scale is needed.
is_rescaling_needed = False
low, high = 0, 0

if len(buckets) == 0:
buckets.index_start = index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def to_json(self, indent=4) -> str:
)


# pylint: disable=invalid-name
DataT = Union[Sum, Gauge, Histogram]
DataPointT = Union[NumberDataPoint, HistogramDataPoint]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,11 @@ def get_aggregated_resources(
futures = [executor.submit(detector.detect) for detector in detectors]
for detector_ind, future in enumerate(futures):
detector = detectors[detector_ind]
detected_resource: Resource = _EMPTY_RESOURCE
try:
detected_resource = future.result(timeout=timeout)
# pylint: disable=broad-except
except Exception as ex:
detected_resource = _EMPTY_RESOURCE
if detector.raise_on_error:
raise ex
logger.warning(
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ def test_record_exception_with_attributes_and_timestamp(self):
self.assertEqual(1604238587112021089, exception_event.timestamp)

def test_record_exception_context_manager(self):
span = None
try:
with self.tracer.start_as_current_span("span") as span:
raise RuntimeError("example error")
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ exclude = '''
/( # generated files
.tox|
venv|
venv.*|
.venv.*|
target.*|
.*/build/lib/.*|
exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/gen|
exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/gen|
Expand Down
2 changes: 1 addition & 1 deletion scripts/update_sha.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

def get_sha(branch):
url = API_URL + branch
response = requests.get(url)
response = requests.get(url, timeout=15)
response.raise_for_status()
return response.json()["sha"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ def from_context_manager(cls, manager: "ScopeManagerShim", span_cm):
:meth:`opentelemetry.trace.use_span`.
"""

# pylint: disable=unnecessary-dunder-call
otel_span = span_cm.__enter__()
span_context = SpanContextShim(otel_span.get_span_context())
span = SpanShim(manager.tracer, span_context, otel_span)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_main(self):
def task(self, interval, parent_span):
logger.info("Starting task")

scope = None
try:
scope = self.tracer.scope_manager.activate(parent_span, False)
with self.tracer.start_active_span("task"):
Expand Down
36 changes: 14 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ commands =
mypyinstalled: mypy --install-types --non-interactive --namespace-packages opentelemetry-api/tests/mypysmoke.py --strict

[testenv:spellcheck]
basepython: python3.10
basepython: python3
recreate = True
deps =
codespell
Expand All @@ -200,20 +200,14 @@ commands =
codespell

[testenv:lint]
basepython: python3.10
basepython: python3
recreate = True
deps =
-c dev-requirements.txt
asgiref
pylint
flake8
isort
black
psutil
readme_renderer
httpretty
GitPython
flaky
-r dev-requirements.txt
asgiref~=3.7
psutil~=5.9
GitPython==3.1.40
flaky~=3.7

commands_pre =
python -m pip install -e {toxinidir}/opentelemetry-api[test]
Expand Down Expand Up @@ -250,14 +244,12 @@ recreate = True
deps =
-c {toxinidir}/dev-requirements.txt
-r {toxinidir}/docs-requirements.txt

changedir = docs

commands =
sphinx-build -E -a -W -b html -T . _build/html

[testenv:tracecontext]
basepython: python3.10
basepython: python3
deps =
# needed for tracecontext
aiohttp~=3.6
Expand All @@ -283,11 +275,11 @@ commands =

[testenv:docker-tests-proto{3,4}]
deps =
pytest
pytest==7.1.3
# Pinning PyYAML for issue: https://github.com/yaml/pyyaml/issues/724
PyYAML == 5.3.1
docker-compose >= 1.25.2
requests < 2.29.0
PyYAML==5.3.1
docker-compose==1.29.2
requests==2.28.2

; proto 3 and 4 tests install the respective version of protobuf
proto3: protobuf~=3.19.0
Expand Down Expand Up @@ -319,9 +311,9 @@ commands_post =
docker-compose down -v

[testenv:public-symbols-check]
basepython: python3.10
basepython: python3
recreate = True
deps =
GitPython
GitPython==3.1.40
commands =
python {toxinidir}/scripts/public_symbols_checker.py

0 comments on commit 89c30fd

Please sign in to comment.