Skip to content

Commit f81d71a

Browse files
thodson-usgsclaude
andcommitted
chore(pre-commit): switch to ruff-only + nbstripout, apply across tree
The previous pre-commit stack (flake8 + isort + pyupgrade + black + black-jupyter + blackdoc + prettier + double-quote-string-fixer) is fully covered by ruff (lint + format + import sorting + pyupgrade rules + double-quote style). Slimming down to: - ``pre-commit-hooks`` (bumped v4.4.0 → v5.0.0): trailing-whitespace / end-of-file-fixer / mixed-line-ending and the JSON/YAML/docstring / debug-statement checks. Ruff's ``W`` rules (already in ``pyproject.toml`` ``[tool.ruff.lint] select``) catch W291/W292/W293 for Python files; the broader hook covers non-Python text. - ``ruff-pre-commit``: ``ruff --fix`` + ``ruff-format``. - ``nbstripout``: strip cell outputs + ``execution_count`` from notebooks on commit, so the diff is the source rather than a rendered run. The bulk of this commit is the drive-by cleanup the new hooks produce the first time they run across the existing tree: - nbstripout strips outputs from every checked-in notebook (15 notebooks in ``demos/`` + ``demos/hydroshare/``). Demos still execute fine; the source diffs are now the actual content. - trailing-whitespace / end-of-file-fixer / mixed-line-ending normalize text files that pre-dated the hooks: ``.gitignore``, ``README.md``, ``py.typed``, the Dockerfile, the ``*.nblink`` and ``*.rst`` doc sources, and the ``*.txt`` / ``*.json`` test fixtures under ``tests/data/``. No behavior change; offline test suite green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 399f44a commit f81d71a

56 files changed

Lines changed: 2103 additions & 1780 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ ENV/
111111
.mypy_cache/
112112

113113
# macOS
114-
*.DS_Store
114+
*.DS_Store

.pre-commit-config.yaml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,33 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.4.0
7+
rev: v5.0.0
88
hooks:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
1111
- id: check-docstring-first
1212
- id: check-json
1313
- id: check-yaml
14-
- id: double-quote-string-fixer
1514
- id: debug-statements
1615
- id: mixed-line-ending
1716

18-
- repo: https://github.com/asottile/pyupgrade
19-
rev: v3.3.1
17+
# Single source of truth for lint + format + import sorting + pyupgrade
18+
# rules. Replaces the previous flake8 + isort + pyupgrade + black +
19+
# black-jupyter + blackdoc + prettier stack; ruff covers all of it (and
20+
# ``ruff format`` enforces the double-quote style that
21+
# ``double-quote-string-fixer`` used to).
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: v0.7.4
2024
hooks:
21-
- id: pyupgrade
22-
args:
23-
- '--py38-plus'
25+
- id: ruff
26+
args: [--fix]
27+
- id: ruff-format
2428

25-
- repo: https://github.com/psf/black
26-
rev: 23.3.0
29+
# Strip cell outputs + execution_count from notebooks before commit so
30+
# the diff is the source, not the rendered run. Demos can still be
31+
# executed (and inspected) locally; clean commits keep PRs reviewable
32+
# and avoid quota/timestamp churn on every re-run.
33+
- repo: https://github.com/kynan/nbstripout
34+
rev: 0.8.1
2735
hooks:
28-
- id: black
29-
- id: black-jupyter
30-
31-
- repo: https://github.com/keewis/blackdoc
32-
rev: v0.3.8
33-
hooks:
34-
- id: blackdoc
35-
36-
- repo: https://github.com/PyCQA/flake8
37-
rev: 6.0.0
38-
hooks:
39-
- id: flake8
40-
41-
- repo: https://github.com/PyCQA/isort
42-
rev: 5.12.0
43-
hooks:
44-
- id: isort
45-
46-
- repo: https://github.com/pre-commit/mirrors-prettier
47-
rev: v3.0.0-alpha.6
48-
hooks:
49-
- id: prettier
36+
- id: nbstripout

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ from dataretrieval import waterdata
5959

