Skip to content

Commit e7c2917

Browse files
felipao-mxclaude
andcommitted
Fix linting issues
- Added type annotations to test fixtures - Fixed null checks in tests - Removed trailing whitespace - Fixed import sorting - All lint checks now pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9ea44ff commit e7c2917

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

cuenca/http/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ def request(
105105
with httpx.Client() as client:
106106
# Set headers
107107
headers = self.headers.copy()
108-
108+
109109
# Update JWT token if needed
110110
if self.jwt_token:
111111
if self.jwt_token.is_expired:
112112
self.jwt_token = Jwt.create(self)
113113
headers['X-Cuenca-Token'] = self.jwt_token.token
114-
114+
115115
# Merge headers from kwargs if present
116116
if 'headers' in kwargs:
117117
headers.update(kwargs.pop('headers'))
118-
118+
119119
# Make request
120120
resp = client.request(
121121
method=method,

cuenca/resources/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _upload(
137137
files = {
138138
'file': encoded_file,
139139
'user_id': str(user_id),
140-
**{k: str(v) if v is not None else '' for k, v in data.items()}
140+
**{k: str(v) if v is not None else '' for k, v in data.items()},
141141
}
142142
resp = session.request(
143143
'post',

tests/http/test_client.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import datetime as dt
22

33
import pytest
4-
from pytest_httpx import HTTPXMock
54
from cuenca_validations.errors import (
65
NoPasswordFoundError,
76
UserNotLoggedInError,
87
)
98
from freezegun import freeze_time
9+
from pytest_httpx import HTTPXMock
1010

1111
from cuenca.exc import CuencaResponseException
1212
from cuenca.http.client import Session
@@ -66,22 +66,20 @@ def test_request_expired_token():
6666

6767
def test_overrides_session(httpx_mock: HTTPXMock):
6868
# Setup mock response
69-
httpx_mock.add_response(
70-
status_code=200,
71-
json={"items": []}
72-
)
73-
69+
httpx_mock.add_response(status_code=200, json={"items": []})
70+
7471
# Configure session with custom credentials
7572
session = Session()
7673
session.configure(
7774
api_key='USER_API_KEY', api_secret='USER_SECRET', sandbox=True
7875
)
79-
76+
8077
# Make the request
8178
Card.first(user_id='USER_ID', session=session)
82-
79+
8380
# Verify the request was made with the correct auth
8481
request = httpx_mock.get_request()
82+
assert request is not None, "No request was captured"
8583
assert request.headers.get("authorization", "").startswith("Basic ")
8684
assert request.url.params.get("user_id") == "USER_ID"
8785

tests/test_cuenca.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import pytest
21
from pytest_httpx import HTTPXMock
32

43
import cuenca
54

65

76
def test_get_balance(httpx_mock: HTTPXMock):
87
# It is the case when the user has transactions in the account
9-
response_json = {
8+
response_json: dict = {
109
'items': [
1110
{
1211
'id': 'LE6xvD1ocHmSIu7MgzlC9woj',
@@ -38,7 +37,7 @@ def test_get_balance_before_first_transaction(httpx_mock: HTTPXMock):
3837
# When the user have no transactions at all
3938
# balance_entries endpoint returns `items` as empty list.
4039
# It means that its balance is Mx$0.00
41-
response_json = {'items': [], 'next_page_uri': None}
40+
response_json: dict = {'items': [], 'next_page_uri': None}
4241

4342
httpx_mock.add_response(
4443
url='https://sandbox.cuenca.com/balance_entries?limit=1',

0 commit comments

Comments
 (0)