Skip to content

Commit

Permalink
🔥 Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Apr 8, 2024
1 parent b8cd0f0 commit 88a3f85
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/repl_python_wakatime/hooks/codestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def __init__(
self,
api_key: str,
url: str = "https://codestats.net/api/my/pulses",
language: str = "python",
language_type: str = "Terminal (%s)",
language_type: str = "Terminal (python)",
) -> None:
"""Init.
Expand All @@ -92,7 +91,7 @@ def __init__(
"""
self.url = url
self.api_key = api_key
self.language_type = language_type % language
self.language_type = language_type
self.xp_dict = {language_type: 0}

self.sem = threading.Semaphore()
Expand Down Expand Up @@ -138,9 +137,10 @@ def send_xp(self) -> None:

# after lock is released we can send the payload
utc_now = datetime.now().astimezone().isoformat()
pulse_json = json.dumps(
{"coded_at": "{0}".format(utc_now), "xps": xp_list}
).encode("utf-8")
pulse_json = json.dumps({
"coded_at": "{0}".format(utc_now),
"xps": xp_list,
}).encode("utf-8")
req = Request(url=self.url, data=pulse_json, headers=headers)
error = ""
try:
Expand All @@ -162,7 +162,8 @@ def send_xp(self) -> None:
error = e
except HTTPException as e:
error = "HTTPException on send data. Msg: {0}\nDoc?:{1}".format(
e.message, e.__doc__ # type: ignore
e.message,
e.__doc__, # type: ignore
)
if error:
logger.error(error)
Expand Down

0 comments on commit 88a3f85

Please sign in to comment.