in usort/api.py [0:0]
def usort_string(data: str, config: Config, path: Optional[Path] = None) -> str:
r"""
Whenever possible use usort_bytes instead.
One does not just .read_text() Python source code. That will use the system
encoding, which if is not utf-8 would be in violation of pep 3120.
There are two additional cases where this function does the wrong thing, but you
won't notice on most modern file contents:
- a string unrepresentable in utf-8, e.g. "\ud800" is a single high surrogate
- a string with a valid pep 263 coding line, other than utf-8
DEPRECATED: use `usort()` directly, and and encode/decode bytes as necessary.
"""
warn("use usort() instead", DeprecationWarning, stacklevel=2)
result = usort(data=data.encode(), config=config, path=path)
if result.error:
raise result.error
return result.output.decode()