Skip to content

Commit 9e3af72

Browse files
committed
Avoid PowerdB defaults in DWR APIs
- Move DWR warning/violation defaults to class constants - Update DWR checker and ATDMA stats service defaults
1 parent eb2a179 commit 9e3af72

3 files changed

Lines changed: 45 additions & 11 deletions

File tree

src/pypnm/api/routes/docs/if30/us/atdma/chan/stats/service.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
from pypnm.docsis.cable_modem import CableModem
1010
from pypnm.lib.inet import Inet
1111
from pypnm.lib.mac_address import MacAddress
12-
from pypnm.lib.types import BandwidthHz, ChannelId, InetAddressStr, MacAddressStr, PowerdB, PowerdBmV
12+
from pypnm.lib.types import (
13+
BandwidthHz,
14+
ChannelId,
15+
InetAddressStr,
16+
MacAddressStr,
17+
PowerdB,
18+
PowerdBmV,
19+
)
1320
from pypnm.pnm.analysis.us_drw import (
1421
DwrChannelPowerModel,
1522
DwrDynamicWindowRangeChecker,
@@ -27,6 +34,9 @@ class UsScQamChannelService:
2734
cm (CableModem): An instance of the CableModem class used to perform SNMP operations.
2835
"""
2936

37+
DEFAULT_DWR_WARNING_DB: PowerdB = PowerdB(6.0)
38+
DEFAULT_DWR_VIOLATION_DB: PowerdB = PowerdB(12.0)
39+
3040
def __init__(self, mac_address: MacAddressStr,
3141
ip_address: InetAddressStr,
3242
snmp_config: SNMPConfig) -> None:
@@ -43,8 +53,8 @@ def __init__(self, mac_address: MacAddressStr,
4353

4454
async def get_upstream_entries(
4555
self,
46-
dwr_warning_db: PowerdB = PowerdB(6.0),
47-
dwr_violation_db: PowerdB = PowerdB(12.0),
56+
dwr_warning_db: PowerdB = DEFAULT_DWR_WARNING_DB,
57+
dwr_violation_db: PowerdB = DEFAULT_DWR_VIOLATION_DB,
4858
) -> dict[str, object]:
4959
"""
5060
Fetches DOCSIS Upstream SC-QAM channel entries.

src/pypnm/pnm/analysis/us_drw.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,15 @@ class DwrDynamicWindowRangeChecker:
109109
dwr_violation_db: PowerdB
110110

111111
MIN_CHANNELS: ClassVar[Final[int]] = 2
112-
113-
def __init__(self, *, dwr_violation_db: PowerdB = PowerdB(12.0), dwr_warning_db: PowerdB = PowerdB(6.0)) -> None:
112+
DEFAULT_WARNING_DB: ClassVar[Final[PowerdB]] = PowerdB(6.0)
113+
DEFAULT_VIOLATION_DB: ClassVar[Final[PowerdB]] = PowerdB(12.0)
114+
115+
def __init__(
116+
self,
117+
*,
118+
dwr_violation_db: PowerdB = DEFAULT_VIOLATION_DB,
119+
dwr_warning_db: PowerdB = DEFAULT_WARNING_DB,
120+
) -> None:
114121
"""
115122
Initialize a DWR checker with explicit thresholds.
116123

tools/agent-review/2026-01-25-atdma-group-delay-types.review.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Agent Review Bundle Summary
2-
- Goal: Clarify DWR checker documentation and ATDMA stats docs.
3-
- Changes: Update DWR docstring and expand DWR window fields in stats docs.
2+
- Goal: Resolve ruff B008 defaults for DWR thresholds.
3+
- Changes: Move PowerdB defaults into class-level constants.
44
- Files: src/pypnm/pnm/analysis/atdma_group_delay.py; src/pypnm/pnm/analysis/us_drw.py; src/pypnm/pnm/data_type/DocsEqualizerData.py; src/pypnm/docsis/cm_snmp_operation.py; src/pypnm/api/routes/docs/if30/us/atdma/chan/stats/service.py; docs/api/fast-api/single/us/atdma/chan/pre-equalization.md; docs/api/fast-api/single/us/atdma/chan/stats.md; tests/test_docs_equalizer_group_delay.py; tools/release/release.py
55
- Tests: Not run (not requested).
66
- Notes: None.
@@ -308,8 +308,15 @@ class DwrDynamicWindowRangeChecker:
308308
dwr_violation_db: PowerdB
309309

310310
MIN_CHANNELS: ClassVar[Final[int]] = 2
311+
DEFAULT_WARNING_DB: ClassVar[Final[PowerdB]] = PowerdB(6.0)
312+
DEFAULT_VIOLATION_DB: ClassVar[Final[PowerdB]] = PowerdB(12.0)
311313

312-
def __init__(self, *, dwr_violation_db: PowerdB = PowerdB(12.0), dwr_warning_db: PowerdB = PowerdB(6.0)) -> None:
314+
def __init__(
315+
self,
316+
*,
317+
dwr_violation_db: PowerdB = DEFAULT_VIOLATION_DB,
318+
dwr_warning_db: PowerdB = DEFAULT_WARNING_DB,
319+
) -> None:
313320
"""
314321
Initialize a DWR checker with explicit thresholds.
315322

@@ -3276,7 +3283,14 @@ from pypnm.api.routes.common.classes.common_endpoint_classes.schema.base_connect
32763283
from pypnm.docsis.cable_modem import CableModem
32773284
from pypnm.lib.inet import Inet
32783285
from pypnm.lib.mac_address import MacAddress
3279-
from pypnm.lib.types import BandwidthHz, ChannelId, InetAddressStr, MacAddressStr, PowerdB, PowerdBmV
3286+
from pypnm.lib.types import (
3287+
BandwidthHz,
3288+
ChannelId,
3289+
InetAddressStr,
3290+
MacAddressStr,
3291+
PowerdB,
3292+
PowerdBmV,
3293+
)
32803294
from pypnm.pnm.analysis.us_drw import (
32813295
DwrChannelPowerModel,
32823296
DwrDynamicWindowRangeChecker,
@@ -3294,6 +3308,9 @@ class UsScQamChannelService:
32943308
cm (CableModem): An instance of the CableModem class used to perform SNMP operations.
32953309
"""
32963310

3311+
DEFAULT_DWR_WARNING_DB: PowerdB = PowerdB(6.0)
3312+
DEFAULT_DWR_VIOLATION_DB: PowerdB = PowerdB(12.0)
3313+
32973314
def __init__(self, mac_address: MacAddressStr,
32983315
ip_address: InetAddressStr,
32993316
snmp_config: SNMPConfig) -> None:
@@ -3310,8 +3327,8 @@ class UsScQamChannelService:
33103327

33113328
async def get_upstream_entries(
33123329
self,
3313-
dwr_warning_db: PowerdB = PowerdB(6.0),
3314-
dwr_violation_db: PowerdB = PowerdB(12.0),
3330+
dwr_warning_db: PowerdB = DEFAULT_DWR_WARNING_DB,
3331+
dwr_violation_db: PowerdB = DEFAULT_DWR_VIOLATION_DB,
33153332
) -> dict[str, object]:
33163333
"""
33173334
Fetches DOCSIS Upstream SC-QAM channel entries.

0 commit comments

Comments
 (0)