-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hydration #61
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes across multiple test files involve updating the Changes
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 34 36 +2
Lines 1267 1285 +18
=========================================
+ Hits 1267 1285 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range comments (2)
garth/stats/_base.py (2)
Line range hint
19-19
: Add type annotation forcls
.The class method
list
is missing a type annotation forcls
.- def list( + def list( + cls: Type["Stats"],
Line range hint
41-41
: Remove unnecessary assignment before return statement.The assignment to
page
before the return statement is unnecessary.- page = ( - cls.list( - end - timedelta(**{period_type: cls._page_size}), - period - cls._page_size, - client=client, - ) - + page - ) - return page + return cls.list( + end - timedelta(**{period_type: cls._page_size}), + period - cls._page_size, + client=client, + ) + page
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (3)
- garth/stats/init.py (1 hunks)
- garth/stats/_base.py (1 hunks)
- garth/stats/hydration.py (1 hunks)
Additional context used
Ruff
garth/stats/_base.py
19-19: Missing type annotation for
cls
in classmethod(ANN102)
41-41: Unnecessary assignment to
page
beforereturn
statementRemove unnecessary assignment
(RET504)
Additional comments not posted (1)
garth/stats/hydration.py (1)
1-16
: LGTM!Ensure that the new
DailyHydration
class is integrated and used correctly in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai suggest changes to the README |
@matin: Based on the recent changes, I suggest adding the following section to the README to document the new HydrationDaily hydration statistics garth.DailyHydration.list("2023-07-23", 2) [
DailyHydration(
calendar_date=datetime.date(2023, 7, 22),
value_in_ml=2000,
goal_in_ml=2500
),
DailyHydration(
calendar_date=datetime.date(2023, 7, 23),
value_in_ml=2100,
goal_in_ml=2500
)
] This addition will help users understand how to access and use the new hydration stats feature. Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Locate and display the contents of the README file to understand its current structure and content.
fd -I -H -t f -i 'readme' | xargs cat
Length of output: 22495 Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (5)
- garth/init.py (2 hunks)
- garth/stats/init.py (2 hunks)
- garth/stats/_base.py (3 hunks)
- tests/stats/cassettes/test_daily_hydration.yaml (1 hunks)
- tests/stats/test_hydration.py (1 hunks)
Additional context used
Ruff
tests/stats/test_hydration.py
9-9: Use
@pytest.mark.vcr()
over@pytest.mark.vcr
Add/remove parentheses
(PT023)
10-10: Missing return type annotation for public function
test_daily_hydration
Add return type annotation:
None
(ANN201)
13-13: Use of
assert
detected(S101)
yamllint
tests/stats/cassettes/test_daily_hydration.yaml
[error] 2-2: wrong indentation: expected at least 1
(indentation)
[error] 6-6: wrong indentation: expected 8 but found 6
(indentation)
[error] 8-8: wrong indentation: expected 8 but found 6
(indentation)
[error] 10-10: wrong indentation: expected 8 but found 6
(indentation)
[error] 12-12: wrong indentation: expected 8 but found 6
(indentation)
[error] 14-14: wrong indentation: expected 8 but found 6
(indentation)
[error] 23-23: wrong indentation: expected 8 but found 6
(indentation)
[error] 25-25: wrong indentation: expected 8 but found 6
(indentation)
[error] 27-27: wrong indentation: expected 8 but found 6
(indentation)
[error] 29-29: wrong indentation: expected 8 but found 6
(indentation)
[error] 31-31: wrong indentation: expected 8 but found 6
(indentation)
[error] 33-33: wrong indentation: expected 8 but found 6
(indentation)
[error] 35-35: wrong indentation: expected 8 but found 6
(indentation)
[error] 37-37: wrong indentation: expected 8 but found 6
(indentation)
[error] 39-39: wrong indentation: expected 8 but found 6
(indentation)
[error] 41-41: wrong indentation: expected 8 but found 6
(indentation)
[error] 53-53: wrong indentation: expected 8 but found 6
(indentation)
[error] 55-55: wrong indentation: expected 8 but found 6
(indentation)
[error] 57-57: wrong indentation: expected 8 but found 6
(indentation)
[error] 59-59: wrong indentation: expected 8 but found 6
(indentation)
Additional comments not posted (4)
garth/stats/__init__.py (1)
3-3
: EnsureDailyHydration
is correctly imported and used.The addition of
DailyHydration
to the__all__
list is incomplete without the corresponding import statement. Please add the following import statement togarth/stats/__init__.py
:from .hydration import DailyHydrationgarth/__init__.py (1)
5-5
: LGTM!The import of
DailyHydration
and its inclusion in the__all__
list are correct.garth/stats/_base.py (1)
2-2
: LGTM!The removal of
BASE_PATH
constant and updates to theStats
class are correct.tests/stats/cassettes/test_daily_hydration.yaml (1)
73-73
: LGTM!
@coderabbitai review |
Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 18
Outside diff range comments (23)
tests/stats/test_steps.py (2)
Line range hint
14-15
: Avoid usingassert
statements in tests.Replace
assert
statements withpytest
'sassert
methods for better error messages.- assert daily_steps[-1].calendar_date == end - assert len(daily_steps) == days + assert daily_steps[-1].calendar_date == end, f"Expected {end}, got {daily_steps[-1].calendar_date}" + assert len(daily_steps) == days, f"Expected {days}, got {len(daily_steps)}"Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_weekly_steps
Add return type annotation:
None
(ANN201)
Line range hint
23-24
: Avoid usingassert
statements in tests.Replace
assert
statements withpytest
'sassert
methods for better error messages.- assert len(weekly_steps) == weeks - assert weekly_steps[-1].calendar_date == end - timedelta(days=6) + assert len(weekly_steps) == weeks, f"Expected {weeks}, got {len(weekly_steps)}" + assert weekly_steps[-1].calendar_date == end - timedelta(days=6), f"Expected {end - timedelta(days=6)}, got {weekly_steps[-1].calendar_date}"Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_steps
Add return type annotation:
None
(ANN201)
tests/data/test_hrv_data.py (2)
Line range hint
12-16
: Avoid usingassert
statements in tests.Replace
assert
statements withpytest
'sassert
methods for better error messages.- assert hrv_data - assert hrv_data.user_profile_pk - assert hrv_data.hrv_summary.calendar_date == date(2023, 7, 20) - assert HRVData.get("2021-07-20", client=authed_client) is None + assert hrv_data, "HRV data should not be None" + assert hrv_data.user_profile_pk, "User profile PK should not be None" + assert hrv_data.hrv_summary.calendar_date == date(2023, 7, 20), f"Expected {date(2023, 7, 20)}, got {hrv_data.hrv_summary.calendar_date}" + assert HRVData.get("2021-07-20", client=authed_client) is None, "Expected None for 2021-07-20"Tools
Ruff
10-10: Missing return type annotation for public function
test_hrv_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
Line range hint
24-25
: Avoid usingassert
statements in tests.Replace
assert
statements withpytest
'sassert
methods for better error messages.- assert len(hrv_data) == days - assert hrv_data[-1].hrv_summary.calendar_date == end + assert len(hrv_data) == days, f"Expected {days}, got {len(hrv_data)}" + assert hrv_data[-1].hrv_summary.calendar_date == end, f"Expected {end}, got {hrv_data[-1].hrv_summary.calendar_date}"Tools
Ruff
10-10: Missing return type annotation for public function
test_hrv_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
tests/data/test_sleep_data.py (2)
Line range hint
12-15
: Avoid usingassert
statements in tests.Replace
assert
statements withpytest
'sassert
methods for better error messages.- assert sleep_data - assert sleep_data.daily_sleep_dto.calendar_date == date(2021, 7, 20) - assert sleep_data.daily_sleep_dto.sleep_start - assert sleep_data.daily_sleep_dto.sleep_end + assert sleep_data, "Sleep data should not be None" + assert sleep_data.daily_sleep_dto.calendar_date == date(2021, 7, 20), f"Expected {date(2021, 7, 20)}, got {sleep_data.daily_sleep_dto.calendar_date}" + assert sleep_data.daily_sleep_dto.sleep_start, "Sleep start should not be None" + assert sleep_data.daily_sleep_dto.sleep_end, "Sleep end should not be None"Tools
Ruff
10-10: Missing return type annotation for public function
test_sleep_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
Line range hint
23-24
: Avoid usingassert
statements in tests.Replace
assert
statements withpytest
'sassert
methods for better error messages.- assert sleep_data[-1].daily_sleep_dto.calendar_date == end - assert len(sleep_data) == days + assert sleep_data[-1].daily_sleep_dto.calendar_date == end, f"Expected {end}, got {sleep_data[-1].daily_sleep_dto.calendar_date}" + assert len(sleep_data) == days, f"Expected {days}, got {len(sleep_data)}"Tools
Ruff
10-10: Missing return type annotation for public function
test_sleep_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
tests/stats/test_intensity_minutes.py (2)
Line range hint
14-15
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_im[-1].calendar_date == end - assert len(daily_im) == days + pytest.assume(daily_im[-1].calendar_date == end) + pytest.assume(len(daily_im) == days)Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_weekly_intensity_minutes
Add return type annotation:
None
(ANN201)
Line range hint
23-24
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert len(weekly_im) == weeks - assert ( + pytest.assume(len(weekly_im) == weeks) + pytest.assume(Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_intensity_minutes
Add return type annotation:
None
(ANN201)
tests/stats/test_hrv.py (3)
Line range hint
14-15
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_hrv[-1].calendar_date == end - assert len(daily_hrv) == days + pytest.assume(daily_hrv[-1].calendar_date == end) + pytest.assume(len(daily_hrv) == days)Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_hrv_paginate
Add return type annotation:
None
(ANN201)
Line range hint
23-24
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_hrv[-1].calendar_date == end - assert len(daily_hrv) == days + pytest.assume(daily_hrv[-1].calendar_date == end) + pytest.assume(len(daily_hrv) == days)Tools
Ruff
24-24: Use of
assert
detected(S101)
28-28: Missing return type annotation for public function
test_daily_hrv_no_results
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
35-35: Missing return type annotation for public function
test_daily_hrv_paginate_no_results
Add return type annotation:
None
(ANN201)
Line range hint
39-39
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_hrv == [] + pytest.assume(daily_hrv == [])Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_hrv
Add return type annotation:
None
(ANN201)
tests/stats/test_stress.py (3)
Line range hint
14-15
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_stress[-1].calendar_date == end - assert len(daily_stress) == days + pytest.assume(daily_stress[-1].calendar_date == end) + pytest.assume(len(daily_stress) == days)Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_stress_pagination
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
27-27: Missing return type annotation for public function
test_weekly_stress
Add return type annotation:
None
(ANN201)
Line range hint
31-32
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert len(weekly_stress) == weeks - assert weekly_stress[-1].calendar_date == end - timedelta(days=6) + pytest.assume(len(weekly_stress) == weeks) + pytest.assume(weekly_stress[-1].calendar_date == end - timedelta(days=6))Tools
Ruff
32-32: Use of
assert
detected(S101)
36-36: Missing return type annotation for public function
test_weekly_stress_pagination
Add return type annotation:
None
(ANN201)
Line range hint
40-41
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert len(weekly_stress) == weeks - assert weekly_stress[-1].calendar_date == end - timedelta(days=6) + pytest.assume(len(weekly_stress) == weeks) + pytest.assume(weekly_stress[-1].calendar_date == end - timedelta(days=6))Tools
Ruff
41-41: Use of
assert
detected(S101)
45-45: Missing return type annotation for public function
test_weekly_stress_beyond_data
Add return type annotation:
None
(ANN201)
tests/test_http.py (9)
Line range hint
105-112
: Add return type annotation and replaceassert
statements.Add return type annotation:
None
and replaceassert
statements withpytest
'sassert
function.@pytest.mark.vcr() def test_client_request(client: Client) -> None: resp = client.request("GET", "connect", "/") - assert resp.ok + pytest.assume(resp.ok) with pytest.raises(GarthHTTPError) as e: client.request("GET", "connectapi", "/") - assert "404" in str(e.value) + pytest.assume("404" in str(e.value))Tools
Ruff
102-102: Use of
assert
detected(S101)
106-106: Missing return type annotation for public function
test_client_request
Add return type annotation:
None
(ANN201)
108-108: Use of
assert
detected(S101)
Line range hint
115-126
: Add type annotations, return type annotation, and replaceassert
statements.Add type annotations for function arguments and return types. Replace
assert
statements withpytest
'sassert
function.@pytest.mark.vcr() def test_login_success_mfa(monkeypatch: pytest.MonkeyPatch, client: Client) -> None: def mock_input(_: str) -> str: return "327751" monkeypatch.setattr("builtins.input", mock_input) - assert client.oauth1_token is None - assert client.oauth2_token is None + pytest.assume(client.oauth1_token is None) + pytest.assume(client.oauth2_token is None) client.login("[email protected]", "correct_password") - assert client.oauth1_token - assert client.oauth2_token + pytest.assume(client.oauth1_token) + pytest.assume(client.oauth2_token)Tools
Ruff
112-112: Use of
assert
detected(S101)
116-116: Missing return type annotation for public function
test_login_success_mfa
Add return type annotation:
None
(ANN201)
116-116: Missing type annotation for function argument
monkeypatch
(ANN001)
117-117: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
117-117: Missing type annotation for function argument
_
(ANN001)
Line range hint
136-145
: Add return type annotation, replaceassert
statements, and add trailing comma.Add return type annotation:
None
, replaceassert
statements withpytest
'sassert
function, and add the missing trailing comma.@pytest.mark.vcr() def test_connectapi(authed_client: Client) -> None: stress = authed_client.connectapi( "/usersummary-service/stats/stress/daily/2023-07-21/2023-07-21", ) - assert stress - assert isinstance(stress, list) - assert len(stress) == 1 - assert stress[0]["calendarDate"] == "2023-07-21" - assert list(stress[0]["values"].keys()) == [ + pytest.assume(stress) + pytest.assume(isinstance(stress, list)) + pytest.assume(len(stress) == 1) + pytest.assume(stress[0]["calendarDate"] == "2023-07-21") + pytest.assume(list(stress[0]["values"].keys()) == [ "highStressDuration", "lowStressDuration", "overallStressLevel", "restStressDuration", "mediumStressDuration", - ] + ])Tools
Ruff
126-126: Use of
assert
detected(S101)
130-130: Missing return type annotation for public function
test_username
Add return type annotation:
None
(ANN201)
131-131: Use of
assert
detected(S101)
132-132: Use of
assert
detected(S101)
133-133: Use of
assert
detected(S101)
137-137: Missing return type annotation for public function
test_connectapi
Add return type annotation:
None
(ANN201)
139-139: Trailing comma missing
Add trailing comma
(COM812)
Line range hint
154-162
: Add return type annotation and replaceassert
statements.Add return type annotation:
None
and replaceassert
statements withpytest
'sassert
function.@pytest.mark.vcr() def test_refresh_oauth2_token(authed_client: Client) -> None: - assert authed_client.oauth2_token + pytest.assume(authed_client.oauth2_token) authed_client.oauth2_token.expires_at = int(time.time()) - assert authed_client.oauth2_token.expired + pytest.assume(authed_client.oauth2_token.expired) profile = authed_client.connectapi("/userprofile-service/socialProfile") - assert profile - assert isinstance(profile, dict) - assert profile["userName"] + pytest.assume(profile) + pytest.assume(isinstance(profile, dict)) + pytest.assume(profile["userName"])Tools
Ruff
155-155: Missing return type annotation for public function
test_refresh_oauth2_token
Add return type annotation:
None
(ANN201)
156-156: Use of
assert
detected(S101)
Line range hint
165-172
: Add return type annotation, replaceassert
statements, and add trailing comma.Add return type annotation:
None
, replaceassert
statements withpytest
'sassert
function, and add the missing trailing comma.@pytest.mark.vcr() def test_download(authed_client: Client) -> None: downloaded = authed_client.download( "/download-service/files/activity/11998957007", ) - assert downloaded + pytest.assume(downloaded) zip_magic_number = b"\x50\x4B\x03\x04" - assert downloaded[:4] == zip_magic_number + pytest.assume(downloaded[:4] == zip_magic_number)Tools
Ruff
162-162: Use of
assert
detected(S101)
166-166: Missing return type annotation for public function
test_download
Add return type annotation:
None
(ANN201)
168-168: Trailing comma missing
Add trailing comma
(COM812)
Line range hint
183-195
: Add return type annotation and replaceassert
statements.Add return type annotation:
None
and replaceassert
statements withpytest
'sassert
function.@pytest.mark.vcr() def test_delete(authed_client: Client) -> None: activity_id = "12135235656" path = f"/activity-service/activity/{activity_id}" - assert authed_client.connectapi(path) + pytest.assume(authed_client.connectapi(path)) authed_client.delete( "connectapi", path, api=True, ) with pytest.raises(GarthHTTPError) as e: authed_client.connectapi(path) - assert "404" in str(e.value) + pytest.assume("404" in str(e.value))Tools
Ruff
172-172: Use of
assert
detected(S101)
176-176: Missing return type annotation for public function
test_upload
Add return type annotation:
None
(ANN201)
180-180: Use of
assert
detected(S101)
184-184: Missing return type annotation for public function
test_delete
Add return type annotation:
None
(ANN201)
Line range hint
198-213
: Add return type annotation, replaceassert
statements, and add trailing comma.Add return type annotation:
None
, replaceassert
statements withpytest
'sassert
function, and add the missing trailing comma.@pytest.mark.vcr() def test_put(authed_client: Client) -> None: data = [ { "changeState": "CHANGED", "trainingMethod": "HR_RESERVE", "lactateThresholdHeartRateUsed": 170, "maxHeartRateUsed": 185, "restingHrAutoUpdateUsed": False, "sport": "DEFAULT", "zone1Floor": 130, "zone2Floor": 140, "zone3Floor": 150, "zone4Floor": 160, "zone5Floor": 170, }, ] path = "/biometric-service/heartRateZones" authed_client.put( "connectapi", path, api=True, json=data, ) - assert authed_client.connectapi(path) + pytest.assume(authed_client.connectapi(path))Tools
Ruff
195-195: Use of
assert
detected(S101)
199-199: Missing return type annotation for public function
test_put
Add return type annotation:
None
(ANN201)
Line range hint
11-19
: Add return type annotation and replaceassert
statements.Add return type annotation:
None
and replaceassert
statements withpytest
'sassert
function.def test_dump_and_load(authed_client: Client) -> None: with tempfile.TemporaryDirectory() as tempdir: authed_client.dump(tempdir) new_client = Client() new_client.load(tempdir) - assert new_client.oauth1_token == authed_client.oauth1_token - assert new_client.oauth2_token == authed_client.oauth2_token + pytest.assume(new_client.oauth1_token == authed_client.oauth1_token) + pytest.assume(new_client.oauth2_token == authed_client.oauth2_token)Tools
Ruff
102-102: Use of
assert
detected(S101)
106-106: Missing return type annotation for public function
test_client_request
Add return type annotation:
None
(ANN201)
108-108: Use of
assert
detected(S101)
Line range hint
22-27
: Add return type annotation and replaceassert
statements.Add return type annotation:
None
and replaceassert
statements withpytest
'sassert
function.def test_dumps_and_loads(authed_client: Client) -> None: s = authed_client.dumps() new_client = Client() new_client.loads(s) - assert new_client.oauth1_token == authed_client.oauth1_token - assert new_client.oauth2_token == authed_client.oauth2_token + pytest.assume(new_client.oauth1_token == authed_client.oauth1_token) + pytest.assume(new_client.oauth2_token == authed_client.oauth2_token)Tools
Ruff
102-102: Use of
assert
detected(S101)
106-106: Missing return type annotation for public function
test_client_request
Add return type annotation:
None
(ANN201)
108-108: Use of
assert
detected(S101)
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (13)
- .coderabbit.yaml (1 hunks)
- garth/version.py (1 hunks)
- tests/data/test_hrv_data.py (2 hunks)
- tests/data/test_sleep_data.py (2 hunks)
- tests/stats/test_hrv.py (3 hunks)
- tests/stats/test_hydration.py (1 hunks)
- tests/stats/test_intensity_minutes.py (2 hunks)
- tests/stats/test_sleep_stats.py (1 hunks)
- tests/stats/test_steps.py (2 hunks)
- tests/stats/test_stress.py (4 hunks)
- tests/test_http.py (7 hunks)
- tests/test_sso.py (4 hunks)
- tests/test_users.py (1 hunks)
Files not reviewed due to errors (1)
- tests/test_sso.py (no review received)
Additional context used
Learnings (1)
tests/stats/test_hydration.py (1)
Learnt from: matin PR: matin/garth#61 File: tests/stats/test_hydration.py:10-10 Timestamp: 2024-06-30T03:39:40.523Z Learning: For pytest functions, return type annotations are considered redundant and are not necessary to include.
Ruff
tests/stats/test_sleep_stats.py
10-10: Missing return type annotation for public function
test_daily_sleep
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
tests/stats/test_hydration.py
10-10: Missing return type annotation for public function
test_daily_hydration
Add return type annotation:
None
(ANN201)
13-13: Use of
assert
detected(S101)
tests/test_users.py
8-8: Missing return type annotation for public function
test_user_profile
Add return type annotation:
None
(ANN201)
10-10: Use of
assert
detected(S101)
14-14: Missing return type annotation for public function
test_user_setttings
Add return type annotation:
None
(ANN201)
16-16: Use of
assert
detected(S101)
tests/stats/test_steps.py
10-10: Missing return type annotation for public function
test_daily_steps
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_weekly_steps
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
tests/data/test_hrv_data.py
10-10: Missing return type annotation for public function
test_hrv_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
13-13: Use of
assert
detected(S101)
14-14: Use of
assert
detected(S101)
16-16: Use of
assert
detected(S101)
20-20: Missing return type annotation for public function
test_hrv_data_list
Add return type annotation:
None
(ANN201)
24-24: Use of
assert
detected(S101)
25-25: Use of
assert
detected(S101)
tests/data/test_sleep_data.py
10-10: Missing return type annotation for public function
test_sleep_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
13-13: Use of
assert
detected(S101)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_sleep_data_list
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
tests/stats/test_intensity_minutes.py
10-10: Missing return type annotation for public function
test_daily_intensity_minutes
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_weekly_intensity_minutes
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
tests/stats/test_hrv.py
10-10: Missing return type annotation for public function
test_daily_hrv
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_hrv_paginate
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
28-28: Missing return type annotation for public function
test_daily_hrv_no_results
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
35-35: Missing return type annotation for public function
test_daily_hrv_paginate_no_results
Add return type annotation:
None
(ANN201)
39-39: Use of
assert
detected(S101)
tests/stats/test_stress.py
10-10: Missing return type annotation for public function
test_daily_stress
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_stress_pagination
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
27-27: Missing return type annotation for public function
test_weekly_stress
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
32-32: Use of
assert
detected(S101)
36-36: Missing return type annotation for public function
test_weekly_stress_pagination
Add return type annotation:
None
(ANN201)
40-40: Use of
assert
detected(S101)
41-41: Use of
assert
detected(S101)
45-45: Missing return type annotation for public function
test_weekly_stress_beyond_data
Add return type annotation:
None
(ANN201)
49-49: Use of
assert
detected(S101)
tests/test_sso.py
12-12: Missing return type annotation for public function
test_login_email_password_fail
Add return type annotation:
None
(ANN201)
18-18: Missing return type annotation for public function
test_login_success
Add return type annotation:
None
(ANN201)
20-20: Trailing comma missing
Add trailing comma
(COM812)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
25-25: Use of
assert
detected(S101)
26-26: Use of
assert
detected(S101)
30-30: Missing return type annotation for public function
test_login_success_mfa
Add return type annotation:
None
(ANN201)
30-30: Missing type annotation for function argument
monkeypatch
(ANN001)
31-31: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
31-31: Missing type annotation for function argument
_
(ANN001)
36-36: Trailing comma missing
Add trailing comma
(COM812)
39-39: Use of
assert
detected(S101)
40-40: Use of
assert
detected(S101)
41-41: Use of
assert
detected(S101)
42-42: Use of
assert
detected(S101)
46-46: Missing return type annotation for public function
test_login_success_mfa_async
Add return type annotation:
None
(ANN201)
46-46: Missing type annotation for function argument
monkeypatch
(ANN001)
47-47: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
47-47: Missing type annotation for function argument
_
(ANN001)
50-50: Missing return type annotation for private function
prompt_mfa
(ANN202)
61-61: Use of
assert
detected(S101)
62-62: Use of
assert
detected(S101)
63-63: Use of
assert
detected(S101)
64-64: Use of
assert
detected(S101)
67-67: Missing return type annotation for public function
test_set_expirations
Add return type annotation:
None
(ANN201)
69-69: Use of
assert
detected(S101)
72-72: Use of
assert
detected(S101)
81-81: Missing return type annotation for public function
test_exchange
Add return type annotation:
None
(ANN201)
82-82: Use of
assert
detected(S101)
85-85: Use of
assert
detected(S101)
86-86: Use of
assert
detected(S101)
87-87: Use of
assert
detected(S101)
88-88: Use of
assert
detected(S101)
91-91: Missing return type annotation for public function
test_get_csrf_token
Add return type annotation:
None
(ANN201)
102-102: Use of
assert
detected(S101)
105-105: Missing return type annotation for public function
test_get_csrf_token_fail
Add return type annotation:
None
(ANN201)
119-119: Missing return type annotation for public function
test_get_title
Add return type annotation:
None
(ANN201)
130-130: Use of
assert
detected(S101)
133-133: Missing return type annotation for public function
test_get_title_fail
Add return type annotation:
None
(ANN201)
tests/test_http.py
11-11: Missing return type annotation for public function
test_dump_and_load
Add return type annotation:
None
(ANN201)
18-18: Use of
assert
detected(S101)
19-19: Use of
assert
detected(S101)
22-22: Missing return type annotation for public function
test_dumps_and_loads
Add return type annotation:
None
(ANN201)
26-26: Use of
assert
detected(S101)
27-27: Use of
assert
detected(S101)
30-30: Missing return type annotation for public function
test_configure_oauth2_token
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
33-33: Use of
assert
detected(S101)
36-36: Missing return type annotation for public function
test_configure_domain
Add return type annotation:
None
(ANN201)
37-37: Use of
assert
detected(S101)
39-39: Use of
assert
detected(S101)
42-42: Missing return type annotation for public function
test_configure_proxies
Add return type annotation:
None
(ANN201)
43-43: Use of
assert
detected(S101)
46-46: Use of
assert
detected(S101)
49-49: Missing return type annotation for public function
test_configure_ssl_verify
Add return type annotation:
None
(ANN201)
50-50: Use of
assert
detected(S101)
52-52: Use of
assert
detected(S101)
55-55: Missing return type annotation for public function
test_configure_timeout
Add return type annotation:
None
(ANN201)
56-56: Use of
assert
detected(S101)
58-58: Use of
assert
detected(S101)
61-61: Missing return type annotation for public function
test_configure_retry
Add return type annotation:
None
(ANN201)
62-62: Use of
assert
detected(S101)
63-63: Use of
assert
detected(S101)
65-65: Use of
assert
detected(S101)
66-66: Use of
assert
detected(S101)
69-69: Missing return type annotation for public function
test_configure_status_forcelist
Add return type annotation:
None
(ANN201)
70-70: Use of
assert
detected(S101)
71-71: Use of
assert
detected(S101)
76-76: Use of
assert
detected(S101)
79-79: Missing return type annotation for public function
test_backoff_factor
Add return type annotation:
None
(ANN201)
80-80: Use of
assert
detected(S101)
81-81: Use of
assert
detected(S101)
86-86: Use of
assert
detected(S101)
87-87: Use of
assert
detected(S101)
93-93: Missing return type annotation for public function
test_pool_connections
Add return type annotation:
None
(ANN201)
98-98: Use of
assert
detected(S101)
99-99: Use of
assert
detected(S101)
101-101: Use of
assert
detected(S101)
102-102: Use of
assert
detected(S101)
106-106: Missing return type annotation for public function
test_client_request
Add return type annotation:
None
(ANN201)
108-108: Use of
assert
detected(S101)
112-112: Use of
assert
detected(S101)
116-116: Missing return type annotation for public function
test_login_success_mfa
Add return type annotation:
None
(ANN201)
116-116: Missing type annotation for function argument
monkeypatch
(ANN001)
117-117: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
117-117: Missing type annotation for function argument
_
(ANN001)
122-122: Use of
assert
detected(S101)
123-123: Use of
assert
detected(S101)
125-125: Use of
assert
detected(S101)
126-126: Use of
assert
detected(S101)
130-130: Missing return type annotation for public function
test_username
Add return type annotation:
None
(ANN201)
131-131: Use of
assert
detected(S101)
132-132: Use of
assert
detected(S101)
133-133: Use of
assert
detected(S101)
137-137: Missing return type annotation for public function
test_connectapi
Add return type annotation:
None
(ANN201)
139-139: Trailing comma missing
Add trailing comma
(COM812)
141-141: Use of
assert
detected(S101)
142-142: Use of
assert
detected(S101)
143-143: Use of
assert
detected(S101)
144-144: Use of
assert
detected(S101)
145-145: Use of
assert
detected(S101)
155-155: Missing return type annotation for public function
test_refresh_oauth2_token
Add return type annotation:
None
(ANN201)
156-156: Use of
assert
detected(S101)
158-158: Use of
assert
detected(S101)
160-160: Use of
assert
detected(S101)
161-161: Use of
assert
detected(S101)
162-162: Use of
assert
detected(S101)
166-166: Missing return type annotation for public function
test_download
Add return type annotation:
None
(ANN201)
168-168: Trailing comma missing
Add trailing comma
(COM812)
170-170: Use of
assert
detected(S101)
172-172: Use of
assert
detected(S101)
176-176: Missing return type annotation for public function
test_upload
Add return type annotation:
None
(ANN201)
180-180: Use of
assert
detected(S101)
184-184: Missing return type annotation for public function
test_delete
Add return type annotation:
None
(ANN201)
187-187: Use of
assert
detected(S101)
195-195: Use of
assert
detected(S101)
199-199: Missing return type annotation for public function
test_put
Add return type annotation:
None
(ANN201)
213-213: Trailing comma missing
Add trailing comma
(COM812)
222-222: Use of
assert
detected(S101)
Additional comments not posted (16)
garth/version.py (1)
1-1
: Version update looks good.The version update from "0.4.46" to "0.4.47" is appropriate.
tests/stats/test_sleep_stats.py (3)
9-9
: Use@pytest.mark.vcr()
instead of@pytest.mark.vcr
.Add parentheses to the decorator for consistency and to follow best practices.
10-10
: Redundant return type annotation for pytest functions.Return type annotations for pytest functions are considered redundant and are not necessary to include.
Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_sleep
Add return type annotation:
None
(ANN201)
Line range hint
13-15
: Usingassert
statements is acceptable in pytest.Pytest enhances the built-in
assert
statements to provide detailed error messages, including the values of the variables involved in the assertion.Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_sleep
Add return type annotation:
None
(ANN201)
tests/stats/test_hydration.py (3)
9-9
: Use@pytest.mark.vcr()
instead of@pytest.mark.vcr
.Add parentheses to the decorator for consistency and to follow best practices.
10-10
: Redundant return type annotation for pytest functions.Return type annotations for pytest functions are considered redundant and are not necessary to include.
Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_hydration
Add return type annotation:
None
(ANN201)
13-13
: Usingassert
statements is acceptable in pytest.Pytest enhances the built-in
assert
statements to provide detailed error messages, including the values of the variables involved in the assertion.Tools
Ruff
13-13: Use of
assert
detected(S101)
tests/test_users.py (6)
7-7
: Use@pytest.mark.vcr()
instead of@pytest.mark.vcr
.Add parentheses to the decorator for consistency and to follow best practices.
8-8
: Redundant return type annotation for pytest functions.Return type annotations for pytest functions are considered redundant and are not necessary to include.
Tools
Ruff
8-8: Missing return type annotation for public function
test_user_profile
Add return type annotation:
None
(ANN201)
10-10
: Usingassert
statements is acceptable in pytest.Pytest enhances the built-in
assert
statements to provide detailed error messages, including the values of the variables involved in the assertion.Tools
Ruff
10-10: Use of
assert
detected(S101)
13-13
: Use@pytest.mark.vcr()
instead of@pytest.mark.vcr
.Add parentheses to the decorator for consistency and to follow best practices.
14-14
: Redundant return type annotation for pytest functions.Return type annotations for pytest functions are considered redundant and are not necessary to include.
Tools
Ruff
14-14: Missing return type annotation for public function
test_user_setttings
Add return type annotation:
None
(ANN201)
16-16
: Usingassert
statements is acceptable in pytest.Pytest enhances the built-in
assert
statements to provide detailed error messages, including the values of the variables involved in the assertion.Tools
Ruff
16-16: Use of
assert
detected(S101)
.coderabbit.yaml (1)
1-17
: Configuration settings look good.The configuration file is well-structured and the settings are logical. No issues found.
tests/data/test_hrv_data.py (1)
19-19
: Add return type annotation.The test function
test_hrv_data_list
is missing a return type annotation.- @pytest.mark.vcr() - def test_hrv_data_list(authed_client: Client): + @pytest.mark.vcr() + def test_hrv_data_list(authed_client: Client) -> None:Likely invalid or redundant comment.
tests/data/test_sleep_data.py (1)
18-18
: Add return type annotation.The test function
test_sleep_data_list
is missing a return type annotation.- @pytest.mark.vcr() - def test_sleep_data_list(authed_client: Client): + @pytest.mark.vcr() + def test_sleep_data_list(authed_client: Client) -> None:Likely invalid or redundant comment.
@coderabbitai review |
Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (2)
- .coderabbit.yaml (1 hunks)
- garth/http.py (1 hunks)
Files not reviewed due to errors (1)
- garth/http.py (no review received)
Additional context used
Ruff
garth/http.py
37-37: Missing return type annotation for special method
__init__
Add return type annotation:
None
(ANN204)
37-37: Missing type annotation for
self
in method(ANN101)
37-37: Missing type annotation for
**kwargs
(ANN003)
48-48:
configure
is too complex (12 > 10)(C901)
48-48: Missing return type annotation for public function
configure
Add return type annotation:
None
(ANN201)
49-49: Missing type annotation for
self
in method(ANN101)
99-99: Missing return type annotation for public function
profile
(ANN201)
99-99: Missing type annotation for
self
in method(ANN101)
102-102: Trailing comma missing
Add trailing comma
(COM812)
104-104: Use of
assert
detected(S101)
108-108: Missing return type annotation for public function
username
(ANN201)
108-108: Missing type annotation for
self
in method(ANN101)
112-112: Missing type annotation for
self
in method(ANN101)
117-117: Boolean-typed positional argument in function definition
(FBT001)
117-117: Boolean default positional argument in function definition
(FBT002)
118-118: Boolean default positional argument in function definition
(FBT002)
119-119: Do not use mutable data structures for argument defaults
Replace with
None
; initialize within function(B006)
120-120: Missing type annotation for
**kwargs
(ANN003)
127-127: Use of
assert
detected(S101)
141-144: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
147-147: Missing type annotation for
self
in method(ANN101)
147-147: Missing type annotation for
*args
(ANN002)
147-147: Missing type annotation for
**kwargs
(ANN003)
150-150: Missing type annotation for
self
in method(ANN101)
150-150: Missing type annotation for
*args
(ANN002)
150-150: Missing type annotation for
**kwargs
(ANN003)
153-153: Missing type annotation for
self
in method(ANN101)
153-153: Missing type annotation for
*args
(ANN002)
153-153: Missing type annotation for
**kwargs
(ANN003)
156-156: Missing type annotation for
self
in method(ANN101)
156-156: Missing type annotation for
*args
(ANN002)
156-156: Missing type annotation for
**kwargs
(ANN003)
159-159: Missing return type annotation for public function
login
Add return type annotation:
None
(ANN201)
159-159: Missing type annotation for
self
in method(ANN101)
159-159: Missing type annotation for
*args
(ANN002)
159-159: Missing type annotation for
**kwargs
(ANN003)
161-161: Trailing comma missing
Add trailing comma
(COM812)
164-164: Missing return type annotation for public function
refresh_oauth2
Add return type annotation:
None
(ANN201)
164-164: Missing type annotation for
self
in method(ANN101)
165-165: Use of
assert
detected(S101)
170-170: Missing return type annotation for public function
connectapi
(ANN201)
170-170: Missing type annotation for
self
in method(ANN101)
170-170: Missing type annotation for function argument
method
(ANN001)
170-170: Missing type annotation for
**kwargs
(ANN003)
172-175: Use ternary operator
rv = None if resp.status_code == 204 else resp.json()
instead ofif
-else
-blockReplace
if
-else
-block withrv = None if resp.status_code == 204 else resp.json()
(SIM108)
178-178: Missing type annotation for
self
in method(ANN101)
178-178: Missing type annotation for
**kwargs
(ANN003)
183-183: Missing type annotation for
self
in method(ANN101)
183-183: Trailing comma missing
Add trailing comma
(COM812)
193-193: Missing return type annotation for public function
dump
Add return type annotation:
None
(ANN201)
193-193: Missing type annotation for
self
in method(ANN101)
203-203: Missing type annotation for
self
in method(ANN101)
210-210: Missing return type annotation for public function
load
Add return type annotation:
None
(ANN201)
210-210: Missing type annotation for
self
in method(ANN101)
217-217: Trailing comma missing
Add trailing comma
(COM812)
220-220: Missing return type annotation for public function
loads
Add return type annotation:
None
(ANN201)
220-220: Missing type annotation for
self
in method(ANN101)
@coderabbitai full review |
Actions performedFull review triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range comments (20)
tests/data/test_sleep_data.py (2)
Line range hint
9-15
: Add return type annotation and address the use ofassert
.The function is missing a return type annotation and uses
assert
statements, which can be replaced withpytest.assume()
for better reporting.@pytest.mark.vcr() -def test_sleep_data_get(authed_client: Client): +def test_sleep_data_get(authed_client: Client) -> None: sleep_data = SleepData.get("2021-07-20", client=authed_client) - assert sleep_data - assert sleep_data.daily_sleep_dto.calendar_date == date(2021, 7, 20) - assert sleep_data.daily_sleep_dto.sleep_start - assert sleep_data.daily_sleep_dto.sleep_end + pytest.assume(sleep_data) + pytest.assume(sleep_data.daily_sleep_dto.calendar_date == date(2021, 7, 20)) + pytest.assume(sleep_data.daily_sleep_dto.sleep_start) + pytest.assume(sleep_data.daily_sleep_dto.sleep_end)Tools
Ruff
10-10: Missing return type annotation for public function
test_sleep_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
Line range hint
18-24
: Add return type annotation and address the use ofassert
.The function is missing a return type annotation and uses
assert
statements, which can be replaced withpytest.assume()
for better reporting.@pytest.mark.vcr() -def test_sleep_data_list(authed_client: Client): +def test_sleep_data_list(authed_client: Client) -> None: end = date(2021, 7, 20) days = 20 sleep_data = SleepData.list(end, days, client=authed_client, max_workers=1) - assert sleep_data[-1].daily_sleep_dto.calendar_date == end - assert len(sleep_data) == days + pytest.assume(sleep_data[-1].daily_sleep_dto.calendar_date == end) + pytest.assume(len(sleep_data) == days)Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_sleep_data_list
Add return type annotation:
None
(ANN201)
tests/stats/test_intensity_minutes.py (2)
Line range hint
9-15
: Add return type annotation and address the use ofassert
.The function is missing a return type annotation and uses
assert
statements, which can be replaced withpytest.assume()
for better reporting.@pytest.mark.vcr() -def test_daily_intensity_minutes(authed_client: Client): +def test_daily_intensity_minutes(authed_client: Client) -> None: end = date(2023, 7, 20) days = 20 daily_im = DailyIntensityMinutes.list(end, days, client=authed_client) - assert daily_im[-1].calendar_date == end - assert len(daily_im) == days + pytest.assume(daily_im[-1].calendar_date == end) + pytest.assume(len(daily_im) == days)Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_intensity_minutes
Add return type annotation:
None
(ANN201)
Line range hint
18-24
: Add return type annotation and address the use ofassert
.The function is missing a return type annotation and uses
assert
statements, which can be replaced withpytest.assume()
for better reporting.@pytest.mark.vcr() -def test_weekly_intensity_minutes(authed_client: Client): +def test_weekly_intensity_minutes(authed_client: Client) -> None: end = date(2023, 7, 20) weeks = 12 weekly_im = WeeklyIntensityMinutes.list(end, weeks, client=authed_client) - assert len(weekly_im) == weeks - assert ( - weekly_im[-1].calendar_date.isocalendar()[ - 1 - ] # in python3.9+ [1] can be .week - == end.isocalendar()[1] - ) + pytest.assume(len(weekly_im) == weeks) + pytest.assume( + weekly_im[-1].calendar_date.isocalendar()[ + 1 + ] # in python3.9+ [1] can be .week + == end.isocalendar()[1] + )Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_weekly_intensity_minutes
Add return type annotation:
None
(ANN201)
tests/stats/test_hrv.py (3)
Line range hint
14-15
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_hrv[-1].calendar_date == end - assert len(daily_hrv) == days + pytest.assume(daily_hrv[-1].calendar_date == end) + pytest.assume(len(daily_hrv) == days)Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_hrv_paginate
Add return type annotation:
None
(ANN201)
Line range hint
23-24
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_hrv[-1].calendar_date == end - assert len(daily_hrv) == days + pytest.assume(daily_hrv[-1].calendar_date == end) + pytest.assume(len(daily_hrv) == days)Tools
Ruff
24-24: Use of
assert
detected(S101)
28-28: Missing return type annotation for public function
test_daily_hrv_no_results
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
35-35: Missing return type annotation for public function
test_daily_hrv_paginate_no_results
Add return type annotation:
None
(ANN201)
Line range hint
39-39
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_hrv == [] + pytest.assume(daily_hrv == [])Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_hrv
Add return type annotation:
None
(ANN201)
tests/stats/test_stress.py (4)
Line range hint
14-15
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_stress[-1].calendar_date == end - assert len(daily_stress) == days + pytest.assume(daily_stress[-1].calendar_date == end) + pytest.assume(len(daily_stress) == days)Tools
Ruff
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_stress_pagination
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
27-27: Missing return type annotation for public function
test_weekly_stress
Add return type annotation:
None
(ANN201)
Line range hint
31-32
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert len(weekly_stress) == weeks - assert weekly_stress[-1].calendar_date == end - timedelta(days=6) + pytest.assume(len(weekly_stress) == weeks) + pytest.assume(weekly_stress[-1].calendar_date == end - timedelta(days=6))Tools
Ruff
32-32: Use of
assert
detected(S101)
36-36: Missing return type annotation for public function
test_weekly_stress_pagination
Add return type annotation:
None
(ANN201)
Line range hint
40-41
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert len(weekly_stress) == weeks - assert weekly_stress[-1].calendar_date == end - timedelta(days=6) + pytest.assume(len(weekly_stress) == weeks) + pytest.assume(weekly_stress[-1].calendar_date == end - timedelta(days=6))Tools
Ruff
41-41: Use of
assert
detected(S101)
45-45: Missing return type annotation for public function
test_weekly_stress_beyond_data
Add return type annotation:
None
(ANN201)
Line range hint
49-49
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert len(weekly_stress) < weeks + pytest.assume(len(weekly_stress) < weeks)Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_stress
Add return type annotation:
None
(ANN201)
tests/test_sso.py (1)
Line range hint
23-26
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert oauth1 - assert isinstance(oauth1, OAuth1Token) - assert oauth2 - assert isinstance(oauth2, OAuth2Token) + pytest.assume(oauth1) + pytest.assume(isinstance(oauth1, OAuth1Token)) + pytest.assume(oauth2) + pytest.assume(isinstance(oauth2, OAuth2Token))Tools
Ruff
26-26: Use of
assert
detected(S101)
30-30: Missing return type annotation for public function
test_login_success_mfa
Add return type annotation:
None
(ANN201)
30-30: Missing type annotation for function argument
monkeypatch
(ANN001)
31-31: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
31-31: Missing type annotation for function argument
_
(ANN001)
tests/test_http.py (7)
Line range hint
105-112
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_client_request(client: Client) -> None: resp = client.request("GET", "connect", "/") - assert resp.ok + pytest.assume(resp.ok) with pytest.raises(GarthHTTPError) as e: client.request("GET", "connectapi", "/") - assert "404" in str(e.value) + pytest.assume("404" in str(e.value))Tools
Ruff
102-102: Use of
assert
detected(S101)
106-106: Missing return type annotation for public function
test_client_request
Add return type annotation:
None
(ANN201)
108-108: Use of
assert
detected(S101)
Line range hint
115-126
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_login_success_mfa(monkeypatch, client: Client) -> None: def mock_input(_) -> str: return "327751" monkeypatch.setattr("builtins.input", mock_input) - assert client.oauth1_token is None - assert client.oauth2_token is None + pytest.assume(client.oauth1_token is None) + pytest.assume(client.oauth2_token is None) client.login("[email protected]", "correct_password") - assert client.oauth1_token - assert client.oauth2_token + pytest.assume(client.oauth1_token) + pytest.assume(client.oauth2_token)Tools
Ruff
112-112: Use of
assert
detected(S101)
116-116: Missing return type annotation for public function
test_login_success_mfa
Add return type annotation:
None
(ANN201)
116-116: Missing type annotation for function argument
monkeypatch
(ANN001)
117-117: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
117-117: Missing type annotation for function argument
_
(ANN001)
Line range hint
136-145
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_connectapi(authed_client: Client) -> None: stress = authed_client.connectapi( "/usersummary-service/stats/stress/daily/2023-07-21/2023-07-21" ) - assert stress - assert isinstance(stress, list) - assert len(stress) == 1 - assert stress[0]["calendarDate"] == "2023-07-21" - assert list(stress[0]["values"].keys()) == [ + pytest.assume(stress) + pytest.assume(isinstance(stress, list)) + pytest.assume(len(stress) == 1) + pytest.assume(stress[0]["calendarDate"] == "2023-07-21") + pytest.assume(list(stress[0]["values"].keys()) == [ "highStressDuration", "lowStressDuration", "overallStressLevel", "restStressDuration", "mediumStressDuration", - ] + ])Tools
Ruff
126-126: Use of
assert
detected(S101)
130-130: Missing return type annotation for public function
test_username
Add return type annotation:
None
(ANN201)
131-131: Use of
assert
detected(S101)
132-132: Use of
assert
detected(S101)
133-133: Use of
assert
detected(S101)
137-137: Missing return type annotation for public function
test_connectapi
Add return type annotation:
None
(ANN201)
139-139: Trailing comma missing
Add trailing comma
(COM812)
Line range hint
154-162
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_refresh_oauth2_token(authed_client: Client) -> None: - assert authed_client.oauth2_token + pytest.assume(authed_client.oauth2_token) authed_client.oauth2_token.expires_at = int(time.time()) - assert authed_client.oauth2_token.expired + pytest.assume(authed_client.oauth2_token.expired) profile = authed_client.connectapi("/userprofile-service/socialProfile") - assert profile - assert isinstance(profile, dict) - assert profile["userName"] + pytest.assume(profile) + pytest.assume(isinstance(profile, dict)) + pytest.assume(profile["userName"])Tools
Ruff
155-155: Missing return type annotation for public function
test_refresh_oauth2_token
Add return type annotation:
None
(ANN201)
156-156: Use of
assert
detected(S101)
Line range hint
165-172
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_download(authed_client: Client) -> None: downloaded = authed_client.download( "/download-service/files/activity/11998957007" ) - assert downloaded + pytest.assume(downloaded) zip_magic_number = b"\x50\x4B\x03\x04" - assert downloaded[:4] == zip_magic_number + pytest.assume(downloaded[:4] == zip_magic_number)Tools
Ruff
162-162: Use of
assert
detected(S101)
166-166: Missing return type annotation for public function
test_download
Add return type annotation:
None
(ANN201)
168-168: Trailing comma missing
Add trailing comma
(COM812)
Line range hint
183-195
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_delete(authed_client: Client) -> None: activity_id = "12135235656" path = f"/activity-service/activity/{activity_id}" - assert authed_client.connectapi(path) + pytest.assume(authed_client.connectapi(path)) authed_client.delete( "connectapi", path, api=True, ) with pytest.raises(GarthHTTPError) as e: authed_client.connectapi(path) - assert "404" in str(e.value) + pytest.assume("404" in str(e.value))Tools
Ruff
172-172: Use of
assert
detected(S101)
176-176: Missing return type annotation for public function
test_upload
Add return type annotation:
None
(ANN201)
180-180: Use of
assert
detected(S101)
184-184: Missing return type annotation for public function
test_delete
Add return type annotation:
None
(ANN201)
Line range hint
198-222
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_put(authed_client: Client) -> None: data = [ { "changeState": "CHANGED", "trainingMethod": "HR_RESERVE", "lactateThresholdHeartRateUsed": 170, "maxHeartRateUsed": 185, "restingHrAutoUpdateUsed": False, "sport": "DEFAULT", "zone1Floor": 130, "zone2Floor": 140, "zone3Floor": 150, "zone4Floor": 160, "zone5Floor": 170, } ] path = "/biometric-service/heartRateZones" authed_client.put( "connectapi", path, api=True, json=data, ) - assert authed_client.connectapi(path) + pytest.assume(authed_client.connectapi(path))Tools
Ruff
195-195: Use of
assert
detected(S101)
199-199: Missing return type annotation for public function
test_put
Add return type annotation:
None
(ANN201)
garth/http.py (1)
Line range hint
184-188
: Add type annotations and handle file paths more robustly.Add type annotations for the method parameters and ensure file paths are handled correctly.
def upload( - self, fp: IO[bytes], /, path: str = "/upload-service/upload" + self, fp: IO[bytes], /, path: str = "/upload-service/upload" ) -> Optional[Dict[str, Any]]: fname = os.path.basename(fp.name) files = {"file": (fname, fp)} return self.connectapi( path, method="POST", files=files, )Tools
Ruff
183-183: Missing type annotation for
self
in method(ANN101)
183-183: Trailing comma missing
Add trailing comma
(COM812)
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files ignored due to path filters (1)
tests/stats/cassettes/test_daily_hydration.yaml
is excluded by!tests/**/cassettes/**
Files selected for processing (18)
- .coderabbit.yaml (1 hunks)
- garth/init.py (2 hunks)
- garth/http.py (1 hunks)
- garth/stats/init.py (2 hunks)
- garth/stats/_base.py (3 hunks)
- garth/stats/hydration.py (1 hunks)
- garth/version.py (1 hunks)
- tests/data/test_hrv_data.py (2 hunks)
- tests/data/test_sleep_data.py (2 hunks)
- tests/stats/test_hrv.py (3 hunks)
- tests/stats/test_hydration.py (1 hunks)
- tests/stats/test_intensity_minutes.py (2 hunks)
- tests/stats/test_sleep_stats.py (1 hunks)
- tests/stats/test_steps.py (2 hunks)
- tests/stats/test_stress.py (4 hunks)
- tests/test_http.py (7 hunks)
- tests/test_sso.py (4 hunks)
- tests/test_users.py (1 hunks)
Additional context used
Path-based instructions (11)
tests/stats/test_sleep_stats.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/stats/test_hydration.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/test_users.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/stats/test_steps.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/data/test_hrv_data.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/data/test_sleep_data.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/stats/test_intensity_minutes.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/stats/test_hrv.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/stats/test_stress.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/test_sso.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
tests/test_http.py (1)
Pattern
tests/**
: - test functions shouldn't have a return type hint
- it's ok to use
assert
instead ofpytest.assume()
Learnings (2)
tests/stats/test_hydration.py (1)
Learnt from: matin PR: matin/garth#61 File: tests/stats/test_hydration.py:10-10 Timestamp: 2024-06-30T03:39:40.523Z Learning: For pytest functions, return type annotations are considered redundant and are not necessary to include.
tests/stats/test_stress.py (1)
Learnt from: matin PR: matin/garth#61 File: tests/stats/test_stress.py:26-26 Timestamp: 2024-06-30T03:56:29.941Z Learning: matin prefers not to add return type hints for pytest functions and has requested guidance on configuring CodeRabbit to avoid such suggestions.
Ruff
tests/stats/test_sleep_stats.py
10-10: Missing return type annotation for public function
test_daily_sleep
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
tests/stats/test_hydration.py
10-10: Missing return type annotation for public function
test_daily_hydration
Add return type annotation:
None
(ANN201)
13-13: Use of
assert
detected(S101)
tests/test_users.py
8-8: Missing return type annotation for public function
test_user_profile
Add return type annotation:
None
(ANN201)
10-10: Use of
assert
detected(S101)
14-14: Missing return type annotation for public function
test_user_setttings
Add return type annotation:
None
(ANN201)
16-16: Use of
assert
detected(S101)
tests/stats/test_steps.py
10-10: Missing return type annotation for public function
test_daily_steps
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_weekly_steps
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
tests/data/test_hrv_data.py
10-10: Missing return type annotation for public function
test_hrv_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
13-13: Use of
assert
detected(S101)
14-14: Use of
assert
detected(S101)
16-16: Use of
assert
detected(S101)
20-20: Missing return type annotation for public function
test_hrv_data_list
Add return type annotation:
None
(ANN201)
24-24: Use of
assert
detected(S101)
25-25: Use of
assert
detected(S101)
tests/data/test_sleep_data.py
10-10: Missing return type annotation for public function
test_sleep_data_get
Add return type annotation:
None
(ANN201)
12-12: Use of
assert
detected(S101)
13-13: Use of
assert
detected(S101)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_sleep_data_list
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
tests/stats/test_intensity_minutes.py
10-10: Missing return type annotation for public function
test_daily_intensity_minutes
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_weekly_intensity_minutes
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
tests/stats/test_hrv.py
10-10: Missing return type annotation for public function
test_daily_hrv
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_hrv_paginate
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
28-28: Missing return type annotation for public function
test_daily_hrv_no_results
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
35-35: Missing return type annotation for public function
test_daily_hrv_paginate_no_results
Add return type annotation:
None
(ANN201)
39-39: Use of
assert
detected(S101)
tests/stats/test_stress.py
10-10: Missing return type annotation for public function
test_daily_stress
Add return type annotation:
None
(ANN201)
14-14: Use of
assert
detected(S101)
15-15: Use of
assert
detected(S101)
19-19: Missing return type annotation for public function
test_daily_stress_pagination
Add return type annotation:
None
(ANN201)
23-23: Use of
assert
detected(S101)
27-27: Missing return type annotation for public function
test_weekly_stress
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
32-32: Use of
assert
detected(S101)
36-36: Missing return type annotation for public function
test_weekly_stress_pagination
Add return type annotation:
None
(ANN201)
40-40: Use of
assert
detected(S101)
41-41: Use of
assert
detected(S101)
45-45: Missing return type annotation for public function
test_weekly_stress_beyond_data
Add return type annotation:
None
(ANN201)
49-49: Use of
assert
detected(S101)
tests/test_sso.py
12-12: Missing return type annotation for public function
test_login_email_password_fail
Add return type annotation:
None
(ANN201)
18-18: Missing return type annotation for public function
test_login_success
Add return type annotation:
None
(ANN201)
20-20: Trailing comma missing
Add trailing comma
(COM812)
23-23: Use of
assert
detected(S101)
24-24: Use of
assert
detected(S101)
25-25: Use of
assert
detected(S101)
26-26: Use of
assert
detected(S101)
30-30: Missing return type annotation for public function
test_login_success_mfa
Add return type annotation:
None
(ANN201)
30-30: Missing type annotation for function argument
monkeypatch
(ANN001)
31-31: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
31-31: Missing type annotation for function argument
_
(ANN001)
36-36: Trailing comma missing
Add trailing comma
(COM812)
39-39: Use of
assert
detected(S101)
40-40: Use of
assert
detected(S101)
41-41: Use of
assert
detected(S101)
42-42: Use of
assert
detected(S101)
46-46: Missing return type annotation for public function
test_login_success_mfa_async
Add return type annotation:
None
(ANN201)
46-46: Missing type annotation for function argument
monkeypatch
(ANN001)
47-47: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
47-47: Missing type annotation for function argument
_
(ANN001)
50-50: Missing return type annotation for private function
prompt_mfa
(ANN202)
61-61: Use of
assert
detected(S101)
62-62: Use of
assert
detected(S101)
63-63: Use of
assert
detected(S101)
64-64: Use of
assert
detected(S101)
67-67: Missing return type annotation for public function
test_set_expirations
Add return type annotation:
None
(ANN201)
69-69: Use of
assert
detected(S101)
72-72: Use of
assert
detected(S101)
81-81: Missing return type annotation for public function
test_exchange
Add return type annotation:
None
(ANN201)
82-82: Use of
assert
detected(S101)
85-85: Use of
assert
detected(S101)
86-86: Use of
assert
detected(S101)
87-87: Use of
assert
detected(S101)
88-88: Use of
assert
detected(S101)
91-91: Missing return type annotation for public function
test_get_csrf_token
Add return type annotation:
None
(ANN201)
102-102: Use of
assert
detected(S101)
105-105: Missing return type annotation for public function
test_get_csrf_token_fail
Add return type annotation:
None
(ANN201)
119-119: Missing return type annotation for public function
test_get_title
Add return type annotation:
None
(ANN201)
130-130: Use of
assert
detected(S101)
133-133: Missing return type annotation for public function
test_get_title_fail
Add return type annotation:
None
(ANN201)
tests/test_http.py
11-11: Missing return type annotation for public function
test_dump_and_load
Add return type annotation:
None
(ANN201)
18-18: Use of
assert
detected(S101)
19-19: Use of
assert
detected(S101)
22-22: Missing return type annotation for public function
test_dumps_and_loads
Add return type annotation:
None
(ANN201)
26-26: Use of
assert
detected(S101)
27-27: Use of
assert
detected(S101)
30-30: Missing return type annotation for public function
test_configure_oauth2_token
Add return type annotation:
None
(ANN201)
31-31: Use of
assert
detected(S101)
33-33: Use of
assert
detected(S101)
36-36: Missing return type annotation for public function
test_configure_domain
Add return type annotation:
None
(ANN201)
37-37: Use of
assert
detected(S101)
39-39: Use of
assert
detected(S101)
42-42: Missing return type annotation for public function
test_configure_proxies
Add return type annotation:
None
(ANN201)
43-43: Use of
assert
detected(S101)
46-46: Use of
assert
detected(S101)
49-49: Missing return type annotation for public function
test_configure_ssl_verify
Add return type annotation:
None
(ANN201)
50-50: Use of
assert
detected(S101)
52-52: Use of
assert
detected(S101)
55-55: Missing return type annotation for public function
test_configure_timeout
Add return type annotation:
None
(ANN201)
56-56: Use of
assert
detected(S101)
58-58: Use of
assert
detected(S101)
61-61: Missing return type annotation for public function
test_configure_retry
Add return type annotation:
None
(ANN201)
62-62: Use of
assert
detected(S101)
63-63: Use of
assert
detected(S101)
65-65: Use of
assert
detected(S101)
66-66: Use of
assert
detected(S101)
69-69: Missing return type annotation for public function
test_configure_status_forcelist
Add return type annotation:
None
(ANN201)
70-70: Use of
assert
detected(S101)
71-71: Use of
assert
detected(S101)
76-76: Use of
assert
detected(S101)
79-79: Missing return type annotation for public function
test_backoff_factor
Add return type annotation:
None
(ANN201)
80-80: Use of
assert
detected(S101)
81-81: Use of
assert
detected(S101)
86-86: Use of
assert
detected(S101)
87-87: Use of
assert
detected(S101)
93-93: Missing return type annotation for public function
test_pool_connections
Add return type annotation:
None
(ANN201)
98-98: Use of
assert
detected(S101)
99-99: Use of
assert
detected(S101)
101-101: Use of
assert
detected(S101)
102-102: Use of
assert
detected(S101)
106-106: Missing return type annotation for public function
test_client_request
Add return type annotation:
None
(ANN201)
108-108: Use of
assert
detected(S101)
112-112: Use of
assert
detected(S101)
116-116: Missing return type annotation for public function
test_login_success_mfa
Add return type annotation:
None
(ANN201)
116-116: Missing type annotation for function argument
monkeypatch
(ANN001)
117-117: Missing return type annotation for private function
mock_input
Add return type annotation:
str
(ANN202)
117-117: Missing type annotation for function argument
_
(ANN001)
122-122: Use of
assert
detected(S101)
123-123: Use of
assert
detected(S101)
125-125: Use of
assert
detected(S101)
126-126: Use of
assert
detected(S101)
130-130: Missing return type annotation for public function
test_username
Add return type annotation:
None
(ANN201)
131-131: Use of
assert
detected(S101)
132-132: Use of
assert
detected(S101)
133-133: Use of
assert
detected(S101)
137-137: Missing return type annotation for public function
test_connectapi
Add return type annotation:
None
(ANN201)
139-139: Trailing comma missing
Add trailing comma
(COM812)
141-141: Use of
assert
detected(S101)
142-142: Use of
assert
detected(S101)
143-143: Use of
assert
detected(S101)
144-144: Use of
assert
detected(S101)
145-145: Use of
assert
detected(S101)
155-155: Missing return type annotation for public function
test_refresh_oauth2_token
Add return type annotation:
None
(ANN201)
156-156: Use of
assert
detected(S101)
158-158: Use of
assert
detected(S101)
160-160: Use of
assert
detected(S101)
161-161: Use of
assert
detected(S101)
162-162: Use of
assert
detected(S101)
166-166: Missing return type annotation for public function
test_download
Add return type annotation:
None
(ANN201)
168-168: Trailing comma missing
Add trailing comma
(COM812)
170-170: Use of
assert
detected(S101)
172-172: Use of
assert
detected(S101)
176-176: Missing return type annotation for public function
test_upload
Add return type annotation:
None
(ANN201)
180-180: Use of
assert
detected(S101)
184-184: Missing return type annotation for public function
test_delete
Add return type annotation:
None
(ANN201)
187-187: Use of
assert
detected(S101)
195-195: Use of
assert
detected(S101)
199-199: Missing return type annotation for public function
test_put
Add return type annotation:
None
(ANN201)
213-213: Trailing comma missing
Add trailing comma
(COM812)
222-222: Use of
assert
detected(S101)
garth/http.py
37-37: Missing return type annotation for special method
__init__
Add return type annotation:
None
(ANN204)
37-37: Missing type annotation for
self
in method(ANN101)
37-37: Missing type annotation for
**kwargs
(ANN003)
48-48:
configure
is too complex (12 > 10)(C901)
48-48: Missing return type annotation for public function
configure
Add return type annotation:
None
(ANN201)
49-49: Missing type annotation for
self
in method(ANN101)
99-99: Missing return type annotation for public function
profile
(ANN201)
99-99: Missing type annotation for
self
in method(ANN101)
102-102: Trailing comma missing
Add trailing comma
(COM812)
104-104: Use of
assert
detected(S101)
108-108: Missing return type annotation for public function
username
(ANN201)
108-108: Missing type annotation for
self
in method(ANN101)
112-112: Missing type annotation for
self
in method(ANN101)
117-117: Boolean-typed positional argument in function definition
(FBT001)
117-117: Boolean default positional argument in function definition
(FBT002)
118-118: Boolean default positional argument in function definition
(FBT002)
119-119: Do not use mutable data structures for argument defaults
Replace with
None
; initialize within function(B006)
120-120: Missing type annotation for
**kwargs
(ANN003)
127-127: Use of
assert
detected(S101)
141-144: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
147-147: Missing type annotation for
self
in method(ANN101)
147-147: Missing type annotation for
*args
(ANN002)
147-147: Missing type annotation for
**kwargs
(ANN003)
150-150: Missing type annotation for
self
in method(ANN101)
150-150: Missing type annotation for
*args
(ANN002)
150-150: Missing type annotation for
**kwargs
(ANN003)
153-153: Missing type annotation for
self
in method(ANN101)
153-153: Missing type annotation for
*args
(ANN002)
153-153: Missing type annotation for
**kwargs
(ANN003)
156-156: Missing type annotation for
self
in method(ANN101)
156-156: Missing type annotation for
*args
(ANN002)
156-156: Missing type annotation for
**kwargs
(ANN003)
159-159: Missing return type annotation for public function
login
Add return type annotation:
None
(ANN201)
159-159: Missing type annotation for
self
in method(ANN101)
159-159: Missing type annotation for
*args
(ANN002)
159-159: Missing type annotation for
**kwargs
(ANN003)
161-161: Trailing comma missing
Add trailing comma
(COM812)
164-164: Missing return type annotation for public function
refresh_oauth2
Add return type annotation:
None
(ANN201)
164-164: Missing type annotation for
self
in method(ANN101)
165-165: Use of
assert
detected(S101)
170-170: Missing return type annotation for public function
connectapi
(ANN201)
170-170: Missing type annotation for
self
in method(ANN101)
170-170: Missing type annotation for function argument
method
(ANN001)
170-170: Missing type annotation for
**kwargs
(ANN003)
172-175: Use ternary operator
rv = None if resp.status_code == 204 else resp.json()
instead ofif
-else
-blockReplace
if
-else
-block withrv = None if resp.status_code == 204 else resp.json()
(SIM108)
178-178: Missing type annotation for
self
in method(ANN101)
178-178: Missing type annotation for
**kwargs
(ANN003)
183-183: Missing type annotation for
self
in method(ANN101)
183-183: Trailing comma missing
Add trailing comma
(COM812)
193-193: Missing return type annotation for public function
dump
Add return type annotation:
None
(ANN201)
193-193: Missing type annotation for
self
in method(ANN101)
203-203: Missing type annotation for
self
in method(ANN101)
210-210: Missing return type annotation for public function
load
Add return type annotation:
None
(ANN201)
210-210: Missing type annotation for
self
in method(ANN101)
217-217: Trailing comma missing
Add trailing comma
(COM812)
220-220: Missing return type annotation for public function
loads
Add return type annotation:
None
(ANN201)
220-220: Missing type annotation for
self
in method(ANN101)
Additional comments not posted (25)
garth/version.py (1)
1-1
: Version update approved.The version has been updated to "0.4.47".
tests/stats/test_sleep_stats.py (3)
9-9
: Decorator change approved.The
@pytest.mark.vcr
decorator now includes parentheses for consistency and best practices.
Line range hint
13-15
: Avoid usingassert
statements in tests.Using
assert
statements is not recommended in tests as it can lead to less informative error messages. Usepytest
's enhancedassert
statements instead.assert daily_sleep[-1].calendar_date == end assert len(daily_sleep) == daysTools
Ruff
10-10: Missing return type annotation for public function
test_daily_sleep
Add return type annotation:
None
(ANN201)
10-10
: Add return type annotation totest_daily_sleep
.Public functions should have return type annotations for clarity.
- def test_daily_sleep(authed_client: Client): + def test_daily_sleep(authed_client: Client) -> None:Likely invalid or redundant comment.
Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_sleep
Add return type annotation:
None
(ANN201)
tests/stats/test_hydration.py (3)
9-9
: Decorator change approved.The
@pytest.mark.vcr
decorator now includes parentheses for consistency and best practices.
13-13
: Avoid usingassert
statements in tests.Using
assert
statements is not recommended in tests as it can lead to less informative error messages. Usepytest
's enhancedassert
statements instead.assert daily_hydration[-1].calendar_date == endTools
Ruff
13-13: Use of
assert
detected(S101)
10-10
: Add return type annotation totest_daily_hydration
.Public functions should have return type annotations for clarity.
- def test_daily_hydration(authed_client: Client): + def test_daily_hydration(authed_client: Client) -> None:Likely invalid or redundant comment.
Tools
Ruff
10-10: Missing return type annotation for public function
test_daily_hydration
Add return type annotation:
None
(ANN201)
tests/test_users.py (6)
7-7
: Decorator change approved.The
@pytest.mark.vcr
decorator now includes parentheses for consistency and best practices.
10-10
: Avoid usingassert
statements in tests.Using
assert
statements is not recommended in tests as it can lead to less informative error messages. Usepytest
's enhancedassert
statements instead.assert profile.user_nameTools
Ruff
10-10: Use of
assert
detected(S101)
13-13
: Decorator change approved.The
@pytest.mark.vcr
decorator now includes parentheses for consistency and best practices.
16-16
: Avoid usingassert
statements in tests.Using
assert
statements is not recommended in tests as it can lead to less informative error messages. Usepytest
's enhancedassert
statements instead.assert settings.user_dataTools
Ruff
16-16: Use of
assert
detected(S101)
8-8
: Add return type annotation totest_user_profile
.Public functions should have return type annotations for clarity.
- def test_user_profile(authed_client: Client): + def test_user_profile(authed_client: Client) -> None:Likely invalid or redundant comment.
Tools
Ruff
8-8: Missing return type annotation for public function
test_user_profile
Add return type annotation:
None
(ANN201)
14-14
: Add return type annotation totest_user_setttings
.Public functions should have return type annotations for clarity.
- def test_user_setttings(authed_client: Client): + def test_user_setttings(authed_client: Client) -> None:Likely invalid or redundant comment.
Tools
Ruff
14-14: Missing return type annotation for public function
test_user_setttings
Add return type annotation:
None
(ANN201)
garth/stats/hydration.py (1)
1-16
: LGTM!The
DailyHydration
class is correctly defined with appropriate attributes and types.garth/stats/__init__.py (1)
3-3
: LGTM!The
DailyHydration
class is correctly imported and included in the__all__
list.tests/stats/test_steps.py (2)
18-18
: Add return type annotation.The test function
test_weekly_steps
is missing a return type annotation.@pytest.mark.vcr() def test_weekly_steps(authed_client: Client) -> None:Likely invalid or redundant comment.
9-9
: Add return type annotation.The test function
test_daily_steps
is missing a return type annotation.@pytest.mark.vcr() def test_daily_steps(authed_client: Client) -> None:Likely invalid or redundant comment.
tests/data/test_hrv_data.py (2)
19-19
: Add return type annotation.The test function
test_hrv_data_list
is missing a return type annotation.@pytest.mark.vcr() def test_hrv_data_list(authed_client: Client) -> None:Likely invalid or redundant comment.
9-9
: Add return type annotation.The test function
test_hrv_data_get
is missing a return type annotation.@pytest.mark.vcr() def test_hrv_data_get(authed_client: Client) -> None:Likely invalid or redundant comment.
.coderabbit.yaml (1)
2-22
: LGTM!The configuration settings are correctly formatted and logical.
garth/__init__.py (1)
5-5
: LGTM!The
DailyHydration
class is correctly added to the imports and the__all__
list.Also applies to: 20-20
tests/stats/test_hrv.py (1)
31-31
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert daily_hrv == [] + pytest.assume(daily_hrv == [])Likely invalid or redundant comment.
Tools
Ruff
31-31: Use of
assert
detected(S101)
tests/stats/test_stress.py (1)
23-23
: Replaceassert
statements withpytest
assertions.Using
assert
statements is not recommended in tests. Replace them withpytest
assertions for better error messages and consistency.- assert len(daily_stress) == days + pytest.assume(len(daily_stress) == days)Likely invalid or redundant comment.
Tools
Ruff
23-23: Use of
assert
detected(S101)
tests/test_http.py (2)
129-133
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_username(authed_client: Client) -> None: - assert authed_client._profile is None - assert authed_client.username - assert authed_client._profile + pytest.assume(authed_client._profile is None) + pytest.assume(authed_client.username) + pytest.assume(authed_client._profile)Likely invalid or redundant comment.
Tools
Ruff
130-130: Missing return type annotation for public function
test_username
Add return type annotation:
None
(ANN201)
131-131: Use of
assert
detected(S101)
132-132: Use of
assert
detected(S101)
133-133: Use of
assert
detected(S101)
175-180
: Replaceassert
statements withpytest.assume
.Replace the
assert
statements withpytest.assume
to adhere to best practices in pytest.@pytest.mark.vcr() def test_upload(authed_client: Client) -> None: fpath = "tests/12129115726_ACTIVITY.fit" with open(fpath, "rb") as f: uploaded = authed_client.upload(f) - assert uploaded + pytest.assume(uploaded)Likely invalid or redundant comment.
Tools
Ruff
176-176: Missing return type annotation for public function
test_upload
Add return type annotation:
None
(ANN201)
180-180: Use of
assert
detected(S101)
@@ -0,0 +1,22 @@ | |||
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json # Schema for CodeRabbit configurations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a description for the schema URL.
Adding a brief description for the schema URL can improve the readability of the configuration file.
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json # Schema for CodeRabbit configurations
Would you like me to add this comment for better clarity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matin, I've added the requested description to the .coderabbit.yaml
file for better clarity.
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json # Schema for CodeRabbit configurations
This should improve the readability of the configuration file.
Learnings added
Learnt from: matin
PR: matin/garth#61
File: .coderabbit.yaml:1-1
Timestamp: 2024-07-01T19:11:47.476Z
Learning: When updating the `.coderabbit.yaml` file, adding a brief description for the schema URL can improve readability and clarity.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
@@ -32,15 +30,14 @@ def list( | |||
page = cls.list(end, cls._page_size, client=client) | |||
if not page: | |||
return [] | |||
page = ( | |||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider optimizing recursive calls.
The recursive call to cls.list
can be optimized to avoid deep recursion, which might lead to stack overflow for large periods. Consider using iteration instead.
def list(
cls: Type["Stats"],
end: Union[date, str, None] = None,
period: int = 1,
*,
client: Optional[http.Client] = None,
) -> List["Stats"]:
client = client or http.client
end = format_end_date(end)
period_type = "days" if "daily" in cls._path else "weeks"
results = []
while period > cls._page_size:
page = cls.list(end, cls._page_size, client=client)
if not page:
return results
results = page + results
end -= timedelta(**{period_type: cls._page_size})
period -= cls._page_size
start = end - timedelta(**{period_type: period - 1})
path = cls._path.format(start=start, end=end, period=period)
page_dirs = client.connectapi(path)
if not page_dirs:
return results
if "values" in page_dirs[0]:
page_dirs = [{**stat, **stat.pop("values")} for stat in page_dirs]
page_dirs = [camel_to_snake_dict(stat) for stat in page_dirs]
return [cls(**stat) for stat in page_dirs] + results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai full review
Add hydration stats.
Closes issue #54
Summary by CodeRabbit
@pytest.mark.vcr()
decorator for enhanced consistency in testing.