Skip to content

Commit db2e4d4

Browse files
StuMasonclaude
andcommitted
fix: Require polar-flow-api>=1.4.0, remove workarounds
- Bump dependency to >=1.4.0 (with biosensing support) - Remove hasattr checks and type ignores - Remove pytest.importorskip from tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0eb9e0e commit db2e4d4

File tree

6 files changed

+8
-34
lines changed

6 files changed

+8
-34
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies = [
2020
"psycopg[binary]>=3.2.3", # PostgreSQL sync driver (for Alembic migrations)
2121

2222
# Polar Flow SDK
23-
"polar-flow-api>=1.3.0",
23+
"polar-flow-api>=1.4.0",
2424

2525
# Data processing
2626
"polars>=1.17.1",

src/polar_flow_server/services/sync.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,8 @@ async def _sync_spo2(
490490
"""
491491
self.logger.debug("Syncing SpO2 data", user_id=user_id)
492492

493-
# Biosensing requires polar-flow >= 1.4.0
494-
if not hasattr(client, "biosensing"):
495-
self.logger.debug("SpO2 sync skipped - SDK version doesn't support biosensing")
496-
return 0
497-
498493
try:
499-
spo2_data = await client.biosensing.get_spo2() # type: ignore[attr-defined]
494+
spo2_data = await client.biosensing.get_spo2()
500495
except Exception as e:
501496
self.logger.debug("SpO2 sync skipped", error=str(e))
502497
return 0
@@ -528,13 +523,8 @@ async def _sync_ecg(
528523
"""
529524
self.logger.debug("Syncing ECG data", user_id=user_id)
530525

531-
# Biosensing requires polar-flow >= 1.4.0
532-
if not hasattr(client, "biosensing"):
533-
self.logger.debug("ECG sync skipped - SDK version doesn't support biosensing")
534-
return 0
535-
536526
try:
537-
ecg_data = await client.biosensing.get_ecg() # type: ignore[attr-defined]
527+
ecg_data = await client.biosensing.get_ecg()
538528
except Exception as e:
539529
self.logger.debug("ECG sync skipped", error=str(e))
540530
return 0
@@ -566,13 +556,8 @@ async def _sync_body_temperature(
566556
"""
567557
self.logger.debug("Syncing body temperature", user_id=user_id)
568558

569-
# Biosensing requires polar-flow >= 1.4.0
570-
if not hasattr(client, "biosensing"):
571-
self.logger.debug("Body temp sync skipped - SDK version doesn't support biosensing")
572-
return 0
573-
574559
try:
575-
temp_data = await client.biosensing.get_body_temperature() # type: ignore[attr-defined]
560+
temp_data = await client.biosensing.get_body_temperature()
576561
except Exception as e:
577562
self.logger.debug("Body temperature sync skipped", error=str(e))
578563
return 0
@@ -604,13 +589,8 @@ async def _sync_skin_temperature(
604589
"""
605590
self.logger.debug("Syncing skin temperature", user_id=user_id)
606591

607-
# Biosensing requires polar-flow >= 1.4.0
608-
if not hasattr(client, "biosensing"):
609-
self.logger.debug("Skin temp sync skipped - SDK version doesn't support biosensing")
610-
return 0
611-
612592
try:
613-
temp_data = await client.biosensing.get_skin_temperature() # type: ignore[attr-defined]
593+
temp_data = await client.biosensing.get_skin_temperature()
614594
except Exception as e:
615595
self.logger.debug("Skin temperature sync skipped", error=str(e))
616596
return 0

src/polar_flow_server/transformers/ecg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import TYPE_CHECKING, Any
1111

1212
if TYPE_CHECKING:
13-
from polar_flow.models.biosensing import ECGResult # type: ignore[import-not-found]
13+
from polar_flow.models.biosensing import ECGResult
1414

1515

1616
class ECGTransformer:

src/polar_flow_server/transformers/spo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import TYPE_CHECKING, Any
1010

1111
if TYPE_CHECKING:
12-
from polar_flow.models.biosensing import SpO2Result # type: ignore[import-not-found]
12+
from polar_flow.models.biosensing import SpO2Result
1313

1414

1515
class SpO2Transformer:

src/polar_flow_server/transformers/temperature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import TYPE_CHECKING, Any
1111

1212
if TYPE_CHECKING:
13-
from polar_flow.models.biosensing import BodyTemperaturePeriod, SkinTemperature # type: ignore[import-not-found]
13+
from polar_flow.models.biosensing import BodyTemperaturePeriod, SkinTemperature
1414

1515

1616
class BodyTemperatureTransformer:

tests/test_biosensing_transformers.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
"""Tests for Biosensing transformers.
22
33
These tests verify that SDK models are correctly transformed to database dicts.
4-
Requires polar-flow-api >= 1.4.0 which includes biosensing models.
54
"""
65

76
import json
87
from datetime import UTC, datetime
98

10-
import pytest
11-
12-
# Skip all tests in this module if biosensing module not available
13-
pytest.importorskip("polar_flow.models.biosensing")
14-
159

1610
class TestSpO2Transformer:
1711
"""Tests for SpO2Transformer."""

0 commit comments

Comments
 (0)