Skip to content

Commit 63fce1b

Browse files
thodson-usgsclaude
andcommitted
fix(nwis): stop emitting a DeprecationWarning at import time
nwis.py warned at module top-level, and dataretrieval/__init__ star-imports nwis, so `import dataretrieval` emitted a DeprecationWarning for every consumer (including waterdata-only users) and failed to import entirely under `-W error::DeprecationWarning`, which is common in CI. Deprecation is already signaled where it matters: the @_deprecated decorator emits a per-function warning on every nwis call. Removed the redundant module-level warning; the per-function warnings are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ee653e5 commit 63fce1b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

dataretrieval/nwis.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
except ImportError:
2525
gpd = None
2626

27-
# Issue deprecation warning upon import
28-
warnings.warn(
29-
"The 'nwis' services are deprecated and being decommissioned. "
30-
"Please use the 'waterdata' module to access the new services.",
31-
DeprecationWarning,
32-
stacklevel=2,
33-
)
27+
# NOTE: deprecation is signaled per-function via the @_deprecated decorator
28+
# (see _warn_deprecated below), NOT at import time. A module-level
29+
# warnings.warn(DeprecationWarning) here fired on every `import dataretrieval`
30+
# (because dataretrieval/__init__ star-imports nwis), warning even
31+
# waterdata-only users and breaking any project that runs under
32+
# `-W error::DeprecationWarning`. The per-function warnings cover real usage.
3433

3534
WATERDATA_BASE_URL = "https://nwis.waterdata.usgs.gov/"
3635
WATERDATA_URL = WATERDATA_BASE_URL + "nwis/"

0 commit comments

Comments
 (0)