MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / stylify

Function stylify

diffusers/utils/check_copies.py:103–118  ·  view source on GitHub ↗

Applies the ruff part of our `make style` command to some code. This formats the code using `ruff format`. As `ruff` does not provide a python api this cannot be done on the fly. Args: code (`str`): The code to format. Returns: `str`: The formatted code.

(code: str)

Source from the content-addressed store, hash-verified

101
102
103def stylify(code: str) -> str:
104 """
105 Applies the ruff part of our `make style` command to some code. This formats the code using `ruff format`.
106 As `ruff` does not provide a python api this cannot be done on the fly.
107
108 Args:
109 code (`str`): The code to format.
110
111 Returns:
112 `str`: The formatted code.
113 """
114 has_indent = len(get_indent(code)) > 0
115 if has_indent:
116 code = f"class Bla:\n{code}"
117 formatted_code = run_ruff(code)
118 return formatted_code[len("class Bla:\n") :] if has_indent else formatted_code
119
120
121def is_copy_consistent(filename, overwrite=False):

Callers 1

is_copy_consistentFunction · 0.85

Calls 2

run_ruffFunction · 0.85
get_indentFunction · 0.70

Tested by

no test coverage detected