This is a helper function for callables that use open() or TextIOWrapper and have an encoding=None parameter.
io.text_encoding(encoding, stacklevel=2, /)
def read_text(path, encoding=None):
encoding = io.text_encoding(encoding) stacklevel=2
with open(path, encoding) as f:
return f.read()