Skip to content

Commit cc8fd88

Browse files
srikanthccvocelotl
andauthored
Update lint deps and configs (open-telemetry#3533)
Co-authored-by: Diego Hurtado <[email protected]>
1 parent c0576a0 commit cc8fd88

File tree

34 files changed

+88
-79
lines changed

34 files changed

+88
-79
lines changed

.pylintrc

+2-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ limit-inference-results=100
2828

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

3333
# Pickle collected data for later comparisons.
3434
persistent=yes
@@ -68,14 +68,14 @@ disable=missing-docstring,
6868
duplicate-code,
6969
ungrouped-imports, # Leave this up to isort
7070
wrong-import-order, # Leave this up to isort
71-
bad-continuation, # Leave this up to black
7271
line-too-long, # Leave this up to black
7372
exec-used,
7473
super-with-arguments, # temp-pylint-upgrade
7574
isinstance-second-argument-not-valid-type, # temp-pylint-upgrade
7675
raise-missing-from, # temp-pylint-upgrade
7776
unused-argument, # temp-pylint-upgrade
7877
redefined-builtin,
78+
cyclic-import,
7979

8080
# Enable the message, report, category or checker with the given id(s). You can
8181
# either give multiple identifier separated by comma (,) or put this option
@@ -263,13 +263,6 @@ max-line-length=79
263263
# Maximum number of lines in a module.
264264
max-module-lines=1000
265265

266-
# List of optional constructs for which whitespace checking is disabled. `dict-
267-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
268-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
269-
# `empty-line` allows space-only lines.
270-
no-space-check=trailing-comma,
271-
dict-separator
272-
273266
# Allow the body of a class to be on the same line as the declaration if body
274267
# contains single statement.
275268
single-line-class-stmt=no

dev-requirements.txt

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
pylint==2.11.0
2-
flake8~=3.7
3-
isort~=5.8
4-
black~=22.3.0
5-
httpretty~=1.0
1+
pylint==3.0.2
2+
flake8==6.1.0
3+
isort==5.12.0
4+
black==22.3.0
5+
httpretty==1.1.4
66
mypy==0.931
7-
sphinx~=3.5.4
8-
sphinx-rtd-theme~=0.5
9-
sphinx-autodoc-typehints~=1.12.0
7+
sphinx==7.1.2
8+
sphinx-rtd-theme==2.0.0rc4
9+
sphinx-autodoc-typehints==1.25.2
1010
pytest==7.1.3
11-
pytest-cov>=2.8
12-
readme-renderer~=24.0
13-
# This version of grpcio-tools ships with protoc 3.19.4 which appears to be compatible with
14-
# both protobuf 3.19.x and 4.x (see https://github.com/protocolbuffers/protobuf/issues/11123).
15-
# Bump this version with caution to preserve compatibility with protobuf 3.
16-
# https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-proto/pyproject.toml#L28
17-
grpcio-tools==1.48.1
18-
mypy-protobuf~=3.0.0
11+
pytest-cov==4.1.0
12+
readme-renderer==42.0
1913
# temporary fix. we should update the jinja, flask deps
2014
# See https://github.com/pallets/markupsafe/issues/282
2115
# breaking change introduced in markupsafe causes jinja, flask to break
@@ -24,3 +18,7 @@ bleach==4.1.0 # This dependency was updated to a breaking version.
2418
codespell==2.1.0
2519
requests==2.31.0
2620
ruamel.yaml==0.17.21
21+
asgiref==3.7.2
22+
psutil==5.9.6
23+
GitPython==3.1.40
24+
flaky==3.7.0

docs-requirements.txt

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
sphinx~=3.5.4
2-
sphinx-rtd-theme~=0.5
3-
sphinx-autodoc-typehints
1+
sphinx==7.1.2
2+
sphinx-rtd-theme==2.0.0rc4
3+
sphinx-autodoc-typehints==1.25.2
44
# used to generate docs for the website
5-
sphinx-jekyll-builder
5+
sphinx-jekyll-builder==0.3.0
66

77
# Need to install the api/sdk in the venv for autodoc. Modifying sys.path
88
# doesn't work for pkg_resources.
99
./opentelemetry-api
1010
./opentelemetry-semantic-conventions
1111
./opentelemetry-sdk
12+
./shim/opentelemetry-opencensus-shim
13+
./shim/opentelemetry-opentracing-shim
1214

1315
# Required by instrumentation and exporter packages
14-
ddtrace>=0.34.0
1516
grpcio~=1.27
16-
Deprecated>=1.2.6
17-
django>=2.2
17+
Deprecated~=1.2
18+
django~=4.2
1819
flask~=1.0
1920
opentracing~=2.2.0
20-
thrift>=0.10.0
21+
thrift~=0.10
2122
wrapt>=1.0.0,<2.0.0
2223
# temporary fix. we should update the jinja, flask deps
2324
# See https://github.com/pallets/markupsafe/issues/282

exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/send.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def __init__(self, thrift_url="", auth=None, timeout_in_millis=None):
125125
if auth is not None:
126126
auth_header = f"{auth[0]}:{auth[1]}"
127127
decoded = base64.b64encode(auth_header.encode()).decode("ascii")
128-
basic_auth = dict(Authorization=f"Basic {decoded}")
128+
basic_auth = {"Authorization": f"Basic {decoded}"}
129129
self.http_transport.setCustomHeaders(basic_auth)
130130

131131
def submit(self, batch: jaeger.Batch):

exporter/opentelemetry-exporter-jaeger/tests/__init__.py

Whitespace-only changes.

exporter/opentelemetry-exporter-otlp-proto-common/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ dependencies = [
3030
"backoff >= 1.10.0, < 3.0.0; python_version>='3.7'",
3131
]
3232

33+
[project.optional-dependencies]
34+
test = []
35+
3336
[project.urls]
3437
Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/exporter/opentelemetry-exporter-otlp-proto-common"
3538

exporter/opentelemetry-exporter-otlp-proto-common/tests/__init__.py

Whitespace-only changes.

exporter/opentelemetry-exporter-otlp-proto-http/tests/__init__.py

Whitespace-only changes.

exporter/opentelemetry-exporter-otlp-proto-http/tests/metrics/__init__.py

Whitespace-only changes.

exporter/opentelemetry-exporter-otlp/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ dependencies = [
3030
"opentelemetry-exporter-otlp-proto-http == 1.22.0.dev",
3131
]
3232

33+
[project.optional-dependencies]
34+
test = []
35+
3336
[project.entry-points.opentelemetry_logs_exporter]
3437
otlp = "opentelemetry.exporter.otlp.proto.grpc._log_exporter:OTLPLogExporter"
3538

exporter/opentelemetry-exporter-otlp/tests/__init__.py

Whitespace-only changes.

exporter/opentelemetry-exporter-zipkin/tests/__init__.py

Whitespace-only changes.

gen-requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This version of grpcio-tools ships with protoc 3.19.4 which appears to be compatible with
2+
# both protobuf 3.19.x and 4.x (see https://github.com/protocolbuffers/protobuf/issues/11123).
3+
# Bump this version with caution to preserve compatibility with protobuf 3.
4+
# https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-proto/pyproject.toml#L28
5+
grpcio-tools==1.48.1
6+
mypy-protobuf~=3.0.0

opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def get_logger_provider() -> LoggerProvider:
177177
"""Gets the current global :class:`~.LoggerProvider` object."""
178178
global _LOGGER_PROVIDER # pylint: disable=global-statement
179179
if _LOGGER_PROVIDER is None:
180-
if _OTEL_PYTHON_LOGGER_PROVIDER not in environ.keys():
180+
if _OTEL_PYTHON_LOGGER_PROVIDER not in environ:
181181
# TODO: return proxy
182182
_LOGGER_PROVIDER = NoOpLoggerProvider()
183183
return _LOGGER_PROVIDER

opentelemetry-api/src/opentelemetry/metrics/_internal/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
_logger = getLogger(__name__)
7676

7777

78+
# pylint: disable=invalid-name
7879
_ProxyInstrumentT = Union[
7980
_ProxyCounter,
8081
_ProxyHistogram,
@@ -760,7 +761,7 @@ def get_meter_provider() -> MeterProvider:
760761
"""Gets the current global :class:`~.MeterProvider` object."""
761762

762763
if _METER_PROVIDER is None:
763-
if OTEL_PYTHON_METER_PROVIDER not in environ.keys():
764+
if OTEL_PYTHON_METER_PROVIDER not in environ:
764765
return _PROXY_METER_PROVIDER
765766

766767
meter_provider: MeterProvider = _load_provider( # type: ignore

opentelemetry-api/src/opentelemetry/metrics/_internal/instrument.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class CallbackOptions:
5555

5656

5757
InstrumentT = TypeVar("InstrumentT", bound="Instrument")
58+
# pylint: disable=invalid-name
5859
CallbackT = Union[
5960
Callable[[CallbackOptions], Iterable[Observation]],
6061
Generator[Iterable[Observation], CallbackOptions, None],

opentelemetry-api/src/opentelemetry/propagators/textmap.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from opentelemetry.context.context import Context
1919

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

2324

opentelemetry-api/tests/context/test_contextvars_context.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
from opentelemetry import context
1818
from opentelemetry.context.contextvars_context import ContextVarsRuntimeContext
1919

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

2223

2324
class TestContextVarsContext(ContextTestCases.BaseTest):
25+
# pylint: disable=invalid-name
2426
def setUp(self) -> None:
2527
super().setUp()
2628
self.mock_runtime = patch.object(
@@ -30,6 +32,7 @@ def setUp(self) -> None:
3032
)
3133
self.mock_runtime.start()
3234

35+
# pylint: disable=invalid-name
3336
def tearDown(self) -> None:
3437
super().tearDown()
3538
self.mock_runtime.stop()

opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_no_traceparent_header(self):
3939
If no traceparent header is received, the vendor creates a new
4040
trace-id and parent-id that represents the current request.
4141
"""
42-
output = {} # type:typing.Dict[str, typing.List[str]]
42+
output: typing.Dict[str, typing.List[str]] = {}
4343
span = trace.get_current_span(FORMAT.extract(output))
4444
self.assertIsInstance(span.get_span_context(), trace.SpanContext)
4545

@@ -66,7 +66,7 @@ def test_headers_with_tracestate(self):
6666
span_context.trace_state, {"foo": "1", "bar": "2", "baz": "3"}
6767
)
6868
self.assertTrue(span_context.is_remote)
69-
output = {} # type:typing.Dict[str, str]
69+
output: typing.Dict[str, str] = {}
7070
span = trace.NonRecordingSpan(span_context)
7171

7272
ctx = trace.set_span_in_context(span)
@@ -145,7 +145,7 @@ def test_no_send_empty_tracestate(self):
145145
Empty and whitespace-only list members are allowed. Vendors MUST accept
146146
empty tracestate headers but SHOULD avoid sending them.
147147
"""
148-
output = {} # type:typing.Dict[str, str]
148+
output: typing.Dict[str, str] = {}
149149
span = trace.NonRecordingSpan(
150150
trace.SpanContext(self.TRACE_ID, self.SPAN_ID, is_remote=False)
151151
)
@@ -177,7 +177,7 @@ def test_format_not_supported(self):
177177

178178
def test_propagate_invalid_context(self):
179179
"""Do not propagate invalid trace context."""
180-
output = {} # type:typing.Dict[str, str]
180+
output: typing.Dict[str, str] = {}
181181
ctx = trace.set_span_in_context(trace.INVALID_SPAN)
182182
FORMAT.inject(output, context=ctx)
183183
self.assertFalse("traceparent" in output)

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ class BatchLogRecordProcessor(LogRecordProcessor):
166166
- :envvar:`OTEL_BLRP_EXPORT_TIMEOUT`
167167
"""
168168

169+
_queue: Deque[LogData]
170+
_flush_request: Optional[_FlushRequest]
171+
_log_records: List[Optional[LogData]]
172+
169173
def __init__(
170174
self,
171175
exporter: LogExporter,
@@ -201,20 +205,16 @@ def __init__(
201205
self._schedule_delay_millis = schedule_delay_millis
202206
self._max_export_batch_size = max_export_batch_size
203207
self._export_timeout_millis = export_timeout_millis
204-
self._queue = collections.deque(
205-
[], max_queue_size
206-
) # type: Deque[LogData]
208+
self._queue = collections.deque([], max_queue_size)
207209
self._worker_thread = threading.Thread(
208210
name="OtelBatchLogRecordProcessor",
209211
target=self.worker,
210212
daemon=True,
211213
)
212214
self._condition = threading.Condition(threading.Lock())
213215
self._shutdown = False
214-
self._flush_request = None # type: Optional[_FlushRequest]
215-
self._log_records = [
216-
None
217-
] * self._max_export_batch_size # type: List[Optional[LogData]]
216+
self._flush_request = None
217+
self._log_records = [None] * self._max_export_batch_size
218218
self._worker_thread.start()
219219
# Only available in *nix since py37.
220220
if hasattr(os, "register_at_fork"):
@@ -236,7 +236,7 @@ def _at_fork_reinit(self):
236236

237237
def worker(self):
238238
timeout = self._schedule_delay_millis / 1e3
239-
flush_request = None # type: Optional[_FlushRequest]
239+
flush_request: Optional[_FlushRequest] = None
240240
while not self._shutdown:
241241
with self._condition:
242242
if self._shutdown:

opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@
674674
675675
The :envvar:`OTEL_EXPERIMENTAL_RESOURCE_DETECTORS` is a comma-separated string
676676
of names of resource detectors. These names must be the same as the names of
677-
entry points for the `opentelemetry_resource_detector` entry point. This is an
677+
entry points for the ```opentelemetry_resource_detector``` entry point. This is an
678678
experimental feature and the name of this variable and its behavior can change
679679
in a non-backwards compatible way.
680680
"""

opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/aggregation.py

+1
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ def aggregate(self, measurement: Measurement) -> None:
646646

647647
# 3. Determine if a change of scale is needed.
648648
is_rescaling_needed = False
649+
low, high = 0, 0
649650

650651
if len(buckets) == 0:
651652
buckets.index_start = index

opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def to_json(self, indent=4) -> str:
170170
)
171171

172172

173+
# pylint: disable=invalid-name
173174
DataT = Union[Sum, Gauge, Histogram]
174175
DataPointT = Union[NumberDataPoint, HistogramDataPoint]
175176

opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,11 @@ def get_aggregated_resources(
365365
futures = [executor.submit(detector.detect) for detector in detectors]
366366
for detector_ind, future in enumerate(futures):
367367
detector = detectors[detector_ind]
368+
detected_resource: Resource = _EMPTY_RESOURCE
368369
try:
369370
detected_resource = future.result(timeout=timeout)
370371
# pylint: disable=broad-except
371372
except Exception as ex:
372-
detected_resource = _EMPTY_RESOURCE
373373
if detector.raise_on_error:
374374
raise ex
375375
logger.warning(

opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ class SynchronousMultiSpanProcessor(SpanProcessor):
140140
added.
141141
"""
142142

143+
_span_processors: Tuple[SpanProcessor, ...]
144+
143145
def __init__(self):
144146
# use a tuple to avoid race conditions when adding a new span and
145147
# iterating through it on "on_start" and "on_end".
146-
self._span_processors = () # type: Tuple[SpanProcessor, ...]
148+
self._span_processors = ()
147149
self._lock = threading.Lock()
148150

149151
def add_span_processor(self, span_processor: SpanProcessor) -> None:

opentelemetry-sdk/tests/trace/test_trace.py

+1
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,7 @@ def test_record_exception_with_attributes_and_timestamp(self):
12201220
self.assertEqual(1604238587112021089, exception_event.timestamp)
12211221

12221222
def test_record_exception_context_manager(self):
1223+
span = None
12231224
try:
12241225
with self.tracer.start_as_current_span("span") as span:
12251226
raise RuntimeError("example error")

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ exclude = '''
55
/( # generated files
66
.tox|
77
venv|
8+
venv.*|
9+
.venv.*|
10+
target.*|
811
.*/build/lib/.*|
912
exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/gen|
1013
exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/gen|

scripts/proto_codegen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ echo "Creating temporary virtualenv at $venv_dir using $(python3 --version)"
3232
python3 -m venv $venv_dir
3333
source $venv_dir/bin/activate
3434
python -m pip install \
35-
-c $repo_root/dev-requirements.txt \
35+
-c $repo_root/gen-requirements.txt \
3636
grpcio-tools mypy-protobuf
3737
echo 'python -m grpc_tools.protoc --version'
3838
python -m grpc_tools.protoc --version

scripts/update_sha.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
def get_sha(branch):
2727
url = API_URL + branch
28-
response = requests.get(url)
28+
response = requests.get(url, timeout=15)
2929
response.raise_for_status()
3030
return response.json()["sha"]
3131

shim/opentelemetry-opencensus-shim/tests/__init__.py

Whitespace-only changes.

shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ def from_context_manager(cls, manager: "ScopeManagerShim", span_cm):
387387
:meth:`opentelemetry.trace.use_span`.
388388
"""
389389

390+
# pylint: disable=unnecessary-dunder-call
390391
otel_span = span_cm.__enter__()
391392
span_context = SpanContextShim(otel_span.get_span_context())
392393
span = SpanShim(manager.tracer, span_context, otel_span)

shim/opentelemetry-opentracing-shim/tests/testbed/test_multiple_callbacks/test_threads.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def test_main(self):
5555
def task(self, interval, parent_span):
5656
logger.info("Starting task")
5757

58+
scope = None
5859
try:
5960
scope = self.tracer.scope_manager.activate(parent_span, False)
6061
with self.tracer.start_active_span("task"):

0 commit comments

Comments
 (0)