@@ -145,19 +145,23 @@ def _lineno(self) -> int:
145145 return self .obj .alias_lineno or 0 # type: ignore[attr-defined]
146146 return self .obj .lineno or 0
147147
148- def _format_location (self ) -> str :
149- return f"{ Style .BRIGHT } { self ._location } { Style .RESET_ALL } :{ self ._lineno } "
148+ def _format_location (self , * , colors : bool = True ) -> str :
149+ bright = Style .BRIGHT if colors else ""
150+ reset = Style .RESET_ALL if colors else ""
151+ return f"{ bright } { self ._location } { reset } :{ self ._lineno } "
150152
151- def _format_title (self ) -> str :
153+ def _format_title (self , * , colors : bool = True ) -> str : # noqa: ARG002
152154 return self ._relative_path
153155
154- def _format_kind (self ) -> str :
155- return f"{ Fore .YELLOW } { self .kind .value } { Fore .RESET } "
156+ def _format_kind (self , * , colors : bool = True ) -> str :
157+ yellow = Fore .YELLOW if colors else ""
158+ reset = Fore .RESET if colors else ""
159+ return f"{ yellow } { self .kind .value } { reset } "
156160
157- def _format_old_value (self ) -> str :
161+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
158162 return str (self .old_value )
159163
160- def _format_new_value (self ) -> str :
164+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
161165 return str (self .new_value )
162166
163167 def _explain_oneline (self ) -> str :
@@ -196,10 +200,10 @@ def _explain_verbose(self) -> str:
196200
197201 def _explain_markdown (self ) -> str :
198202 explanation = f"- `{ self ._relative_path } `: *{ self .kind .value } *"
199- old = self ._format_old_value ()
203+ old = self ._format_old_value (colors = False )
200204 if old and old != "unset" :
201205 old = f"`{ old } `"
202- new = self ._format_new_value ()
206+ new = self ._format_new_value (colors = False )
203207 if new and new != "unset" :
204208 new = f"`{ new } `"
205209 if old and new :
@@ -216,12 +220,12 @@ def _explain_markdown(self) -> str:
216220
217221 def _explain_github (self ) -> str :
218222 location = f"file={ self ._location } ,line={ self ._lineno } "
219- title = f"title={ self ._format_title ()} "
223+ title = f"title={ self ._format_title (colors = False )} "
220224 explanation = f"::warning { location } ,{ title } ::{ self .kind .value } "
221- old = self ._format_old_value ()
225+ old = self ._format_old_value (colors = False )
222226 if old and old != "unset" :
223227 old = f"`{ old } `"
224- new = self ._format_new_value ()
228+ new = self ._format_new_value (colors = False )
225229 if new and new != "unset" :
226230 new = f"`{ new } `"
227231 if old and new :
@@ -246,13 +250,15 @@ class ParameterMovedBreakage(Breakage):
246250 def _relative_path (self ) -> str :
247251 return f"{ super ()._relative_path } ({ self .old_value .name } )"
248252
249- def _format_title (self ) -> str :
250- return f"{ super ()._relative_path } ({ Fore .BLUE } { self .old_value .name } { Fore .RESET } )"
253+ def _format_title (self , * , colors : bool = True ) -> str :
254+ blue = Fore .BLUE if colors else ""
255+ reset = Fore .RESET if colors else ""
256+ return f"{ super ()._relative_path } ({ blue } { self .old_value .name } { reset } )"
251257
252- def _format_old_value (self ) -> str :
258+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
253259 return ""
254260
255- def _format_new_value (self ) -> str :
261+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
256262 return ""
257263
258264
@@ -265,13 +271,15 @@ class ParameterRemovedBreakage(Breakage):
265271 def _relative_path (self ) -> str :
266272 return f"{ super ()._relative_path } ({ self .old_value .name } )"
267273
268- def _format_title (self ) -> str :
269- return f"{ super ()._relative_path } ({ Fore .BLUE } { self .old_value .name } { Fore .RESET } )"
274+ def _format_title (self , * , colors : bool = True ) -> str :
275+ blue = Fore .BLUE if colors else ""
276+ reset = Fore .RESET if colors else ""
277+ return f"{ super ()._relative_path } ({ blue } { self .old_value .name } { reset } )"
270278
271- def _format_old_value (self ) -> str :
279+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
272280 return ""
273281
274- def _format_new_value (self ) -> str :
282+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
275283 return ""
276284
277285
@@ -284,13 +292,15 @@ class ParameterChangedKindBreakage(Breakage):
284292 def _relative_path (self ) -> str :
285293 return f"{ super ()._relative_path } ({ self .old_value .name } )"
286294
287- def _format_title (self ) -> str :
288- return f"{ super ()._relative_path } ({ Fore .BLUE } { self .old_value .name } { Fore .RESET } )"
295+ def _format_title (self , * , colors : bool = True ) -> str :
296+ blue = Fore .BLUE if colors else ""
297+ reset = Fore .RESET if colors else ""
298+ return f"{ super ()._relative_path } ({ blue } { self .old_value .name } { reset } )"
289299
290- def _format_old_value (self ) -> str :
300+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
291301 return str (self .old_value .kind .value )
292302
293- def _format_new_value (self ) -> str :
303+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
294304 return str (self .new_value .kind .value )
295305
296306
@@ -303,13 +313,15 @@ class ParameterChangedDefaultBreakage(Breakage):
303313 def _relative_path (self ) -> str :
304314 return f"{ super ()._relative_path } ({ self .old_value .name } )"
305315
306- def _format_title (self ) -> str :
307- return f"{ super ()._relative_path } ({ Fore .BLUE } { self .old_value .name } { Fore .RESET } )"
316+ def _format_title (self , * , colors : bool = True ) -> str :
317+ blue = Fore .BLUE if colors else ""
318+ reset = Fore .RESET if colors else ""
319+ return f"{ super ()._relative_path } ({ blue } { self .old_value .name } { reset } )"
308320
309- def _format_old_value (self ) -> str :
321+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
310322 return str (self .old_value .default )
311323
312- def _format_new_value (self ) -> str :
324+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
313325 return str (self .new_value .default )
314326
315327
@@ -322,13 +334,15 @@ class ParameterChangedRequiredBreakage(Breakage):
322334 def _relative_path (self ) -> str :
323335 return f"{ super ()._relative_path } ({ self .old_value .name } )"
324336
325- def _format_title (self ) -> str :
326- return f"{ super ()._relative_path } ({ Fore .BLUE } { self .old_value .name } { Fore .RESET } )"
337+ def _format_title (self , * , colors : bool = True ) -> str :
338+ blue = Fore .BLUE if colors else ""
339+ reset = Fore .RESET if colors else ""
340+ return f"{ super ()._relative_path } ({ blue } { self .old_value .name } { reset } )"
327341
328- def _format_old_value (self ) -> str :
342+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
329343 return ""
330344
331- def _format_new_value (self ) -> str :
345+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
332346 return ""
333347
334348
@@ -341,13 +355,15 @@ class ParameterAddedRequiredBreakage(Breakage):
341355 def _relative_path (self ) -> str :
342356 return f"{ super ()._relative_path } ({ self .new_value .name } )"
343357
344- def _format_title (self ) -> str :
345- return f"{ super ()._relative_path } ({ Fore .BLUE } { self .new_value .name } { Fore .RESET } )"
358+ def _format_title (self , * , colors : bool = True ) -> str :
359+ blue = Fore .BLUE if colors else ""
360+ reset = Fore .RESET if colors else ""
361+ return f"{ super ()._relative_path } ({ blue } { self .new_value .name } { reset } )"
346362
347- def _format_old_value (self ) -> str :
363+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
348364 return ""
349365
350- def _format_new_value (self ) -> str :
366+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
351367 return ""
352368
353369
@@ -362,10 +378,10 @@ class ObjectRemovedBreakage(Breakage):
362378
363379 kind : BreakageKind = BreakageKind .OBJECT_REMOVED
364380
365- def _format_old_value (self ) -> str :
381+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
366382 return ""
367383
368- def _format_new_value (self ) -> str :
384+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
369385 return ""
370386
371387
@@ -374,10 +390,10 @@ class ObjectChangedKindBreakage(Breakage):
374390
375391 kind : BreakageKind = BreakageKind .OBJECT_CHANGED_KIND
376392
377- def _format_old_value (self ) -> str :
393+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
378394 return self .old_value .value
379395
380- def _format_new_value (self ) -> str :
396+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
381397 return self .new_value .value
382398
383399
@@ -398,10 +414,10 @@ class ClassRemovedBaseBreakage(Breakage):
398414
399415 kind : BreakageKind = BreakageKind .CLASS_REMOVED_BASE
400416
401- def _format_old_value (self ) -> str :
417+ def _format_old_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
402418 return "[" + ", " .join (base .canonical_path for base in self .old_value ) + "]"
403419
404- def _format_new_value (self ) -> str :
420+ def _format_new_value (self , * , colors : bool = True ) -> str : # noqa: ARG002
405421 return "[" + ", " .join (base .canonical_path for base in self .new_value ) + "]"
406422
407423
0 commit comments