Skip to content

Commit c96049f

Browse files
committed
coderabbit comments
1 parent 1590a9e commit c96049f

File tree

9 files changed

+45
-22
lines changed

9 files changed

+45
-22
lines changed

cuenca/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
'get_balance',
4545
]
4646

47-
from typing import cast
48-
4947
from . import http
5048
from .resources import (
5149
Account,
@@ -96,5 +94,5 @@
9694

9795

9896
def get_balance(session: http.Session = session) -> int:
99-
balance_entry = cast('BalanceEntry', BalanceEntry.first(session=session))
97+
balance_entry = BalanceEntry.first(session=session)
10098
return balance_entry.rolling_balance if balance_entry else 0

cuenca/resources/base.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import datetime as dt
33
import json
44
from io import BytesIO
5-
from typing import ClassVar, Generator, Optional, Type, TypeVar, cast
5+
from typing import Any, ClassVar, Generator, Optional, Type, TypeVar, cast
66
from urllib.parse import urlencode
77

88
from cuenca_validations.types import (
@@ -35,7 +35,10 @@ def to_dict(self):
3535
class Retrievable(Resource):
3636
@classmethod
3737
def retrieve(
38-
cls: Type[R_co], id: str, *, session: Session = global_session
38+
cls: Type[R_co],
39+
id: str,
40+
*,
41+
session: Session = global_session,
3942
) -> R_co:
4043
resp = session.get(f'/{cls._resource}/{id}')
4144
return cls(**resp)
@@ -49,7 +52,10 @@ def refresh(self, *, session: Session = global_session) -> None:
4952
class Creatable(Resource):
5053
@classmethod
5154
def _create(
52-
cls: Type[R_co], *, session: Session = global_session, **data
55+
cls: Type[R_co],
56+
*,
57+
session: Session = global_session,
58+
**data: Any,
5359
) -> R_co:
5460
resp = session.post(cls._resource, data)
5561
return cls(**resp)
@@ -61,7 +67,11 @@ class Updateable(Resource):
6167

6268
@classmethod
6369
def _update(
64-
cls: Type[R_co], id: str, *, session: Session = global_session, **data
70+
cls: Type[R_co],
71+
id: str,
72+
*,
73+
session: Session = global_session,
74+
**data: Any,
6575
) -> R_co:
6676
resp = session.patch(f'/{cls._resource}/{id}', data)
6777
return cls(**resp)
@@ -72,7 +82,11 @@ class Deactivable(Resource):
7282

7383
@classmethod
7484
def deactivate(
75-
cls: Type[R_co], id: str, *, session: Session = global_session, **data
85+
cls: Type[R_co],
86+
id: str,
87+
*,
88+
session: Session = global_session,
89+
**data: Any,
7690
) -> R_co:
7791
resp = session.delete(f'/{cls._resource}/{id}', data)
7892
return cls(**resp)
@@ -115,7 +129,7 @@ def _upload(
115129
user_id: str,
116130
*,
117131
session: Session = global_session,
118-
**data,
132+
**data: Any,
119133
) -> R_co:
120134
encoded_file = base64.b64encode(file)
121135
resp = session.request(
@@ -137,7 +151,10 @@ class Queryable(Resource):
137151

138152
@classmethod
139153
def one(
140-
cls: Type[R_co], *, session: Session = global_session, **query_params
154+
cls: Type[R_co],
155+
*,
156+
session: Session = global_session,
157+
**query_params: Any,
141158
) -> R_co:
142159
q = cast(Queryable, cls)._query_params(limit=2, **query_params)
143160
resp = session.get(cls._resource, q.dict())
@@ -151,7 +168,10 @@ def one(
151168

152169
@classmethod
153170
def first(
154-
cls: Type[R_co], *, session: Session = global_session, **query_params
171+
cls: Type[R_co],
172+
*,
173+
session: Session = global_session,
174+
**query_params: Any,
155175
) -> Optional[R_co]:
156176
q = cast(Queryable, cls)._query_params(limit=1, **query_params)
157177
resp = session.get(cls._resource, q.dict())
@@ -165,15 +185,21 @@ def first(
165185

166186
@classmethod
167187
def count(
168-
cls: Type[R_co], *, session: Session = global_session, **query_params
188+
cls: Type[R_co],
189+
*,
190+
session: Session = global_session,
191+
**query_params: Any,
169192
) -> int:
170193
q = cast(Queryable, cls)._query_params(count=True, **query_params)
171194
resp = session.get(cls._resource, q.dict())
172195
return resp['count']
173196

174197
@classmethod
175198
def all(
176-
cls: Type[R_co], *, session: Session = global_session, **query_params
199+
cls: Type[R_co],
200+
*,
201+
session: Session = global_session,
202+
**query_params: Any,
177203
) -> Generator[R_co, None, None]:
178204
session = session or global_session
179205
q = cast(Queryable, cls)._query_params(**query_params)

cuenca/resources/card_validations.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ def create(
5151
pin_block=pin_block,
5252
pin_attempts_exceeded=pin_attempts_exceeded,
5353
)
54-
return cast(
55-
'CardValidation', cls._create(session=session, **req.dict())
56-
)
54+
return cls._create(session=session, **req.dict())
5755

5856
@property
5957
def card(self) -> Card:

cuenca/resources/endpoints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def update(
8989
like url and is_active.
9090
:param endpoint_id: existing endpoint_id
9191
:param url
92+
:param events: Optional list of enabled events to update
9293
:param is_enable
9394
:param session
9495
:return: Updated endpoint object

cuenca/resources/otps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import ClassVar, cast
1+
from typing import ClassVar
22

33
from ..http import Session, session as global_session
44
from .base import Creatable
@@ -21,4 +21,4 @@ def create(cls, session: Session = global_session) -> 'Otp':
2121
"""
2222
Use this method to create a OTP seed
2323
"""
24-
return cast('Otp', cls._create(session=session))
24+
return cls._create(session=session)

cuenca/resources/savings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def create(
2727
category: SavingCategory,
2828
goal_amount: Optional[int] = None,
2929
goal_date: Optional[dt.datetime] = None,
30-
):
30+
) -> 'Saving':
3131
request = SavingRequest(
3232
name=name,
3333
category=category,

cuenca/resources/transfers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def create_many(cls, requests: List[TransferRequest]) -> DictStrAny:
8080
except (CuencaException, HTTPError) as e:
8181
transfers['errors'].append(dict(request=req, error=e))
8282
else:
83-
transfers['submitted'].append(cast('Transfer', transfer))
83+
transfers['submitted'].append(transfer)
8484
return transfers
8585

8686
@staticmethod

cuenca/resources/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def update(
157157
curp_document: Optional[HttpUrl] = None,
158158
*,
159159
session: Session = global_session,
160-
):
160+
) -> 'User':
161161
request = UserUpdateRequest(
162162
phone_number=phone_number,
163163
email_address=email_address,

cuenca/resources/wallet_transactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def create(
2929
wallet_uri: str,
3030
transaction_type: WalletTransactionType,
3131
amount: int,
32-
):
32+
) -> 'WalletTransaction':
3333
request = WalletTransactionRequest(
3434
wallet_uri=wallet_uri,
3535
transaction_type=transaction_type,

0 commit comments

Comments
 (0)