Skip to content

Commit 398861d

Browse files
Fixing constants
1 parent 961ae5c commit 398861d

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

aws_lambda_powertools/utilities/streaming/_s3_seekable_io.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from aws_lambda_powertools.shared import user_agent
1010
from aws_lambda_powertools.utilities.streaming.compat import PowertoolsStreamingBody
11+
from aws_lambda_powertools.utilities.streaming.constants import MESSAGE_STREAM_NOT_WRITABLE
1112

1213
if TYPE_CHECKING:
1314
from mmap import mmap
@@ -93,7 +94,7 @@ def size(self) -> int:
9394
@property
9495
def raw_stream(self) -> PowertoolsStreamingBody:
9596
"""
96-
Returns the boto3 StreamingBody, starting the stream from the seeked position.
97+
Returns the boto3 StreamingBody, starting the stream from the sought position.
9798
"""
9899
if self._raw_stream is None:
99100
range_header = f"bytes={self._position}-"
@@ -185,19 +186,19 @@ def fileno(self) -> int:
185186
raise NotImplementedError("this stream is not backed by a file descriptor")
186187

187188
def flush(self) -> None:
188-
raise NotImplementedError("this stream is not writable")
189+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)
189190

190191
def isatty(self) -> bool:
191192
return False
192193

193194
def truncate(self, size: int | None = 0) -> int:
194-
raise NotImplementedError("this stream is not writable")
195+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)
195196

196197
def write(self, data: bytes | bytearray | memoryview | Sequence[Any] | mmap | _CData) -> int:
197-
raise NotImplementedError("this stream is not writable")
198+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)
198199

199200
def writelines(
200201
self,
201202
data: Iterable[bytes | bytearray | memoryview | Sequence[Any] | mmap | _CData],
202203
) -> None:
203-
raise NotImplementedError("this stream is not writable")
204+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MESSAGE_STREAM_NOT_WRITABLE = "this stream is not writable"

aws_lambda_powertools/utilities/streaming/s3_object.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import IO, TYPE_CHECKING, Any, Iterable, Literal, Sequence, TypeVar, cast, overload
55

66
from aws_lambda_powertools.utilities.streaming._s3_seekable_io import _S3SeekableIO
7+
from aws_lambda_powertools.utilities.streaming.constants import MESSAGE_STREAM_NOT_WRITABLE
78
from aws_lambda_powertools.utilities.streaming.transformations import (
89
CsvTransform,
910
GzipTransform,
@@ -243,19 +244,19 @@ def fileno(self) -> int:
243244
raise NotImplementedError("this stream is not backed by a file descriptor")
244245

245246
def flush(self) -> None:
246-
raise NotImplementedError("this stream is not writable")
247+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)
247248

248249
def isatty(self) -> bool:
249250
return False
250251

251252
def truncate(self, size: int | None = 0) -> int:
252-
raise NotImplementedError("this stream is not writable")
253+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)
253254

254255
def write(self, data: bytes | bytearray | memoryview | Sequence[Any] | mmap | _CData) -> int:
255-
raise NotImplementedError("this stream is not writable")
256+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)
256257

257258
def writelines(
258259
self,
259260
data: Iterable[bytes | bytearray | memoryview | Sequence[Any] | mmap | _CData],
260261
) -> None:
261-
raise NotImplementedError("this stream is not writable")
262+
raise NotImplementedError(MESSAGE_STREAM_NOT_WRITABLE)

0 commit comments

Comments
 (0)