We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 266f41f commit df24bbcCopy full SHA for df24bbc
src/mkdocstrings_handlers/python/rendering.py
@@ -351,14 +351,17 @@ def do_filter_objects(
351
@lru_cache(maxsize=1)
352
def _get_black_formatter() -> Callable[[str, int], str]:
353
try:
354
- from black import Mode, format_str
+ from black import InvalidInput, Mode, format_str
355
except ModuleNotFoundError:
356
logger.info("Formatting signatures requires Black to be installed.")
357
return lambda text, _: text
358
359
def formatter(code: str, line_length: int) -> str:
360
mode = Mode(line_length=line_length)
361
- return format_str(code, mode=mode)
+ try:
362
+ return format_str(code, mode=mode)
363
+ except InvalidInput:
364
+ return code
365
366
return formatter
367
0 commit comments