Skip to content

Commit

Permalink
🐛 Fix wrong calls of static methods
Browse files Browse the repository at this point in the history
Fix wrong f-string
  • Loading branch information
Freed-Wu committed Jan 23, 2023
1 parent d9f2a42 commit 4689bb6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
20 changes: 8 additions & 12 deletions src/translate_shell/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,14 @@ def get_clipper() -> list[str]:
return get_clipper()

@staticmethod
def get_speaker(query: str) -> list[str]:
def get_speaker(unused_query: str) -> list[str]:
"""Get speaker.
:param query:
:type query: str
:param unused_query:
:type unused_query: str
:rtype: list[str]
"""
from .utils.speakers import get_speaker

return get_speaker(query)
return []

@staticmethod
def get_prompt(text: str, tl: str, sl: str, translators: str) -> str:
Expand All @@ -116,16 +114,14 @@ def get_prompt(text: str, tl: str, sl: str, translators: str) -> str:
return get_prompt(text, tl, sl, translators)

@staticmethod
def get_youdaozhiyun_app_info(*args: Any) -> tuple[str, str]:
def get_youdaozhiyun_app_info(*unused_args: Any) -> tuple[str, str]:
"""Get youdaozhiyun APP info.
:param args:
:type args: Any
:param unused_args:
:type unused_args: Any
:rtype: tuple[str, str]
"""
from .utils.youdaozhiyun import get_youdaozhiyun_app_info

return get_youdaozhiyun_app_info(*args)
return "", ""

@staticmethod
def complete(text: str, state: int) -> str:
Expand Down
7 changes: 2 additions & 5 deletions src/translate_shell/translators/online/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ def get_url(self, sl: str, tl: str, qry: str) -> str:
"""
http_host = self._cnhost if "zh" in tl else self._host
qry = quote_plus(qry)
url = (
f"https://{http_host}/translate_a/single?client=gtx&sl={sl}"
"&tl={tl}&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss"
"&dt=t&q={qry}"
)
url = f"https://{http_host}/translate_a/single?client=gtx&sl={sl}\
&tl={tl}&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&q={qry}"
return url

def __call__(self, text: str, tl: str, sl: str) -> TRANSLATION | None:
Expand Down
2 changes: 1 addition & 1 deletion src/translate_shell/translators/online/youdaozhiyun.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self) -> None:
"""
super().__init__("youdaozhiyun")
self.url = "https://openapi.youdao.com/api"
self.app_id, self.app_sec = self.get_youdaozhiyun_app_info()
self.app_id, self.app_sec = self.__class__.get_youdaozhiyun_app_info()

def sign(self, text: str, salt: str) -> str:
"""Sign.
Expand Down
2 changes: 1 addition & 1 deletion src/translate_shell/translators/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __call__(self, text: str, tl: str, sl: str) -> None:
:type sl: str
:rtype: None
"""
tokens = self.get_speaker(text)
tokens = self.__class__.get_speaker(text)
if tokens:
check_output(tokens)

Expand Down

0 comments on commit 4689bb6

Please sign in to comment.