Skip to content

Commit bfc932a

Browse files
committed
Add encoding parameter to readlines method signature
- Update Fs abstract method to accept encoding parameter with utf-8 default - Update PathFs and RecordFs implementations to support encoding parameter - Maintains backward compatibility with default utf-8 encoding - Addresses PR feedback for Python 3.9 and earlier compatibility
1 parent efc52a9 commit bfc932a

File tree

1 file changed

+4
-4
lines changed
  • aws_doc_sdk_examples_tools

1 file changed

+4
-4
lines changed

aws_doc_sdk_examples_tools/fs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def read(self, path: Path) -> str:
2828
pass
2929

3030
@abstractmethod
31-
def readlines(self, path: Path) -> List[str]:
31+
def readlines(self, path: Path, encoding: str = "utf-8") -> List[str]:
3232
pass
3333

3434
@abstractmethod
@@ -56,8 +56,8 @@ def read(self, path: Path) -> str:
5656
with path.open("r", encoding="utf-8") as file:
5757
return file.read()
5858

59-
def readlines(self, path: Path) -> List[str]:
60-
with path.open("r", encoding="utf-8") as file:
59+
def readlines(self, path: Path, encoding: str = "utf-8") -> List[str]:
60+
with path.open("r", encoding=encoding) as file:
6161
return file.readlines()
6262

6363
def write(self, path: Path, content: str):
@@ -95,7 +95,7 @@ def glob(self, path: Path, glob: str) -> Generator[Path, None, None]:
9595
def read(self, path: Path) -> str:
9696
return self.fs[path]
9797

98-
def readlines(self, path: Path) -> List[str]:
98+
def readlines(self, path: Path, encoding: str = "utf-8") -> List[str]:
9999
content = self.fs[path]
100100
return content.splitlines(keepends=True)
101101

0 commit comments

Comments
 (0)