Skip to content

Commit 1aedf0b

Browse files
committed
Linting fixes
1 parent e65c413 commit 1aedf0b

19 files changed

+7414
-1211
lines changed

garminconnect/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ def _fmt_ts(dt: datetime) -> str:
9090
# Use ms precision to match server expectations
9191
return dt.replace(tzinfo=None).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3]
9292

93+
9394
def _validate_json_exists(response: requests.Response) -> dict[str, Any] | None:
94-
if response.status_code == 204:
95+
if response.status_code == 204:
9596
return None
96-
return response.json()
97+
return response.json()
9798

9899

99100
class Garmin:

tests/cassettes/test_all_day_stress.yaml

Lines changed: 311 additions & 65 deletions
Large diffs are not rendered by default.

tests/cassettes/test_body_battery.yaml

Lines changed: 318 additions & 45 deletions
Large diffs are not rendered by default.

tests/cassettes/test_body_composition.yaml

Lines changed: 302 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interactions:
1111
Connection:
1212
- keep-alive
1313
Cookie:
14-
- _cfuvid=SANITIZED
14+
- SANITIZED
1515
User-Agent:
1616
- GCM-iOS-5.7.2.1
1717
method: GET
@@ -54,32 +54,14 @@ interactions:
5454
"DAILY", "startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
5555
23400}]}'
5656
headers:
57-
CF-RAY:
58-
- 97830505dbf70bb9-AMS
5957
Cache-Control:
6058
- no-cache, no-store, private
6159
Connection:
6260
- keep-alive
63-
Content-Encoding:
64-
- gzip
6561
Content-Type:
6662
- application/json;charset=UTF-8
67-
Date:
68-
- Mon, 01 Sep 2025 07:22:59 GMT
69-
NEL:
70-
- '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}'
71-
Report-To:
72-
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=3Xv5m090Pat8QakUzIXQk1EEjRKchZCXuvBMZHTDitdkA%2BBVYDAHMgvLOSrdxwQFn5P5QoBD3jfzUWE%2FKgTJNJ5tuz1iL9RceeXx3kEbWGk%2Bwhjm0ex5rSI9fVHBVui4Puqt1ua4%2B2uEy72jkzAV1XdCKA%3D%3D"}],"group":"cf-nel","max_age":604800}'
7363
Server:
7464
- cloudflare
75-
Transfer-Encoding:
76-
- chunked
77-
alt-svc:
78-
- h3=":443"; ma=86400
79-
cf-cache-status:
80-
- DYNAMIC
81-
pragma:
82-
- no-cache
8365
status:
8466
code: 200
8567
message: OK
@@ -95,7 +77,307 @@ interactions:
9577
Connection:
9678
- keep-alive
9779
Cookie:
98-
- _cfuvid=SANITIZED
80+
- SANITIZED
81+
User-Agent:
82+
- GCM-iOS-5.7.2.1
83+
method: GET
84+
uri: https://connectapi.garmin.com/weight-service/weight/dateRange?startDate=2023-07-01&endDate=2023-07-01
85+
response:
86+
body:
87+
string: '{"startDate": "2023-07-01", "endDate": "2023-07-01", "dateWeightList":
88+
[], "totalAverage": {"from": 1688169600000, "until": 1688255999999, "weight":
89+
null, "bmi": null, "bodyFat": null, "bodyWater": null, "boneMass": null, "muscleMass":
90+
null, "physiqueRating": null, "visceralFat": null, "metabolicAge": null}}'
91+
headers:
92+
Cache-Control:
93+
- no-cache, no-store, private
94+
Connection:
95+
- keep-alive
96+
Content-Type:
97+
- application/json
98+
Server:
99+
- cloudflare
100+
status:
101+
code: 200
102+
message: OK
103+
- request:
104+
body: mfa_token=MFA-43851-i7hWWWBtysft01HGvG7ciXegf07gQEVbRY5N90lCDkPog50CmK-cas
105+
headers:
106+
Accept:
107+
- !!binary |
108+
Ki8q
109+
Accept-Encoding:
110+
- !!binary |
111+
Z3ppcCwgZGVmbGF0ZQ==
112+
Authorization:
113+
- Bearer SANITIZED
114+
Connection:
115+
- !!binary |
116+
a2VlcC1hbGl2ZQ==
117+
Content-Length:
118+
- '74'
119+
Content-Type:
120+
- !!binary |
121+
YXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVk
122+
User-Agent:
123+
- !!binary |
124+
Y29tLmdhcm1pbi5hbmRyb2lkLmFwcHMuY29ubmVjdG1vYmlsZQ==
125+
method: POST
126+
uri: https://connectapi.garmin.com/oauth-service/oauth/exchange/user/2.0
127+
response:
128+
body:
129+
string: '{"scope": "GARMINPAY_WRITE ATP_READ GHS_SAMD INSIGHTS_READ CIQ_APPSTORE_SERVICES_CREATE
130+
COMMUNITY_COURSE_WRITE GCOFFER_WRITE DT_CLIENT_ANALYTICS_WRITE CIQ_APPSTORE_SERVICES_DELETE
131+
OMT_SUBSCRIPTION_READ CONNECT_READ COMMUNITY_COURSE_READ GOLF_API_READ GHS_UPLOAD
132+
DIVE_API_READ CIQ_APPSTORE_SERVICES_READ CIQ_APPSTORE_SERVICES_UPDATE CONNECT_WRITE
133+
CONNECT_MCT_DAILY_LOG_READ DI_OAUTH_2_AUTHORIZATION_CODE_CREATE GARMINPAY_READ
134+
GOLF_API_WRITE INSIGHTS_WRITE PRODUCT_SEARCH_READ OMT_CAMPAIGN_READ GCOFFER_READ
135+
ATP_WRITE", "jti": "SANITIZED", "access_token": "SANITIZED", "token_type":
136+
"bearer", "refresh_token": "SANITIZED", "expires_in": 101500, "refresh_token_expires_in":
137+
2591999}'
138+
headers:
139+
Cache-Control:
140+
- no-cache, no-store, private
141+
Connection:
142+
- keep-alive
143+
Content-Type:
144+
- application/json
145+
Server:
146+
- cloudflare
147+
Set-Cookie:
148+
- _cfuvid=SANITIZED; path=SANITIZED; domain=SANITIZED; HttpOnly; Secure; SameSite=SANITIZED
149+
status:
150+
code: 200
151+
message: OK
152+
- request:
153+
body: null
154+
headers:
155+
Accept:
156+
- '*/*'
157+
Accept-Encoding:
158+
- gzip, deflate
159+
Authorization:
160+
- Bearer SANITIZED
161+
Connection:
162+
- keep-alive
163+
Cookie:
164+
- SANITIZED
165+
User-Agent:
166+
- GCM-iOS-5.7.2.1
167+
method: GET
168+
uri: https://connectapi.garmin.com/userprofile-service/userprofile/user-settings
169+
response:
170+
body:
171+
string: '{"id": 82413233, "userData": {"gender": "MALE", "weight": 87160.0,
172+
"height": 184.0, "timeFormat": "time_twenty_four_hr", "birthDate": "1966-09-15",
173+
"measurementSystem": "metric", "activityLevel": 4, "handedness": "RIGHT",
174+
"powerFormat": {"formatId": 30, "formatKey": "watt", "minFraction": 0, "maxFraction":
175+
0, "groupingUsed": true, "displayFormat": null}, "heartRateFormat": {"formatId":
176+
21, "formatKey": "bpm", "minFraction": 0, "maxFraction": 0, "groupingUsed":
177+
false, "displayFormat": null}, "firstDayOfWeek": {"dayId": 3, "dayName": "monday",
178+
"sortOrder": 3, "isPossibleFirstDay": true}, "vo2MaxRunning": 41.0, "vo2MaxCycling":
179+
null, "lactateThresholdSpeed": null, "lactateThresholdHeartRate": null, "diveNumber":
180+
null, "intensityMinutesCalcMethod": "AUTO", "moderateIntensityMinutesHrZone":
181+
3, "vigorousIntensityMinutesHrZone": 4, "hydrationMeasurementUnit": "milliliter",
182+
"hydrationContainers": [], "hydrationAutoGoalEnabled": true, "firstbeatMaxStressScore":
183+
null, "firstbeatCyclingLtTimestamp": null, "firstbeatRunningLtTimestamp":
184+
null, "thresholdHeartRateAutoDetected": null, "ftpAutoDetected": null, "trainingStatusPausedDate":
185+
null, "weatherLocation": {"useFixedLocation": null, "latitude": null, "longitude":
186+
null, "locationName": null, "isoCountryCode": null, "postalCode": null}, "golfDistanceUnit":
187+
null, "golfElevationUnit": null, "golfSpeedUnit": null, "externalBottomTime":
188+
null, "availableTrainingDays": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY",
189+
"FRIDAY", "SATURDAY", "SUNDAY"], "preferredLongTrainingDays": ["SATURDAY",
190+
"SUNDAY"], "virtualCaddieDataSource": null, "numberDivesAutomatically": null},
191+
"userSleep": {"sleepTime": 81000, "defaultSleepTime": false, "wakeTime": 23400,
192+
"defaultWakeTime": false}, "connectDate": null, "sourceType": null, "userSleepWindows":
193+
[{"sleepWindowFrequency": "SUNDAY", "startSleepTimeSecondsFromMidnight": 81000,
194+
"endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency": "MONDAY",
195+
"startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
196+
23400}, {"sleepWindowFrequency": "TUESDAY", "startSleepTimeSecondsFromMidnight":
197+
81000, "endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency":
198+
"WEDNESDAY", "startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
199+
23400}, {"sleepWindowFrequency": "THURSDAY", "startSleepTimeSecondsFromMidnight":
200+
81000, "endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency":
201+
"FRIDAY", "startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
202+
23400}, {"sleepWindowFrequency": "SATURDAY", "startSleepTimeSecondsFromMidnight":
203+
81000, "endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency":
204+
"DAILY", "startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
205+
23400}]}'
206+
headers:
207+
Cache-Control:
208+
- no-cache, no-store, private
209+
Connection:
210+
- keep-alive
211+
Content-Type:
212+
- application/json
213+
Server:
214+
- cloudflare
215+
status:
216+
code: 200
217+
message: OK
218+
- request:
219+
body: null
220+
headers:
221+
Accept:
222+
- '*/*'
223+
Accept-Encoding:
224+
- gzip, deflate
225+
Authorization:
226+
- Bearer SANITIZED
227+
Connection:
228+
- keep-alive
229+
Cookie:
230+
- SANITIZED
231+
User-Agent:
232+
- GCM-iOS-5.7.2.1
233+
method: GET
234+
uri: https://connectapi.garmin.com/weight-service/weight/dateRange?startDate=2023-07-01&endDate=2023-07-01
235+
response:
236+
body:
237+
string: '{"startDate": "2023-07-01", "endDate": "2023-07-01", "dateWeightList":
238+
[], "totalAverage": {"from": 1688169600000, "until": 1688255999999, "weight":
239+
null, "bmi": null, "bodyFat": null, "bodyWater": null, "boneMass": null, "muscleMass":
240+
null, "physiqueRating": null, "visceralFat": null, "metabolicAge": null}}'
241+
headers:
242+
Cache-Control:
243+
- no-cache, no-store, private
244+
Connection:
245+
- keep-alive
246+
Content-Type:
247+
- application/json
248+
Server:
249+
- cloudflare
250+
status:
251+
code: 200
252+
message: OK
253+
- request:
254+
body: mfa_token=MFA-43851-i7hWWWBtysft01HGvG7ciXegf07gQEVbRY5N90lCDkPog50CmK-cas
255+
headers:
256+
Accept:
257+
- !!binary |
258+
Ki8q
259+
Accept-Encoding:
260+
- !!binary |
261+
Z3ppcCwgZGVmbGF0ZQ==
262+
Authorization:
263+
- Bearer SANITIZED
264+
Connection:
265+
- !!binary |
266+
a2VlcC1hbGl2ZQ==
267+
Content-Length:
268+
- '74'
269+
Content-Type:
270+
- !!binary |
271+
YXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVk
272+
User-Agent:
273+
- !!binary |
274+
Y29tLmdhcm1pbi5hbmRyb2lkLmFwcHMuY29ubmVjdG1vYmlsZQ==
275+
method: POST
276+
uri: https://connectapi.garmin.com/oauth-service/oauth/exchange/user/2.0
277+
response:
278+
body:
279+
string: '{"scope": "GARMINPAY_WRITE ATP_READ GHS_SAMD INSIGHTS_READ CIQ_APPSTORE_SERVICES_CREATE
280+
COMMUNITY_COURSE_WRITE GCOFFER_WRITE DT_CLIENT_ANALYTICS_WRITE CIQ_APPSTORE_SERVICES_DELETE
281+
OMT_SUBSCRIPTION_READ CONNECT_READ COMMUNITY_COURSE_READ GOLF_API_READ GHS_UPLOAD
282+
DIVE_API_READ CIQ_APPSTORE_SERVICES_READ CIQ_APPSTORE_SERVICES_UPDATE CONNECT_WRITE
283+
CONNECT_MCT_DAILY_LOG_READ DI_OAUTH_2_AUTHORIZATION_CODE_CREATE GARMINPAY_READ
284+
GOLF_API_WRITE INSIGHTS_WRITE PRODUCT_SEARCH_READ OMT_CAMPAIGN_READ GCOFFER_READ
285+
ATP_WRITE", "jti": "SANITIZED", "access_token": "SANITIZED", "token_type":
286+
"bearer", "refresh_token": "SANITIZED", "expires_in": 83699, "refresh_token_expires_in":
287+
2591999}'
288+
headers:
289+
Cache-Control:
290+
- no-cache, no-store, private
291+
Connection:
292+
- keep-alive
293+
Content-Type:
294+
- application/json
295+
Server:
296+
- cloudflare
297+
Set-Cookie:
298+
- _cfuvid=SANITIZED; path=SANITIZED; domain=SANITIZED; HttpOnly; Secure; SameSite=SANITIZED
299+
status:
300+
code: 200
301+
message: OK
302+
- request:
303+
body: null
304+
headers:
305+
Accept:
306+
- '*/*'
307+
Accept-Encoding:
308+
- gzip, deflate
309+
Authorization:
310+
- Bearer SANITIZED
311+
Connection:
312+
- keep-alive
313+
Cookie:
314+
- SANITIZED
315+
User-Agent:
316+
- GCM-iOS-5.7.2.1
317+
method: GET
318+
uri: https://connectapi.garmin.com/userprofile-service/userprofile/user-settings
319+
response:
320+
body:
321+
string: '{"id": 82413233, "userData": {"gender": "MALE", "weight": 87160.0,
322+
"height": 184.0, "timeFormat": "time_twenty_four_hr", "birthDate": "1966-09-15",
323+
"measurementSystem": "metric", "activityLevel": 4, "handedness": "RIGHT",
324+
"powerFormat": {"formatId": 30, "formatKey": "watt", "minFraction": 0, "maxFraction":
325+
0, "groupingUsed": true, "displayFormat": null}, "heartRateFormat": {"formatId":
326+
21, "formatKey": "bpm", "minFraction": 0, "maxFraction": 0, "groupingUsed":
327+
false, "displayFormat": null}, "firstDayOfWeek": {"dayId": 3, "dayName": "monday",
328+
"sortOrder": 3, "isPossibleFirstDay": true}, "vo2MaxRunning": 41.0, "vo2MaxCycling":
329+
null, "lactateThresholdSpeed": null, "lactateThresholdHeartRate": null, "diveNumber":
330+
null, "intensityMinutesCalcMethod": "AUTO", "moderateIntensityMinutesHrZone":
331+
3, "vigorousIntensityMinutesHrZone": 4, "hydrationMeasurementUnit": "milliliter",
332+
"hydrationContainers": [], "hydrationAutoGoalEnabled": true, "firstbeatMaxStressScore":
333+
null, "firstbeatCyclingLtTimestamp": null, "firstbeatRunningLtTimestamp":
334+
null, "thresholdHeartRateAutoDetected": null, "ftpAutoDetected": null, "trainingStatusPausedDate":
335+
null, "weatherLocation": {"useFixedLocation": null, "latitude": null, "longitude":
336+
null, "locationName": null, "isoCountryCode": null, "postalCode": null}, "golfDistanceUnit":
337+
null, "golfElevationUnit": null, "golfSpeedUnit": null, "externalBottomTime":
338+
null, "availableTrainingDays": ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY",
339+
"FRIDAY", "SATURDAY", "SUNDAY"], "preferredLongTrainingDays": ["SATURDAY",
340+
"SUNDAY"], "virtualCaddieDataSource": null, "numberDivesAutomatically": null},
341+
"userSleep": {"sleepTime": 81000, "defaultSleepTime": false, "wakeTime": 23400,
342+
"defaultWakeTime": false}, "connectDate": null, "sourceType": null, "userSleepWindows":
343+
[{"sleepWindowFrequency": "SUNDAY", "startSleepTimeSecondsFromMidnight": 81000,
344+
"endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency": "MONDAY",
345+
"startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
346+
23400}, {"sleepWindowFrequency": "TUESDAY", "startSleepTimeSecondsFromMidnight":
347+
81000, "endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency":
348+
"WEDNESDAY", "startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
349+
23400}, {"sleepWindowFrequency": "THURSDAY", "startSleepTimeSecondsFromMidnight":
350+
81000, "endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency":
351+
"FRIDAY", "startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
352+
23400}, {"sleepWindowFrequency": "SATURDAY", "startSleepTimeSecondsFromMidnight":
353+
81000, "endSleepTimeSecondsFromMidnight": 23400}, {"sleepWindowFrequency":
354+
"DAILY", "startSleepTimeSecondsFromMidnight": 81000, "endSleepTimeSecondsFromMidnight":
355+
23400}]}'
356+
headers:
357+
Cache-Control:
358+
- no-cache, no-store, private
359+
Connection:
360+
- keep-alive
361+
Content-Type:
362+
- application/json
363+
Server:
364+
- cloudflare
365+
status:
366+
code: 200
367+
message: OK
368+
- request:
369+
body: null
370+
headers:
371+
Accept:
372+
- '*/*'
373+
Accept-Encoding:
374+
- gzip, deflate
375+
Authorization:
376+
- Bearer SANITIZED
377+
Connection:
378+
- keep-alive
379+
Cookie:
380+
- SANITIZED
99381
User-Agent:
100382
- GCM-iOS-5.7.2.1
101383
method: GET
@@ -107,32 +389,14 @@ interactions:
107389
null, "bmi": null, "bodyFat": null, "bodyWater": null, "boneMass": null, "muscleMass":
108390
null, "physiqueRating": null, "visceralFat": null, "metabolicAge": null}}'
109391
headers:
110-
CF-RAY:
111-
- 97830507bdb10a4b-AMS
112392
Cache-Control:
113393
- no-cache, no-store, private
114394
Connection:
115395
- keep-alive
116-
Content-Encoding:
117-
- gzip
118396
Content-Type:
119397
- application/json
120-
Date:
121-
- Mon, 01 Sep 2025 07:22:59 GMT
122-
NEL:
123-
- '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}'
124-
Report-To:
125-
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=oXsUOgeuhKMJvlbdfkD1dPAMWUa7Hp2tQp%2BRo%2B16IpENF1gm4oDWjGBMzCKkfucoVKz49PRFt7bId6TojbSsJUS4e7UgLGDZx%2BnTKyGy3T1fIxeMq7hHSjsA4LYgyY%2B1aR6K8EVS6bszSaYMHWOqiLGmoA%3D%3D"}],"group":"cf-nel","max_age":604800}'
126398
Server:
127399
- cloudflare
128-
Transfer-Encoding:
129-
- chunked
130-
alt-svc:
131-
- h3=":443"; ma=86400
132-
cf-cache-status:
133-
- DYNAMIC
134-
pragma:
135-
- no-cache
136400
status:
137401
code: 200
138402
message: OK

0 commit comments

Comments
 (0)