Skip to content

Commit 0095883

Browse files
committed
lint
1 parent 4c2c04f commit 0095883

File tree

3 files changed

+80
-42
lines changed

3 files changed

+80
-42
lines changed

opentelemetry-sdk/tests/logs/test_export.py

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,19 @@ def test_console_log_exporter_deprecated_warning(self):
656656
with warnings.catch_warnings(record=True) as cw:
657657
warnings.simplefilter("always")
658658
ConsoleLogExporter()
659-
659+
660660
# Check that at least one ConsoleLogExporterDeprecatedWarning was emitted
661661
console_warnings = [
662-
w for w in cw if isinstance(w.message, ConsoleLogExporterDeprecatedWarning)
662+
w
663+
for w in cw
664+
if isinstance(w.message, ConsoleLogExporterDeprecatedWarning)
663665
]
664-
self.assertGreater(len(console_warnings), 0,
665-
"Expected at least one ConsoleLogExporterDeprecatedWarning")
666-
666+
self.assertGreater(
667+
len(console_warnings),
668+
0,
669+
"Expected at least one ConsoleLogExporterDeprecatedWarning",
670+
)
671+
667672
# Check the message content of the ConsoleLogExporterDeprecatedWarning
668673
warning_message = str(console_warnings[0].message)
669674
self.assertIn(
@@ -677,14 +682,19 @@ def test_console_log_exporter_deprecated_warning_once(self):
677682
# Multiple instantiations should only warn once due to simplefilter("once")
678683
for _ in range(10):
679684
ConsoleLogExporter()
680-
685+
681686
# Check that exactly one ConsoleLogExporterDeprecatedWarning was emitted
682687
console_warnings = [
683-
w for w in cw if isinstance(w.message, ConsoleLogExporterDeprecatedWarning)
688+
w
689+
for w in cw
690+
if isinstance(w.message, ConsoleLogExporterDeprecatedWarning)
684691
]
685-
self.assertEqual(len(console_warnings), 1,
686-
"Expected exactly one ConsoleLogExporterDeprecatedWarning due to simplefilter('once')")
687-
692+
self.assertEqual(
693+
len(console_warnings),
694+
1,
695+
"Expected exactly one ConsoleLogExporterDeprecatedWarning due to simplefilter('once')",
696+
)
697+
688698
# Check the message content
689699
warning_message = str(console_warnings[0].message)
690700
self.assertIn(
@@ -699,14 +709,19 @@ def test_in_memory_log_exporter_deprecated_warning(self):
699709
with warnings.catch_warnings(record=True) as cw:
700710
warnings.simplefilter("always")
701711
InMemoryLogExporter()
702-
712+
703713
# Check that at least one InMemoryLogExporterDeprecatedWarning was emitted
704714
in_memory_warnings = [
705-
w for w in cw if isinstance(w.message, InMemoryLogExporterDeprecatedWarning)
715+
w
716+
for w in cw
717+
if isinstance(w.message, InMemoryLogExporterDeprecatedWarning)
706718
]
707-
self.assertGreater(len(in_memory_warnings), 0,
708-
"Expected at least one InMemoryLogExporterDeprecatedWarning")
709-
719+
self.assertGreater(
720+
len(in_memory_warnings),
721+
0,
722+
"Expected at least one InMemoryLogExporterDeprecatedWarning",
723+
)
724+
710725
# Check the message content of the InMemoryLogExporterDeprecatedWarning
711726
warning_message = str(in_memory_warnings[0].message)
712727
self.assertIn(
@@ -720,14 +735,19 @@ def test_in_memory_log_exporter_deprecated_warning_once(self):
720735
# Multiple instantiations should only warn once due to simplefilter("once")
721736
for _ in range(10):
722737
InMemoryLogExporter()
723-
738+
724739
# Check that exactly one InMemoryLogExporterDeprecatedWarning was emitted
725740
in_memory_warnings = [
726-
w for w in cw if isinstance(w.message, InMemoryLogExporterDeprecatedWarning)
741+
w
742+
for w in cw
743+
if isinstance(w.message, InMemoryLogExporterDeprecatedWarning)
727744
]
728-
self.assertEqual(len(in_memory_warnings), 1,
729-
"Expected exactly one InMemoryLogExporterDeprecatedWarning due to simplefilter('once')")
730-
745+
self.assertEqual(
746+
len(in_memory_warnings),
747+
1,
748+
"Expected exactly one InMemoryLogExporterDeprecatedWarning due to simplefilter('once')",
749+
)
750+
731751
# Check the message content
732752
warning_message = str(in_memory_warnings[0].message)
733753
self.assertIn(

opentelemetry-sdk/tests/logs/test_log_limits.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_log_limits_init_deprecated_warning(self):
7777
with warnings.catch_warnings(record=True) as cw:
7878
warnings.simplefilter("always")
7979
LogLimits()
80-
80+
8181
self.assertEqual(len(cw), 1)
8282
self.assertIsInstance(cw[-1].message, LogLimitsInitDeprecatedWarning)
8383
self.assertIn(
@@ -90,7 +90,7 @@ def test_log_limits_init_deprecated_warning_with_params(self):
9090
with warnings.catch_warnings(record=True) as cw:
9191
warnings.simplefilter("always")
9292
LogLimits(max_attributes=10, max_attribute_length=100)
93-
93+
9494
self.assertEqual(len(cw), 1)
9595
self.assertIsInstance(cw[-1].message, LogLimitsInitDeprecatedWarning)
9696
self.assertIn(
@@ -104,7 +104,7 @@ def test_log_limits_init_deprecated_warning_once(self):
104104
# Multiple instantiations should only warn once due to simplefilter("once")
105105
for _ in range(10):
106106
LogLimits()
107-
107+
108108
self.assertEqual(len(cw), 1)
109109
self.assertIsInstance(cw[-1].message, LogLimitsInitDeprecatedWarning)
110110
self.assertIn(

opentelemetry-sdk/tests/logs/test_log_record.py

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
from opentelemetry.attributes import BoundedAttributes
2222
from opentelemetry.context import get_current
2323
from opentelemetry.sdk._logs import (
24-
LogRecordContextDeprecatedWarning,
25-
LogRecordInitDeprecatedWarning,
2624
LogDroppedAttributesWarning,
2725
LogLimits,
2826
LogRecord,
27+
LogRecordContextDeprecatedWarning,
28+
LogRecordInitDeprecatedWarning,
2929
)
3030
from opentelemetry.sdk.resources import Resource
3131
from opentelemetry.trace.span import TraceFlags
@@ -143,14 +143,17 @@ def test_log_record_dropped_attributes_set_limits_warning_once(self):
143143
attributes=attr,
144144
limits=limits,
145145
)
146-
146+
147147
# Check that at least one LogDroppedAttributesWarning was emitted
148148
dropped_attributes_warnings = [
149149
w for w in cw if isinstance(w.message, LogDroppedAttributesWarning)
150150
]
151-
self.assertEqual(len(dropped_attributes_warnings), 1,
152-
"Expected exactly one LogDroppedAttributesWarning due to simplefilter('once')")
153-
151+
self.assertEqual(
152+
len(dropped_attributes_warnings),
153+
1,
154+
"Expected exactly one LogDroppedAttributesWarning due to simplefilter('once')",
155+
)
156+
154157
# Check the message content of the LogDroppedAttributesWarning
155158
warning_message = str(dropped_attributes_warnings[0].message)
156159
self.assertIn(
@@ -183,11 +186,16 @@ def test_log_record_context_deprecated_init_warning(self):
183186

184187
# Check that at least one LogRecordContextDeprecatedWarning was emitted
185188
context_deprecated_warnings = [
186-
w for w in cw if isinstance(w.message, LogRecordContextDeprecatedWarning)
189+
w
190+
for w in cw
191+
if isinstance(w.message, LogRecordContextDeprecatedWarning)
187192
]
188-
self.assertEqual(len(context_deprecated_warnings), 1,
189-
"Expected exactly one LogRecordContextDeprecatedWarning due to simplefilter('once')")
190-
193+
self.assertEqual(
194+
len(context_deprecated_warnings),
195+
1,
196+
"Expected exactly one LogRecordContextDeprecatedWarning due to simplefilter('once')",
197+
)
198+
191199
# Check the message content of the LogRecordContextDeprecatedWarning
192200
warning_message = str(context_deprecated_warnings[0].message)
193201
self.assertIn(
@@ -198,27 +206,37 @@ def test_log_record_context_deprecated_init_warning(self):
198206
with warnings.catch_warnings(record=True) as cw:
199207
for _ in range(10):
200208
LogRecord(context=get_current())
201-
209+
202210
# Check that no LogRecordContextDeprecatedWarning was emitted when using context
203211
context_deprecated_warnings = [
204-
w for w in cw if isinstance(w.message, LogRecordContextDeprecatedWarning)
212+
w
213+
for w in cw
214+
if isinstance(w.message, LogRecordContextDeprecatedWarning)
205215
]
206-
self.assertEqual(len(context_deprecated_warnings), 0,
207-
"Expected no LogRecordContextDeprecatedWarning when using context parameter")
216+
self.assertEqual(
217+
len(context_deprecated_warnings),
218+
0,
219+
"Expected no LogRecordContextDeprecatedWarning when using context parameter",
220+
)
208221

209222
def test_log_record_init_deprecated_warning(self):
210223
"""Test that LogRecord initialization emits a LogRecordInitDeprecatedWarning."""
211224
with warnings.catch_warnings(record=True) as cw:
212225
warnings.simplefilter("always")
213226
LogRecord()
214-
227+
215228
# Check that at least one LogRecordInitDeprecatedWarning was emitted
216229
log_record_init_warnings = [
217-
w for w in cw if isinstance(w.message, LogRecordInitDeprecatedWarning)
230+
w
231+
for w in cw
232+
if isinstance(w.message, LogRecordInitDeprecatedWarning)
218233
]
219-
self.assertGreater(len(log_record_init_warnings), 0,
220-
"Expected at least one LogRecordInitDeprecatedWarning")
221-
234+
self.assertGreater(
235+
len(log_record_init_warnings),
236+
0,
237+
"Expected at least one LogRecordInitDeprecatedWarning",
238+
)
239+
222240
# Check the message content of the LogRecordInitDeprecatedWarning
223241
warning_message = str(log_record_init_warnings[0].message)
224242
self.assertIn(

0 commit comments

Comments
 (0)