@@ -260,9 +260,12 @@ def _load_reporter_by_class(reporter_class: str) -> type[BaseReporter]:
260
260
}
261
261
262
262
263
- def _handle_force_color_no_color (reporters : list [reporters .BaseReporter ]) -> list [reporters .BaseReporter ]:
263
+ def _handle_force_color_no_color (
264
+ reporters : list [reporters .BaseReporter ],
265
+ ) -> list [reporters .BaseReporter ]:
264
266
"""
265
- Check ``NO_COLOR`` and ``FORCE_COLOR``, and return the modified reporter list accordingly.
267
+ Check ``NO_COLOR`` and ``FORCE_COLOR``, and return the modified reporter list
268
+ accordingly.
266
269
267
270
Rules are presented in this table:
268
271
+--------------+---------------+-----------------+------------------------------------------------------------+
@@ -290,19 +293,26 @@ def _handle_force_color_no_color(reporters: list[reporters.BaseReporter]) -> lis
290
293
force_color = False
291
294
292
295
final_reporters : list [reporters .BaseReporter ] = []
293
-
296
+
294
297
for idx , rep in enumerate (reporters ):
295
- if no_color and isinstance (rep , ColorizedTextReporter ) and rep .out .buffer is sys .stdout .buffer :
298
+ if (
299
+ no_color
300
+ and isinstance (rep , ColorizedTextReporter )
301
+ and rep .out .buffer is sys .stdout .buffer
302
+ ):
296
303
warnings .warn (
297
304
WARN_NO_COLOR_SET ,
298
305
ReporterWarning ,
299
306
stacklevel = 2 ,
300
307
)
301
308
final_reporters .append (TextReporter ())
302
309
303
-
304
310
# pylint: disable=unidiomatic-typecheck # Want explicit type check
305
- elif force_color and type (rep ) is TextReporter and rep .out .buffer is sys .stdout .buffer :
311
+ elif (
312
+ force_color
313
+ and type (rep ) is TextReporter
314
+ and rep .out .buffer is sys .stdout .buffer
315
+ ):
306
316
warnings .warn (
307
317
WARN_FORCE_COLOR_SET ,
308
318
ReporterWarning ,
@@ -312,7 +322,7 @@ def _handle_force_color_no_color(reporters: list[reporters.BaseReporter]) -> lis
312
322
313
323
else :
314
324
final_reporters .append (rep )
315
-
325
+
316
326
return final_reporters
317
327
318
328
0 commit comments