mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 21:10:27 -06:00
13 lines
234 B
Python
13 lines
234 B
Python
from typing import Union
|
|
|
|
|
|
def to_text(s: Union[str, bytes]) -> str:
|
|
return s if isinstance(s, str) else s.decode()
|
|
|
|
|
|
def to_bytes(s: Union[str, bytes]) -> bytes:
|
|
return s if isinstance(s, bytes) else s.encode()
|
|
|
|
|
|
n = to_text
|