From 433b7fe614ea8587e8b76784e6289b852a742dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:42:57 -0400 Subject: [PATCH] chore: Make it easier to switch Singer reader and writer IO implementations in plugin classes (#2565) --- singer_sdk/_singerlib/encoding/__init__.py | 6 +++--- singer_sdk/_singerlib/encoding/_simple.py | 4 ++-- singer_sdk/_singerlib/messages.py | 2 +- singer_sdk/io_base.py | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/singer_sdk/_singerlib/encoding/__init__.py b/singer_sdk/_singerlib/encoding/__init__.py index 2d64c54dc..65ed5b767 100644 --- a/singer_sdk/_singerlib/encoding/__init__.py +++ b/singer_sdk/_singerlib/encoding/__init__.py @@ -1,12 +1,12 @@ from __future__ import annotations from ._base import GenericSingerReader, GenericSingerWriter, SingerMessageType -from ._simple import SingerReader, SingerWriter +from ._simple import SimpleSingerReader, SimpleSingerWriter __all__ = [ "GenericSingerReader", "GenericSingerWriter", + "SimpleSingerReader", + "SimpleSingerWriter", "SingerMessageType", - "SingerReader", - "SingerWriter", ] diff --git a/singer_sdk/_singerlib/encoding/_simple.py b/singer_sdk/_singerlib/encoding/_simple.py index 5bfb242fb..7ce148fc3 100644 --- a/singer_sdk/_singerlib/encoding/_simple.py +++ b/singer_sdk/_singerlib/encoding/_simple.py @@ -194,7 +194,7 @@ def __post_init__(self) -> None: self.type = SingerMessageType.ACTIVATE_VERSION -class SingerReader(GenericSingerReader[str]): +class SimpleSingerReader(GenericSingerReader[str]): """Base class for all plugins reading Singer messages as strings from stdin.""" default_input = sys.stdin @@ -219,7 +219,7 @@ def deserialize_json(self, line: str) -> dict: # noqa: PLR6301 raise InvalidInputLine(msg) from exc -class SingerWriter(GenericSingerWriter[str, Message]): +class SimpleSingerWriter(GenericSingerWriter[str, Message]): """Interface for all plugins writing Singer messages to stdout.""" def serialize_message(self, message: Message) -> str: # noqa: PLR6301 diff --git a/singer_sdk/_singerlib/messages.py b/singer_sdk/_singerlib/messages.py index 640219de6..271c3bea3 100644 --- a/singer_sdk/_singerlib/messages.py +++ b/singer_sdk/_singerlib/messages.py @@ -2,7 +2,7 @@ from __future__ import annotations -from .encoding import SingerWriter +from .encoding import SimpleSingerWriter as SingerWriter from .encoding._base import SingerMessageType from .encoding._simple import ( ActivateVersionMessage, diff --git a/singer_sdk/io_base.py b/singer_sdk/io_base.py index f9041beea..f24188b4e 100644 --- a/singer_sdk/io_base.py +++ b/singer_sdk/io_base.py @@ -2,4 +2,18 @@ from __future__ import annotations -from singer_sdk._singerlib.encoding import * # noqa: F403 +from singer_sdk._singerlib.encoding import ( + GenericSingerReader, + GenericSingerWriter, + SingerMessageType, +) +from singer_sdk._singerlib.encoding import SimpleSingerReader as SingerReader +from singer_sdk._singerlib.encoding import SimpleSingerWriter as SingerWriter + +__all__ = [ + "GenericSingerReader", + "GenericSingerWriter", + "SingerMessageType", + "SingerReader", + "SingerWriter", +]