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

Upgraded black to 22.1.0 #2427

Merged
merged 2 commits into from
Jan 31, 2022
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: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
),
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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",
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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(
Expand Down
Loading