Skip to content

docs: copy-edit docstrings and comments for clarity and accuracy#316

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:docs/docstring-copyedit
Jun 1, 2026
Merged

docs: copy-edit docstrings and comments for clarity and accuracy#316
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:docs/docstring-copyedit

Conversation

@thodson-usgs
Copy link
Copy Markdown
Collaborator

@thodson-usgs thodson-usgs commented Jun 1, 2026

What

A copy-edit and accuracy review pass over the package's docstrings and inline
comments
— spelling, grammar, clarity, and (most importantly) making the prose
match what the code actually does. Docstrings/comments only; no executable
code, signatures, or doctest example code changed.

Notable accuracy fixes (docs that disagreed with the code)

  • waterdata/api.get_monitoring_locations — three params documented as
    float are actually string or iterable of strings.
  • nwis.query_waterservices — a duplicated ssl_check block; bBox was
    described as a "7-digit HUC" (it's a bounding box).
  • waterdata/utils._switch_properties_id — docstring described a dict
    (copy-pasted from _switch_arg_id); the function takes a list[str] | None.
    Also refreshed _get_resp_data / _get_args notes for the now-always-
    materialized id column and numeric-param listifying.
  • nwis — getter Returns referenced a nonexistent utils.Metadata;
    corrected to nwis.NWIS_Metadata. Removed a spurious (df, metadata) entry
    from _read_json (it returns a DataFrame).
  • RST/numpydoc"Return""Returns", ".. note:"".. note::".

Additions where docs were silent

  • Deprecation note on the nadp module docstring.
  • Raises sections on utils.query and streamstats.get_watershed; the
    format param + dual return type on get_watershed.
  • Params missing from get_channel's docstring (bbox, last_modified, limit).
  • Dropped bogus Returns blocks from __init__ methods (they return None).

Spelling/grammar

"Times series"→"Time series", "datetme"→"datetime", "conatining",
"indeces"→"indices", "ESPSG"→"EPSG", "NDAP"→"NADP", plus a/an and spacing.

Noticed but left for maintainer judgment (out of scope for a copy-edit)

  • get_time_series_metadata's properties option list looks copy-pasted from
    get_daily and is likely stale — couldn't verify the correct set.
  • get_stats_por / get_stats_date_range have no Returns section.
  • A malformed URL in an nwis.get_info runtime warnings.warn(...):
    waterdata.usgs.gov.nwis/qwdata (should be /nwis/) — in executable code, so
    left for a separate fix.
  • Older bbox docstrings still use R-style c(xmin, ymin, ...) notation.

Verification

ruff check + ruff format --check clean; package imports clean; docs-only so
no runtime/test impact. Scope: source-code docstrings/comments only (the docs/
RST and notebooks were not part of this pass).

🤖 Generated with Claude Code


Update — follow-up commits

Second copy-edit pass caught more misses: 9 Returns cross-references to a
nonexistent utils.Metadata in wqp.py -> wqp.WQP_Metadata;
query_waterdata/query_waterservices examples that listed services the
functions reject; wrong id/empty-frame behavior notes in
_handle_stats_nesting / _combine_chunk_frames; another bogus __init__
Returns; a nadp param-order mismatch; streamstats branding.

Resolved three of the flagged items (incl. two small code fixes):

  • Removed the non-functional time parameter from get_monitoring_locations
    the collection has no time property (verified via its OGC queryables), so
    time=... only ever produced an opaque 400 InvalidQuery. Removal yields a
    clear client-side TypeError instead. Verified against the live API.
  • Fixed a malformed URL in the nwis seriesCatalogOutput deprecation
    warning (usgs.gov.nwis/qwdata -> usgs.gov/nwis/qwdata).
  • De-R-ified the bbox docstrings (c(xmin,ymin,xmax,ymax) -> [xmin, ymin, xmax, ymax]).

This PR is now mostly docstrings/comments plus those two small, verified code
fixes. ruff clean; 471 tests pass.

Still open for maintainer judgment

  • get_time_series_metadata's properties option list looks copy-pasted from
    get_daily and is likely stale (needs the API schema to correct).
  • get_stats_por / get_stats_date_range lack Returns sections.
  • Sibling site/metadata getters may share the time-param copy-paste; only
    get_monitoring_locations was verified here.

@thodson-usgs thodson-usgs force-pushed the docs/docstring-copyedit branch from 9b9c05f to 932db26 Compare June 1, 2026 18:16
@thodson-usgs thodson-usgs marked this pull request as ready for review June 1, 2026 18:40
A review pass over the package's docstrings and inline comments for spelling,
grammar, clarity, and accuracy against the implementation.

Spelling & grammar:
- Typos ("Times series" -> "Time series", "datetme", "conatining", "indeces"
  -> "indices", "ESPSG" -> "EPSG", "NDAP" -> "NADP") plus articles,
  subject-verb agreement, duplicated words, and punctuation. codespell-clean
  ("gage" is the intentional USGS spelling).

R-language cruft -> Python:
- bbox `c(xmin,ymin,xmax,ymax)` -> `[xmin, ymin, xmax, ymax]`; "(numeric)
  vector"/"a vector of requested columns" -> list wording; `limit : numeric`
  -> `int`; `thresholds : numeric` -> `number`.

Accuracy (docs that disagreed with the code):
- Broken `Returns` cross-references to a nonexistent
  `dataretrieval.utils.Metadata` -> the real classes (`nwis.NWIS_Metadata`,
  `wqp.WQP_Metadata`, `utils.BaseMetadata`).
- get_monitoring_locations: three params typed `float` -> string/iterable.
- nwis.query_waterdata / query_waterservices: `service` examples listed values
  the functions reject -> the accepted sets; removed a duplicated `ssl_check`
  block and a `bBox` documented as a HUC.
- waterdata/utils: _switch_properties_id docstring described a dict (copied from
  _switch_arg_id); _handle_stats_nesting / _combine_chunk_frames notes
  corrected to match the code.
- get_time_series_metadata: replaced the stale `properties` list (copied from
  get_daily) with the collection's real queryables.
- Added missing pieces: `nadp` module deprecation note; `Raises` on
  `utils.query` and `streamstats.get_watershed` (plus its `format` param and
  dual return type); `get_channel` params; `get_stats_por` /
  `get_stats_date_range` `Returns` sections.
- Dropped bogus `Returns` blocks from `__init__` methods (they return None).

Code fixes surfaced by the review:
- Removed the non-functional `time` parameter from `get_monitoring_locations`
  and `get_time_series_metadata`. Their OGC collections have no `time`
  queryable (verified via the collections' queryables and a live 400), so
  `time=...` only produced an opaque server error; with no `**kwargs`, removal
  now yields a clear `TypeError`. The observation getters' `time` is valid and
  untouched.
- Fixed a malformed URL in the nwis seriesCatalogOutput deprecation warning
  (`waterdata.usgs.gov.nwis/qwdata` -> `waterdata.usgs.gov/nwis/qwdata`).

ruff check + ruff format clean; mypy --strict clean; tests pass; live-API
behavior verified.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thodson-usgs thodson-usgs force-pushed the docs/docstring-copyedit branch from 932db26 to fb5a79a Compare June 1, 2026 18:43
@thodson-usgs thodson-usgs merged commit b06fbdd into DOI-USGS:main Jun 1, 2026
9 checks passed
@thodson-usgs thodson-usgs deleted the docs/docstring-copyedit branch June 1, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant