Skip to content

Commit

Permalink
Fix return type to be instance of Api() (#283)
Browse files Browse the repository at this point in the history
The return value from the ```connect()``` function is not
```typing.Type[Api]``` it is an instance of ```Api``` class.
  • Loading branch information
luqasz authored Sep 16, 2024
2 parents 0d49742 + 6d8dad5 commit b9aab30
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions librouteros/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: UTF-8 -*-

import typing
from socket import create_connection
from collections import ChainMap

Expand All @@ -27,7 +26,7 @@
}


def connect(host: str, username: str, password: str, **kwargs) -> typing.Type[Api]:
def connect(host: str, username: str, password: str, **kwargs) -> Api:
"""
Connect and login to routeros device.
Upon success return a Api class.
Expand All @@ -45,7 +44,7 @@ def connect(host: str, username: str, password: str, **kwargs) -> typing.Type[Ap
arguments = ChainMap(kwargs, DEFAULTS)
transport = create_transport(host, **arguments)
protocol = ApiProtocol(transport=transport, encoding=arguments["encoding"])
api = arguments["subclass"](protocol=protocol)
api: Api = arguments["subclass"](protocol=protocol)

try:
arguments["login_method"](api=api, username=username, password=password)
Expand Down

0 comments on commit b9aab30

Please sign in to comment.