Skip to content

Commit

Permalink
[fix] fixing services_list according to #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Animenosekai committed Jul 7, 2021
1 parent e747d98 commit 579565a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions translatepy/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ def __init__(

self.services = []
for service in services_list:
if not isinstance(service, type):
raise ValueError("Type of the parameter 'services_list' must be a class")

if not issubclass(service, BaseTranslator):
raise TypeError("Type of the parameter 'services_list' must be a child class of BaseTranslator class")
if not isinstance(service, BaseTranslator):
if not issubclass(service, BaseTranslator):
raise TypeError("{service} must be a child class of the BaseTranslator class".format(service=service))
else:
self.services.append(service(request=request))
else:
self.services.append(service)

self.services.append(service(request=request))

def translate(self, text: str, destination_language: str, source_language: str = "auto") -> TranslationResult:
"""
Expand Down

0 comments on commit 579565a

Please sign in to comment.