Skip to content

Commit

Permalink
fix: use came case for params
Browse files Browse the repository at this point in the history
  • Loading branch information
Olegt0rr committed Aug 25, 2023
1 parent a18e6c6 commit 93caf7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion yatracker/tracker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import msgspec.json

from yatracker.utils.camel_case import camel_case
from yatracker.utils.mixins import ContextInstanceMixin

from .client import AIOHTTPClient
Expand Down Expand Up @@ -74,7 +75,7 @@ def clear_payload(
payload.update(kwargs)

return {
k: v
camel_case(k): v
for k, v in payload.items()
if k not in {"self", "cls", *exclude} and v is not None
}
Expand Down
13 changes: 13 additions & 0 deletions yatracker/utils/camel_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def camel_case(string: str) -> str:
"""Convert string into camel case."""
if not string:
return string

string = string.replace("_", "-")
lst = string.split("-")
for i in range(len(lst)):
if i == 0:
continue
lst[i] = lst[i].capitalize()

return "".join(lst)

0 comments on commit 93caf7c

Please sign in to comment.