Repository: phidatahq/phidata
File: libs/agno/agno/knowledge/reader/text_reader.py (Python)

Code before:
        """Get the list of supported chunking strategies for Text readers."""
        return [
            ChunkingStrategyType.FIXED_SIZE_CHUNKER,
            ChunkingStrategyType.AGENTIC_CHUNKER,
            ChunkingStrategyType.DOCUMENT_CHUNKER,
            ChunkingStrategyType.RECURSIVE_CHUNKER,
            ChunkingStrategyType.SEMANTIC_CHUNKER,
        ]

    @classmethod
    def get_supported_content_types(self) -> List[ContentType]:
        return [ContentType.TXT]

    def read(self, file: Union[Path, IO[Any]], name: Optional[str] = None) -> List[Document]:
        try:
            if isinstance(file, Path):
                if not file.exists():
                    raise FileNotFoundError(f"Could not find file: {file}")
                log_debug(f"Reading: {file}")
                file_name = name or file.stem
                file_contents = file.read_text(self.encoding or "utf-8")
            else:
                # Handle BytesIO and other file-like objects that may not have a name attribute
                if name:
                    file_name = name
                elif hasattr(file, "name") and file.name:
                    file_name = file.name.split(".")[0]
                else:
                    file_name = "text_file"
                log_debug(f"Reading uploaded file: {file_name}")
                file.seek(0)
                file_contents = file.read().decode(self.encoding or "utf-8")

            documents = [
                Document(
                    name=file_name,
                    id=str(uuid.uuid4()),
                    content=file_contents,
                )
            ]
            if self.chunk:
                chunked_documents = []
                for document in documents:
                    chunked_documents.extend(self.chunk_document(document))
                return chunked_documents
            return documents
        except Exception as e:
            log_error(f"Error reading: {file}: {e}")
            return []

    async def async_read(self, file: Union[Path, IO[Any]], name: Optional[str] = None) -> List[Document]:

Review comment (suggestion):
Probably
```suggestion
                elif hasattr(file, "name") and file.name is not None:
```

Code after:
        """Get the list of supported chunking strategies for Text readers."""
        return [
            ChunkingStrategyType.FIXED_SIZE_CHUNKER,
            ChunkingStrategyType.AGENTIC_CHUNKER,
            ChunkingStrategyType.DOCUMENT_CHUNKER,
            ChunkingStrategyType.RECURSIVE_CHUNKER,
            ChunkingStrategyType.SEMANTIC_CHUNKER,
        ]

    @classmethod
    def get_supported_content_types(self) -> List[ContentType]:
        return [ContentType.TXT]

    def read(self, file: Union[Path, IO[Any]], name: Optional[str] = None) -> List[Document]:
        try:
            if isinstance(file, Path):
                if not file.exists():
                    raise FileNotFoundError(f"Could not find file: {file}")
                log_debug(f"Reading: {file}")
                file_name = name or file.stem
                file_contents = file.read_text(self.encoding or "utf-8")
            else:
                # Handle BytesIO and other file-like objects that may not have a name attribute
                if name:
                    file_name = name
                elif hasattr(file, "name") and file.name is not None:
                    file_name = file.name.split(".")[0]
                else:
                    file_name = "text_file"
                log_debug(f"Reading uploaded file: {file_name}")
                file.seek(0)
                file_contents = file.read().decode(self.encoding or "utf-8")

            documents = [
                Document(
                    name=file_name,
                    id=str(uuid.uuid4()),
                    content=file_contents,
                )
            ]
            if self.chunk:
                chunked_documents = []
                for document in documents:
                    chunked_documents.extend(self.chunk_document(document))
                return chunked_documents
            return documents
        except Exception as e:
            log_error(f"Error reading: {file}: {e}")
            return []

    async def async_read(self, file: Union[Path, IO[Any]], name: Optional[str] = None) -> List[Document]: