mirror of
https://github.com/Mintplex-Labs/langchain-python.git
synced 2026-07-21 16:55:25 -04:00
5eec74d9a5
- Updated docstrings for `document_loaders` - Mass update `"""Loader that loads` to `"""Loads` @baskaryan - please, review
20 lines
525 B
Python
20 lines
525 B
Python
import tokenize
|
|
|
|
from langchain.document_loaders.text import TextLoader
|
|
|
|
|
|
class PythonLoader(TextLoader):
|
|
"""
|
|
Load Python files, respecting any non-default encoding if specified.
|
|
"""
|
|
|
|
def __init__(self, file_path: str):
|
|
"""Initialize with a file path.
|
|
|
|
Args:
|
|
file_path: The path to the file to load.
|
|
"""
|
|
with open(file_path, "rb") as f:
|
|
encoding, _ = tokenize.detect_encoding(f.readline)
|
|
super().__init__(file_path=file_path, encoding=encoding)
|