Skip to content

Commit

Permalink
remove id from interface init params
Browse files Browse the repository at this point in the history
This is not necessary for now.
  • Loading branch information
RLKRo committed Oct 25, 2024
1 parent 45df6cc commit ddd488f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
12 changes: 6 additions & 6 deletions chatsky/messengers/common/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class MessengerInterface(abc.ABC):
It is responsible for connection between user and pipeline, as well as for request-response transactions.
"""

def __init__(self, id: Optional[str] = None) -> None:
self.id = id if id is not None else type(self).__name__
def __init__(self) -> None:
self.id = type(self).__name__

@abc.abstractmethod
async def connect(self, pipeline_runner: PipelineRunnerFunction):
Expand Down Expand Up @@ -63,8 +63,8 @@ class MessengerInterfaceWithAttachments(MessengerInterface, abc.ABC):
Attachments not in this list will be neglected.
"""

def __init__(self, id: Optional[str] = None, attachments_directory: Optional[Path] = None) -> None:
MessengerInterface.__init__(self, id)
def __init__(self, attachments_directory: Optional[Path] = None) -> None:
super().__init__()
tempdir = gettempdir()
if attachments_directory is not None and not str(attachments_directory.absolute()).startswith(tempdir):
self.attachments_directory = attachments_directory
Expand Down Expand Up @@ -173,8 +173,8 @@ class CallbackMessengerInterface(MessengerInterface):
Callback message interface is waiting for user input and answers once it gets one.
"""

def __init__(self, id: Optional[str] = None) -> None:
MessengerInterface.__init__(self, id)
def __init__(self) -> None:
super().__init__()
self._pipeline_runner: Optional[PipelineRunnerFunction] = None

async def connect(self, pipeline_runner: PipelineRunnerFunction):
Expand Down
3 changes: 1 addition & 2 deletions chatsky/messengers/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ class CLIMessengerInterface(PollingMessengerInterface):

def __init__(
self,
id: Optional[str] = None,
intro: Optional[str] = None,
prompt_request: str = "request: ",
prompt_response: str = "response: ",
out_descriptor: Optional[TextIO] = None,
):
super().__init__(id)
super().__init__()
self._ctx_id: Optional[Hashable] = None
self._intro: Optional[str] = intro
self._prompt_request: str = prompt_request
Expand Down
4 changes: 2 additions & 2 deletions chatsky/messengers/telegram/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class _AbstractTelegramInterface(MessengerInterfaceWithAttachments):
MediaGroup,
}

def __init__(self, token: str, id: Optional[str] = None, attachments_directory: Optional[Path] = None) -> None:
super().__init__(id, attachments_directory)
def __init__(self, token: str, attachments_directory: Optional[Path] = None) -> None:
super().__init__(attachments_directory)
if not telegram_available:
raise ImportError("`python-telegram-bot` package is missing.\nTry to run `pip install chatsky[telegram]`.")

Expand Down
6 changes: 2 additions & 4 deletions chatsky/messengers/telegram/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ class LongpollingInterface(_AbstractTelegramInterface):
def __init__(
self,
token: str,
id: Optional[str] = None,
attachments_directory: Optional[Path] = None,
interval: int = 2,
timeout: int = 20,
) -> None:
super().__init__(token, id, attachments_directory)
super().__init__(token, attachments_directory)
self.interval = interval
self.timeout = timeout

Expand All @@ -61,12 +60,11 @@ class WebhookInterface(_AbstractTelegramInterface):
def __init__(
self,
token: str,
id: Optional[str] = None,
attachments_directory: Optional[Path] = None,
host: str = "localhost",
port: int = 844,
):
super().__init__(token, id, attachments_directory)
super().__init__(token, attachments_directory)
self.listen = host
self.port = port

Expand Down

0 comments on commit ddd488f

Please sign in to comment.