Commit ca5926c
refactor(api)!: expose service submodules, not a flattened top-level namespace
`dataretrieval/__init__.py` star-imported every service module, flattening all
their public functions into the top-level package namespace. That:
- leaked one large, ambiguous namespace (`dataretrieval.get_dv`,
`dataretrieval.get_results`, ...), and
- silently collided on names defined by more than one service: `get_ratings`
(nwis vs waterdata) and `what_sites` (nwis vs wqp) resolved to whichever
module was star-imported last; the other was shadowed.
Replace the star-imports with submodule imports, so callers reach each service
through its own module -- the pattern the README, the docs (per-module
autodoc), and the tests already use:
from dataretrieval import waterdata
df, meta = waterdata.get_ratings(...)
from dataretrieval import nwis
df, meta = nwis.get_ratings(...)
`dataretrieval.<name>` and `from dataretrieval import <name>` still work for
every service module, and `__version__` is unchanged. `nldi` remains
import-on-demand (it pulls in the optional geopandas dependency). The collision
is now impossible -- each `get_ratings` / `what_sites` lives only under its
module.
BREAKING CHANGE: top-level function access (e.g. `dataretrieval.get_dv`) is
removed; use the service module (`dataretrieval.nwis.get_dv`). Exception and
helper classes likewise move under their modules (e.g.
`dataretrieval.utils.NoSitesError`).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1adf174 commit ca5926c
1 file changed
Lines changed: 39 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
1 | 20 | | |
2 | 21 | | |
3 | 22 | | |
4 | 23 | | |
5 | 24 | | |
6 | 25 | | |
7 | 26 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments