77import os
88import pathlib
99import re
10+ import subprocess
11+ import sys
1012import threading
1113import time
1214from typing import Callable , List , Optional
@@ -245,22 +247,22 @@ def _is_available_via_cli(self) -> bool:
245247 ],
246248 )
247249 return True
248- except CalledProcessError :
250+ except subprocess . CalledProcessError :
249251 return False
250252
251253
252- class RuffFormatter :
254+ class RuffFormatter ( Formatter ) :
253255 command = ["ruff" , "format" ]
254256
255257
256- class BlackFormatter :
258+ class BlackFormatter ( Formatter ) :
257259 command = ["black" ]
258260
259261
260262formatters = {"ruff" : RuffFormatter (), "black" : BlackFormatter ()}
261263
262264
263- def format_signature (signature : str , signature_formatter : str ) -> str :
265+ def format_signature (signature : str , config : dict , signature_formatter : str ) -> str :
264266 """Formats signature using ruff or black if either is available."""
265267 as_func = f"def { signature .strip ()} :\n pass"
266268 line_length = config .get ("line_length" , 88 )
@@ -286,7 +288,10 @@ def convert_signatures_to_markdown(signatures: List[str], config: dict) -> str:
286288 signature_formatter = config .get ("format" , "black" )
287289 if signature_formatter :
288290 signatures = [
289- format_signature (signature , config = config ) for signature in signatures
291+ format_signature (
292+ signature , signature_formatter = signature_formatter , config = config
293+ )
294+ for signature in signatures
290295 ]
291296 return wrap_signature ("\n " .join (signatures ))
292297
0 commit comments