6060
# Get daily streamflow data (returns DataFrame and metadata)
6161
df, metadata = waterdata.get_daily(
62-
monitoring_location_id='USGS-01646500',
62+
monitoring_location_id='USGS-01646500',
6363
parameter_code='00060', # Discharge
6464
time='2024-10-01/2025-09-30'
6565
)
@@ -98,7 +98,7 @@ windows to avoid timeouts and other issues:
9898
```python
9999
# Get continuous data for a single monitoring location and water year
100100
df, metadata = waterdata.get_continuous(
101-
monitoring_location_id='USGS-01646500',
101+
monitoring_location_id='USGS-01646500',
102102
parameter_code='00065', # Gage height
103103
time='2024-10-01/2025-09-30'
104104
)
@@ -152,7 +152,7 @@ from dataretrieval import nldi
152152
# Get watershed basin for a stream reach
153153
basin = nldi.get_basin(
154154
feature_source='comid',
155-
feature_id='13293474' # NHD reach identifier
155+
feature_id='13293474' # NHD reach identifier
156156
)
157157

158158
print(f"Basin contains {len(basin)} feature(s)")
@@ -184,7 +184,7 @@ print(f"Found {len(flowlines)} upstream tributaries within 50km")
184184
### Legacy NWIS Services (Deprecated)
185185
- **Daily values (dv)**: Legacy daily statistical data
186186
- **Instantaneous values (iv)**: Legacy continuous data
187-
- **Site info (site)**: Basic site information
187+
- **Site info (site)**: Basic site information
188188
- **Statistics (stat)**: Statistical summaries
189189
- **Discharge peaks (peaks)**: Annual peak discharge events
190190

dataretrieval/py.typed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

demos/USGS_WaterData_ContinuousData_Examples.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "d664492b",
5+
"id": "0",
66
"metadata": {},
77
"source": [
88
"# Continuous Data\n",
@@ -21,7 +21,7 @@
2121
{
2222
"cell_type": "code",
2323
"execution_count": null,
24-
"id": "e7e06e81",
24+
"id": "1",
2525
"metadata": {},
2626
"outputs": [],
2727
"source": [
@@ -34,7 +34,7 @@
3434
},
3535
{
3636
"cell_type": "markdown",
37-
"id": "b0136bd1",
37+
"id": "2",
3838
"metadata": {},
3939
"source": [
4040
"## What continuous data are available?\n",
@@ -46,7 +46,7 @@
4646
{
4747
"cell_type": "code",
4848
"execution_count": null,
49-
"id": "6f8a9d87",
49+
"id": "3",
5050
"metadata": {},
5151
"outputs": [],
5252
"source": [
@@ -60,7 +60,7 @@
6060
},
6161
{
6262
"cell_type": "markdown",
63-
"id": "fdaa8150",
63+
"id": "4",
6464
"metadata": {},
6565
"source": [
6666
"## Large requests are chunked for you\n",
@@ -79,7 +79,7 @@
7979
{
8080
"cell_type": "code",
8181
"execution_count": null,
82-
"id": "6bc05102",
82+
"id": "5",
8383
"metadata": {},
8484
"outputs": [],
8585
"source": [
@@ -93,7 +93,7 @@
9393
},
9494
{
9595
"cell_type": "markdown",
96-
"id": "353ad4ec",
96+
"id": "6",
9797
"metadata": {},
9898
"source": [
9999
"## Resilient pulls: resume after an interruption\n",
@@ -119,7 +119,7 @@
119119
{
120120
"cell_type": "code",
121121
"execution_count": null,
122-
"id": "e2e9ddff",
122+
"id": "7",
123123
"metadata": {},
124124
"outputs": [],
125125
"source": [
@@ -151,7 +151,7 @@
151151
},
152152
{
153153
"cell_type": "markdown",
154-
"id": "397e87b5",
154+
"id": "8",
155155
"metadata": {},
156156
"source": [
157157
"## The 3-year window: the one axis you split yourself\n",
@@ -170,7 +170,7 @@
170170
{
171171
"cell_type": "code",
172172
"execution_count": null,
173-
"id": "bd26d199",
173+
"id": "9",
174174
"metadata": {},
175175
"outputs": [],
176176
"source": [
@@ -191,7 +191,7 @@
191191
},
192192
{
193193
"cell_type": "markdown",
194-
"id": "3bc4f40f",
194+
"id": "10",
195195
"metadata": {},
196196
"source": [
197197
"Then request each window and concatenate. (We use a short two-window span here so\n",
@@ -201,7 +201,7 @@
201201
{
202202
"cell_type": "code",
203203
"execution_count": null,
204-
"id": "01ebb4a0",
204+
"id": "11",
205205
"metadata": {},
206206
"outputs": [],
207207
"source": [
@@ -225,7 +225,7 @@
225225
},
226226
{
227227
"cell_type": "markdown",
228-
"id": "e2487bf4",
228+
"id": "12",
229229
"metadata": {},
230230
"source": [
231231
"Wrap each window's call in the resume pattern above for an unattended,\n",

0 commit comments

Comments
 (0)