diff --git a/dev-requirements.txt b/dev-requirements.txt index 22595d5af2b..44e20801416 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ pylint==2.11.0 flake8~=3.7 isort~=5.8 -black~=21.7b0 +black~=22.1.0 httpretty~=1.0 mypy==0.812 sphinx~=3.5.4 diff --git a/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py b/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py index 65eef76d0fa..3eb59755c96 100644 --- a/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py +++ b/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py @@ -39,7 +39,7 @@ def _nsec_to_usec_round(nsec: int) -> int: """Round nanoseconds to microseconds""" - return (nsec + 500) // 10 ** 3 + return (nsec + 500) // 10**3 def _convert_int_to_i64(val): diff --git a/exporter/opentelemetry-exporter-jaeger-proto-grpc/tests/test_jaeger_exporter_protobuf.py b/exporter/opentelemetry-exporter-jaeger-proto-grpc/tests/test_jaeger_exporter_protobuf.py index 4448b2c838c..926bbff085e 100644 --- a/exporter/opentelemetry-exporter-jaeger-proto-grpc/tests/test_jaeger_exporter_protobuf.py +++ b/exporter/opentelemetry-exporter-jaeger-proto-grpc/tests/test_jaeger_exporter_protobuf.py @@ -108,13 +108,13 @@ def test_translate_to_jaeger(self): parent_id = 0x1111111111111111 other_id = 0x2222222222222222 - base_time = 683647322 * 10 ** 9 # in ns + base_time = 683647322 * 10**9 # in ns start_times = ( base_time, - base_time + 150 * 10 ** 6, - base_time + 300 * 10 ** 6, + base_time + 150 * 10**6, + base_time + 300 * 10**6, ) - durations = (50 * 10 ** 6, 100 * 10 ** 6, 200 * 10 ** 6) + durations = (50 * 10**6, 100 * 10**6, 200 * 10**6) end_times = ( start_times[0] + durations[0], start_times[1] + durations[1], @@ -139,7 +139,7 @@ def test_translate_to_jaeger(self): ] ) - event_timestamp = base_time + 50 * 10 ** 6 + event_timestamp = base_time + 50 * 10**6 # pylint:disable=protected-access event_timestamp_proto = ( pb_translator._proto_timestamp_from_epoch_nanos(event_timestamp) diff --git a/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py b/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py index f21ede6f8b4..1649b000e91 100644 --- a/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py +++ b/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py @@ -36,7 +36,7 @@ def _nsec_to_usec_round(nsec: int) -> int: """Round nanoseconds to microseconds""" - return (nsec + 500) // 10 ** 3 + return (nsec + 500) // 10**3 def _convert_int_to_i64(val): diff --git a/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py b/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py index 8a30527eebc..8bd3e3e359d 100644 --- a/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py +++ b/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py @@ -230,13 +230,13 @@ def test_translate_to_jaeger(self): parent_id = 0x1111111111111111 other_id = 0x2222222222222222 - base_time = 683647322 * 10 ** 9 # in ns + base_time = 683647322 * 10**9 # in ns start_times = ( base_time, - base_time + 150 * 10 ** 6, - base_time + 300 * 10 ** 6, + base_time + 150 * 10**6, + base_time + 300 * 10**6, ) - durations = (50 * 10 ** 6, 100 * 10 ** 6, 200 * 10 ** 6) + durations = (50 * 10**6, 100 * 10**6, 200 * 10**6) end_times = ( start_times[0] + durations[0], start_times[1] + durations[1], @@ -259,7 +259,7 @@ def test_translate_to_jaeger(self): "key_float": 0.3, } - event_timestamp = base_time + 50 * 10 ** 6 + event_timestamp = base_time + 50 * 10**6 event = trace.Event( name="event0", timestamp=event_timestamp, @@ -338,8 +338,8 @@ def test_translate_to_jaeger(self): traceIdLow=trace_id_low, spanId=span_id, parentSpanId=parent_id, - startTime=start_times[0] // 10 ** 3, - duration=durations[0] // 10 ** 3, + startTime=start_times[0] // 10**3, + duration=durations[0] // 10**3, flags=0, tags=[ jaeger.Tag( @@ -394,7 +394,7 @@ def test_translate_to_jaeger(self): ], logs=[ jaeger.Log( - timestamp=event_timestamp // 10 ** 3, + timestamp=event_timestamp // 10**3, fields=[ jaeger.Tag( key="annotation_bool", @@ -426,8 +426,8 @@ def test_translate_to_jaeger(self): traceIdLow=trace_id_low, spanId=parent_id, parentSpanId=0, - startTime=start_times[1] // 10 ** 3, - duration=durations[1] // 10 ** 3, + startTime=start_times[1] // 10**3, + duration=durations[1] // 10**3, flags=0, tags=default_tags, ), @@ -437,8 +437,8 @@ def test_translate_to_jaeger(self): traceIdLow=trace_id_low, spanId=other_id, parentSpanId=0, - startTime=start_times[2] // 10 ** 3, - duration=durations[2] // 10 ** 3, + startTime=start_times[2] // 10**3, + duration=durations[2] // 10**3, flags=0, tags=[ jaeger.Tag( diff --git a/exporter/opentelemetry-exporter-opencensus/tests/test_otcollector_trace_exporter.py b/exporter/opentelemetry-exporter-opencensus/tests/test_otcollector_trace_exporter.py index cd4dcb1a08c..fa546cde7a2 100644 --- a/exporter/opentelemetry-exporter-opencensus/tests/test_otcollector_trace_exporter.py +++ b/exporter/opentelemetry-exporter-opencensus/tests/test_otcollector_trace_exporter.py @@ -84,13 +84,13 @@ def test_translate_to_collector(self): trace_id = 0x6E0C63257DE34C926F9EFCD03927272E span_id = 0x34BF92DEEFC58C92 parent_id = 0x1111111111111111 - base_time = 683647322 * 10 ** 9 # in ns + base_time = 683647322 * 10**9 # in ns start_times = ( base_time, - base_time + 150 * 10 ** 6, - base_time + 300 * 10 ** 6, + base_time + 150 * 10**6, + base_time + 300 * 10**6, ) - durations = (50 * 10 ** 6, 100 * 10 ** 6, 200 * 10 ** 6) + durations = (50 * 10**6, 100 * 10**6, 200 * 10**6) end_times = ( start_times[0] + durations[0], start_times[1] + durations[1], @@ -114,7 +114,7 @@ def test_translate_to_collector(self): "annotation_string": "annotation_test", "key_float": 0.3, } - event_timestamp = base_time + 50 * 10 ** 6 + event_timestamp = base_time + 50 * 10**6 event = trace.Event( name="event0", timestamp=event_timestamp, diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_protobuf_encoder.py b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_protobuf_encoder.py index f2d2445677c..a6ebc051452 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_protobuf_encoder.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/tests/test_protobuf_encoder.py @@ -80,18 +80,18 @@ def test_content_type(self): def get_exhaustive_otel_span_list() -> List[SDKSpan]: trace_id = 0x3E0C63257DE34C926F9EFCD03927272E - base_time = 683647322 * 10 ** 9 # in ns + base_time = 683647322 * 10**9 # in ns start_times = ( base_time, - base_time + 150 * 10 ** 6, - base_time + 300 * 10 ** 6, - base_time + 400 * 10 ** 6, + base_time + 150 * 10**6, + base_time + 300 * 10**6, + base_time + 400 * 10**6, ) end_times = ( - start_times[0] + (50 * 10 ** 6), - start_times[1] + (100 * 10 ** 6), - start_times[2] + (200 * 10 ** 6), - start_times[3] + (300 * 10 ** 6), + start_times[0] + (50 * 10**6), + start_times[1] + (100 * 10**6), + start_times[2] + (200 * 10**6), + start_times[3] + (300 * 10**6), ) parent_span_context = SDKSpanContext( @@ -114,7 +114,7 @@ def get_exhaustive_otel_span_list() -> List[SDKSpan]: events=( SDKEvent( name="event0", - timestamp=base_time + 50 * 10 ** 6, + timestamp=base_time + 50 * 10**6, attributes={ "annotation_bool": True, "annotation_string": "annotation_test", diff --git a/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/encoder/__init__.py b/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/encoder/__init__.py index 07ad735ece8..5353a896cf8 100644 --- a/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/encoder/__init__.py +++ b/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/encoder/__init__.py @@ -256,7 +256,7 @@ def _nsec_to_usec_round(nsec: int) -> int: Timestamp in zipkin spans is int of microseconds. See: https://zipkin.io/pages/instrumenting.html """ - return (nsec + 500) // 10 ** 3 + return (nsec + 500) // 10**3 class JsonEncoder(Encoder): diff --git a/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/common_tests.py b/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/common_tests.py index a04148b6ea4..8eaa5b1563b 100644 --- a/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/common_tests.py +++ b/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/common_tests.py @@ -96,15 +96,15 @@ def test_constructor_max_tag_value_length(self): ) def test_nsec_to_usec_round(self): - base_time_nsec = 683647322 * 10 ** 9 + base_time_nsec = 683647322 * 10**9 for nsec in ( base_time_nsec, - base_time_nsec + 150 * 10 ** 6, - base_time_nsec + 300 * 10 ** 6, - base_time_nsec + 400 * 10 ** 6, + base_time_nsec + 150 * 10**6, + base_time_nsec + 300 * 10**6, + base_time_nsec + 400 * 10**6, ): self.assertEqual( - (nsec + 500) // 10 ** 3, + (nsec + 500) // 10**3, self.get_encoder_default()._nsec_to_usec_round(nsec), ) @@ -168,8 +168,8 @@ def test_get_parent_id_from_span_context(self): def get_data_for_max_tag_length_test( max_tag_length: int, ) -> (trace._Span, Dict): - start_time = 683647322 * 10 ** 9 # in ns - duration = 50 * 10 ** 6 + start_time = 683647322 * 10**9 # in ns + duration = 50 * 10**6 end_time = start_time + duration span = trace._Span( @@ -332,18 +332,18 @@ def get_data_for_max_tag_length_test( def get_exhaustive_otel_span_list() -> List[trace._Span]: trace_id = 0x6E0C63257DE34C926F9EFCD03927272E - base_time = 683647322 * 10 ** 9 # in ns + base_time = 683647322 * 10**9 # in ns start_times = ( base_time, - base_time + 150 * 10 ** 6, - base_time + 300 * 10 ** 6, - base_time + 400 * 10 ** 6, + base_time + 150 * 10**6, + base_time + 300 * 10**6, + base_time + 400 * 10**6, ) end_times = ( - start_times[0] + (50 * 10 ** 6), - start_times[1] + (100 * 10 ** 6), - start_times[2] + (200 * 10 ** 6), - start_times[3] + (300 * 10 ** 6), + start_times[0] + (50 * 10**6), + start_times[1] + (100 * 10**6), + start_times[2] + (200 * 10**6), + start_times[3] + (300 * 10**6), ) parent_span_context = trace_api.SpanContext( @@ -366,7 +366,7 @@ def get_exhaustive_otel_span_list() -> List[trace._Span]: events=( trace.Event( name="event0", - timestamp=base_time + 50 * 10 ** 6, + timestamp=base_time + 50 * 10**6, attributes={ "annotation_bool": True, "annotation_string": "annotation_test", @@ -429,14 +429,14 @@ def get_exhaustive_otel_span_list() -> List[trace._Span]: # pylint: disable=W0223 class CommonJsonEncoderTest(CommonEncoderTest, abc.ABC): def test_encode_trace_id(self): - for trace_id in (1, 1024, 2 ** 32, 2 ** 64, 2 ** 65): + for trace_id in (1, 1024, 2**32, 2**64, 2**65): self.assertEqual( format(trace_id, "032x"), self.get_encoder_default()._encode_trace_id(trace_id), ) def test_encode_span_id(self): - for span_id in (1, 1024, 2 ** 8, 2 ** 16, 2 ** 32, 2 ** 64): + for span_id in (1, 1024, 2**8, 2**16, 2**32, 2**64): self.assertEqual( format(span_id, "016x"), self.get_encoder_default()._encode_span_id(span_id), diff --git a/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v1_json.py b/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v1_json.py index a7e0480f0e2..b099040acc9 100644 --- a/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v1_json.py +++ b/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v1_json.py @@ -48,13 +48,13 @@ def test_encode(self): otel_spans[0].context.span_id ), "name": otel_spans[0].name, - "timestamp": otel_spans[0].start_time // 10 ** 3, - "duration": (otel_spans[0].end_time // 10 ** 3) - - (otel_spans[0].start_time // 10 ** 3), + "timestamp": otel_spans[0].start_time // 10**3, + "duration": (otel_spans[0].end_time // 10**3) + - (otel_spans[0].start_time // 10**3), "annotations": [ { "timestamp": otel_spans[0].events[0].timestamp - // 10 ** 3, + // 10**3, "value": json.dumps( { "event0": { @@ -101,9 +101,9 @@ def test_encode(self): otel_spans[1].context.span_id ), "name": otel_spans[1].name, - "timestamp": otel_spans[1].start_time // 10 ** 3, - "duration": (otel_spans[1].end_time // 10 ** 3) - - (otel_spans[1].start_time // 10 ** 3), + "timestamp": otel_spans[1].start_time // 10**3, + "duration": (otel_spans[1].end_time // 10**3) + - (otel_spans[1].start_time // 10**3), "binaryAnnotations": [ { "key": "key_resource", @@ -128,9 +128,9 @@ def test_encode(self): otel_spans[2].context.span_id ), "name": otel_spans[2].name, - "timestamp": otel_spans[2].start_time // 10 ** 3, - "duration": (otel_spans[2].end_time // 10 ** 3) - - (otel_spans[2].start_time // 10 ** 3), + "timestamp": otel_spans[2].start_time // 10**3, + "duration": (otel_spans[2].end_time // 10**3) + - (otel_spans[2].start_time // 10**3), "binaryAnnotations": [ { "key": "key_string", @@ -150,9 +150,9 @@ def test_encode(self): otel_spans[3].context.span_id ), "name": otel_spans[3].name, - "timestamp": otel_spans[3].start_time // 10 ** 3, - "duration": (otel_spans[3].end_time // 10 ** 3) - - (otel_spans[3].start_time // 10 ** 3), + "timestamp": otel_spans[3].start_time // 10**3, + "duration": (otel_spans[3].end_time // 10**3) + - (otel_spans[3].start_time // 10**3), "binaryAnnotations": [ { "key": NAME_KEY, @@ -177,8 +177,8 @@ def test_encode_id_zero_padding(self): trace_id = 0x0E0C63257DE34C926F9EFCD03927272E span_id = 0x04BF92DEEFC58C92 parent_id = 0x0AAAAAAAAAAAAAAA - start_time = 683647322 * 10 ** 9 # in ns - duration = 50 * 10 ** 6 + start_time = 683647322 * 10**9 # in ns + duration = 50 * 10**6 end_time = start_time + duration otel_span = trace._Span( diff --git a/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v2_json.py b/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v2_json.py index 2898604a25b..9ceb9383fd6 100644 --- a/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v2_json.py +++ b/exporter/opentelemetry-exporter-zipkin-json/tests/encoder/test_v2_json.py @@ -48,9 +48,9 @@ def test_encode(self): otel_spans[0].context.span_id ), "name": otel_spans[0].name, - "timestamp": otel_spans[0].start_time // 10 ** 3, - "duration": (otel_spans[0].end_time // 10 ** 3) - - (otel_spans[0].start_time // 10 ** 3), + "timestamp": otel_spans[0].start_time // 10**3, + "duration": (otel_spans[0].end_time // 10**3) + - (otel_spans[0].start_time // 10**3), "localEndpoint": local_endpoint, "kind": span_kind, "tags": { @@ -62,7 +62,7 @@ def test_encode(self): "annotations": [ { "timestamp": otel_spans[0].events[0].timestamp - // 10 ** 3, + // 10**3, "value": json.dumps( { "event0": { @@ -86,9 +86,9 @@ def test_encode(self): otel_spans[1].context.span_id ), "name": otel_spans[1].name, - "timestamp": otel_spans[1].start_time // 10 ** 3, - "duration": (otel_spans[1].end_time // 10 ** 3) - - (otel_spans[1].start_time // 10 ** 3), + "timestamp": otel_spans[1].start_time // 10**3, + "duration": (otel_spans[1].end_time // 10**3) + - (otel_spans[1].start_time // 10**3), "localEndpoint": local_endpoint, "kind": span_kind, "tags": { @@ -103,9 +103,9 @@ def test_encode(self): otel_spans[2].context.span_id ), "name": otel_spans[2].name, - "timestamp": otel_spans[2].start_time // 10 ** 3, - "duration": (otel_spans[2].end_time // 10 ** 3) - - (otel_spans[2].start_time // 10 ** 3), + "timestamp": otel_spans[2].start_time // 10**3, + "duration": (otel_spans[2].end_time // 10**3) + - (otel_spans[2].start_time // 10**3), "localEndpoint": local_endpoint, "kind": span_kind, "tags": { @@ -119,9 +119,9 @@ def test_encode(self): otel_spans[3].context.span_id ), "name": otel_spans[3].name, - "timestamp": otel_spans[3].start_time // 10 ** 3, - "duration": (otel_spans[3].end_time // 10 ** 3) - - (otel_spans[3].start_time // 10 ** 3), + "timestamp": otel_spans[3].start_time // 10**3, + "duration": (otel_spans[3].end_time // 10**3) + - (otel_spans[3].start_time // 10**3), "localEndpoint": local_endpoint, "kind": span_kind, "tags": {NAME_KEY: "name", VERSION_KEY: "version"}, @@ -137,8 +137,8 @@ def test_encode_id_zero_padding(self): trace_id = 0x0E0C63257DE34C926F9EFCD03927272E span_id = 0x04BF92DEEFC58C92 parent_id = 0x0AAAAAAAAAAAAAAA - start_time = 683647322 * 10 ** 9 # in ns - duration = 50 * 10 ** 6 + start_time = 683647322 * 10**9 # in ns + duration = 50 * 10**6 end_time = start_time + duration otel_span = trace._Span( diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/common_tests.py b/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/common_tests.py index a04148b6ea4..8eaa5b1563b 100644 --- a/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/common_tests.py +++ b/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/common_tests.py @@ -96,15 +96,15 @@ def test_constructor_max_tag_value_length(self): ) def test_nsec_to_usec_round(self): - base_time_nsec = 683647322 * 10 ** 9 + base_time_nsec = 683647322 * 10**9 for nsec in ( base_time_nsec, - base_time_nsec + 150 * 10 ** 6, - base_time_nsec + 300 * 10 ** 6, - base_time_nsec + 400 * 10 ** 6, + base_time_nsec + 150 * 10**6, + base_time_nsec + 300 * 10**6, + base_time_nsec + 400 * 10**6, ): self.assertEqual( - (nsec + 500) // 10 ** 3, + (nsec + 500) // 10**3, self.get_encoder_default()._nsec_to_usec_round(nsec), ) @@ -168,8 +168,8 @@ def test_get_parent_id_from_span_context(self): def get_data_for_max_tag_length_test( max_tag_length: int, ) -> (trace._Span, Dict): - start_time = 683647322 * 10 ** 9 # in ns - duration = 50 * 10 ** 6 + start_time = 683647322 * 10**9 # in ns + duration = 50 * 10**6 end_time = start_time + duration span = trace._Span( @@ -332,18 +332,18 @@ def get_data_for_max_tag_length_test( def get_exhaustive_otel_span_list() -> List[trace._Span]: trace_id = 0x6E0C63257DE34C926F9EFCD03927272E - base_time = 683647322 * 10 ** 9 # in ns + base_time = 683647322 * 10**9 # in ns start_times = ( base_time, - base_time + 150 * 10 ** 6, - base_time + 300 * 10 ** 6, - base_time + 400 * 10 ** 6, + base_time + 150 * 10**6, + base_time + 300 * 10**6, + base_time + 400 * 10**6, ) end_times = ( - start_times[0] + (50 * 10 ** 6), - start_times[1] + (100 * 10 ** 6), - start_times[2] + (200 * 10 ** 6), - start_times[3] + (300 * 10 ** 6), + start_times[0] + (50 * 10**6), + start_times[1] + (100 * 10**6), + start_times[2] + (200 * 10**6), + start_times[3] + (300 * 10**6), ) parent_span_context = trace_api.SpanContext( @@ -366,7 +366,7 @@ def get_exhaustive_otel_span_list() -> List[trace._Span]: events=( trace.Event( name="event0", - timestamp=base_time + 50 * 10 ** 6, + timestamp=base_time + 50 * 10**6, attributes={ "annotation_bool": True, "annotation_string": "annotation_test", @@ -429,14 +429,14 @@ def get_exhaustive_otel_span_list() -> List[trace._Span]: # pylint: disable=W0223 class CommonJsonEncoderTest(CommonEncoderTest, abc.ABC): def test_encode_trace_id(self): - for trace_id in (1, 1024, 2 ** 32, 2 ** 64, 2 ** 65): + for trace_id in (1, 1024, 2**32, 2**64, 2**65): self.assertEqual( format(trace_id, "032x"), self.get_encoder_default()._encode_trace_id(trace_id), ) def test_encode_span_id(self): - for span_id in (1, 1024, 2 ** 8, 2 ** 16, 2 ** 32, 2 ** 64): + for span_id in (1, 1024, 2**8, 2**16, 2**32, 2**64): self.assertEqual( format(span_id, "016x"), self.get_encoder_default()._encode_span_id(span_id), diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/test_v2_protobuf.py b/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/test_v2_protobuf.py index 787566e7109..4ba1ea220a2 100644 --- a/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/test_v2_protobuf.py +++ b/exporter/opentelemetry-exporter-zipkin-proto-http/tests/encoder/test_v2_protobuf.py @@ -33,14 +33,14 @@ def get_encoder(*args, **kwargs) -> ProtobufEncoder: return ProtobufEncoder(*args, **kwargs) def test_encode_trace_id(self): - for trace_id in (1, 1024, 2 ** 32, 2 ** 64, 2 ** 127): + for trace_id in (1, 1024, 2**32, 2**64, 2**127): self.assertEqual( self.get_encoder_default()._encode_trace_id(trace_id), trace_id.to_bytes(length=16, byteorder="big", signed=False), ) def test_encode_span_id(self): - for span_id in (1, 1024, 2 ** 8, 2 ** 16, 2 ** 32, 2 ** 63): + for span_id in (1, 1024, 2**8, 2**16, 2**32, 2**63): self.assertEqual( self.get_encoder_default()._encode_span_id(span_id), span_id.to_bytes(length=8, byteorder="big", signed=False), diff --git a/opentelemetry-api/src/opentelemetry/trace/span.py b/opentelemetry-api/src/opentelemetry/trace/span.py index 23eac7337ed..228e505281c 100644 --- a/opentelemetry-api/src/opentelemetry/trace/span.py +++ b/opentelemetry-api/src/opentelemetry/trace/span.py @@ -387,8 +387,8 @@ def values(self) -> typing.ValuesView[str]: DEFAULT_TRACE_STATE = TraceState.get_default() -_TRACE_ID_MAX_VALUE = 2 ** 128 - 1 -_SPAN_ID_MAX_VALUE = 2 ** 64 - 1 +_TRACE_ID_MAX_VALUE = 2**128 - 1 +_SPAN_ID_MAX_VALUE = 2**64 - 1 class SpanContext( diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py b/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py index 7f565ba8ea3..d634e1b8330 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.py @@ -40,15 +40,11 @@ def __hash__(self): return hash((self._name, self._version, self._schema_url)) def __eq__(self, value): - return ( - type(value) is type(self) - and ( - self._name, - self._version, - self._schema_url, - ) - == (value._name, value._version, value._schema_url) - ) + return type(value) is type(self) and ( + self._name, + self._version, + self._schema_url, + ) == (value._name, value._version, value._schema_url) def __lt__(self, value): if type(value) is not type(self): diff --git a/opentelemetry-sdk/tests/trace/test_sampling.py b/opentelemetry-sdk/tests/trace/test_sampling.py index ba6c5f5636a..c5f922c8e5c 100644 --- a/opentelemetry-sdk/tests/trace/test_sampling.py +++ b/opentelemetry-sdk/tests/trace/test_sampling.py @@ -255,7 +255,7 @@ def test_probability_sampler_limits(self): # Sample one of every 2^64 (= 5e-20) traces. This is the lowest # possible meaningful sampling rate, only traces with trace ID 0x0 # should get sampled. - almost_always_off = sampling.TraceIdRatioBased(2 ** -64) + almost_always_off = sampling.TraceIdRatioBased(2**-64) self.assertTrue( almost_always_off.should_sample( None, 0x0, "span name" @@ -267,7 +267,7 @@ def test_probability_sampler_limits(self): ).decision.is_sampled() ) self.assertEqual( - sampling.TraceIdRatioBased.get_bound_for_rate(2 ** -64), 0x1 + sampling.TraceIdRatioBased.get_bound_for_rate(2**-64), 0x1 ) # Sample every trace with trace ID less than 0xffffffffffffffff. In @@ -278,7 +278,7 @@ def test_probability_sampler_limits(self): # # 1 - sys.float_info.epsilon - almost_always_on = sampling.TraceIdRatioBased(1 - 2 ** -64) + almost_always_on = sampling.TraceIdRatioBased(1 - 2**-64) self.assertTrue( almost_always_on.should_sample( None, 0xFFFFFFFFFFFFFFFE, "span name" diff --git a/scripts/eachdist.py b/scripts/eachdist.py index 58064a7400d..427f990fe18 100755 --- a/scripts/eachdist.py +++ b/scripts/eachdist.py @@ -630,7 +630,7 @@ def update_dependencies(targets, version, packages): update_files( targets, "setup.cfg", - fr"({basename(pkg)}.*)==(.*)", + rf"({basename(pkg)}.*)==(.*)", r"\1== " + version, ) diff --git a/tests/opentelemetry-test-utils/setup.cfg b/tests/opentelemetry-test-utils/setup.cfg index cf5220fc3b8..dc2c84d6d47 100644 --- a/tests/opentelemetry-test-utils/setup.cfg +++ b/tests/opentelemetry-test-utils/setup.cfg @@ -42,7 +42,7 @@ install_requires = opentelemetry-sdk ~= 1.3 [options.extras_require] -test = flask~=1.0 +test = flask~=2.0 [options.packages.find] where = src