[docs]classPythonLoader(TextLoader):"""Load `Python` files, respecting any non-default encoding if specified."""
[docs]def__init__(self,file_path:Union[str,Path]):"""Initialize with a file path. Args: file_path: The path to the file to load. """withopen(file_path,"rb")asf:encoding,_=tokenize.detect_encoding(f.readline)super().__init__(file_path=file_path,encoding=encoding)