Skip to content

Commit 0b76978

Browse files
committed
ci: upgrade Ruff to 0.16.1
Align pre-commit, CI, and the test extra on Ruff 0.16.1 and apply its Markdown code-fence formatting.
1 parent 7980e86 commit 0b76978

5 files changed

Lines changed: 47 additions & 45 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
cache: "pip"
2222
- name: Install ruff
2323
# Keep this version aligned with the ruff-pre-commit revision.
24-
run: pip install ruff==0.15.15
24+
run: pip install ruff==0.16.1
2525
- name: Lint with ruff
2626
run: |
2727
ruff check . --output-format=github

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
- id: debug-statements
2222

2323
- repo: https://github.com/astral-sh/ruff-pre-commit
24-
rev: v0.15.15
24+
rev: v0.16.1
2525
hooks:
2626
- id: ruff-check
2727
args: [--fix]

CONTRIBUTING.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,20 @@ via any automated processes or pipelines.
149149
* Example:
150150

151151
``` python
152+
LIGHT_MESSAGES = {
153+
"English": "There are %(number_of_lights)s lights.",
154+
"Pirate": "Arr! Thar be %(number_of_lights)s lights.",
155+
}
152156

153-
LIGHT_MESSAGES = {
154-
'English': "There are %(number_of_lights)s lights.",
155-
'Pirate': "Arr! Thar be %(number_of_lights)s lights."
156-
}
157157

158-
def lights_message(language, number_of_lights):
159-
"""Return a language-appropriate string reporting the light count."""
160-
return LIGHT_MESSAGES[language] % locals()
158+
def lights_message(language, number_of_lights):
159+
"""Return a language-appropriate string reporting the light count."""
160+
return LIGHT_MESSAGES[language] % locals()
161161

162-
def is_pirate(message):
163-
"""Return True if the given message sounds piratical."""
164-
return re.search(r"(?i)(arr|avast|yohoho)!", message) is not None
162+
163+
def is_pirate(message):
164+
"""Return True if the given message sounds piratical."""
165+
return re.search(r"(?i)(arr|avast|yohoho)!", message) is not None
165166
```
166167

167168
---

README.md

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ and set it as an environment variable:
4747

4848
```python
4949
import os
50+
5051
os.environ["API_USGS_PAT"] = "your_api_key_here"
5152
```
5253

@@ -59,9 +60,9 @@ from dataretrieval import waterdata
5960

6061
# Get daily streamflow data (returns DataFrame and metadata)
6162
df, metadata = waterdata.get_daily(
62-
monitoring_location_id='USGS-01646500',
63-
parameter_code='00060', # Discharge
64-
time='2024-10-01/2025-09-30'
63+
monitoring_location_id="USGS-01646500",
64+
parameter_code="00060", # Discharge
65+
time="2024-10-01/2025-09-30",
6566
)
6667

6768
print(f"Retrieved {len(df)} records")
@@ -72,9 +73,9 @@ Retrieve streamflow at multiple locations from October 1, 2024 to the present:
7273

7374
```python
7475
df, metadata = waterdata.get_daily(
75-
monitoring_location_id=["USGS-13018750","USGS-13013650"],
76-
parameter_code='00060',
77-
time='2024-10-01/..'
76+
monitoring_location_id=["USGS-13018750", "USGS-13013650"],
77+
parameter_code="00060",
78+
time="2024-10-01/..",
7879
)
7980

8081
print(f"Retrieved {len(df)} records")
@@ -85,8 +86,8 @@ stream sites in Maryland:
8586
```python
8687
# Get monitoring location information
8788
df, metadata = waterdata.get_monitoring_locations(
88-
state='Maryland', # full name, postal code ('MD'), or FIPS ('24')
89-
site_type_code='ST' # Stream sites
89+
state="Maryland", # full name, postal code ('MD'), or FIPS ('24')
90+
site_type_code="ST", # Stream sites
9091
)
9192

9293
print(f"Found {len(df)} stream monitoring locations in Maryland")
@@ -98,9 +99,9 @@ windows to avoid timeouts and other issues:
9899
```python
99100
# Get continuous data for a single monitoring location and water year
100101
df, metadata = waterdata.get_continuous(
101-
monitoring_location_id='USGS-01646500',
102-
parameter_code='00065', # Gage height
103-
time='2024-10-01/2025-09-30'
102+
monitoring_location_id="USGS-01646500",
103+
parameter_code="00065", # Gage height
104+
time="2024-10-01/2025-09-30",
104105
)
105106
print(f"Retrieved {len(df)} continuous gage height measurements")
106107
```
@@ -125,10 +126,10 @@ from dataretrieval import waterdata
125126
# enough to span many pages, so it profits from a finer split.
126127
sites, _ = waterdata.get_monitoring_locations(state="Ohio", site_type_code="ST")
127128

128-
with waterdata.parallel_chunks(32): # fan out into 32 sub-requests
129+
with waterdata.parallel_chunks(32): # fan out into 32 sub-requests
129130
df, md = waterdata.get_daily(
130131
monitoring_location_id=sites["monitoring_location_id"],
131-
parameter_code="00060", # discharge
132+
parameter_code="00060", # discharge
132133
time="2004-01-01/2023-12-31",
133134
)
134135
```
@@ -167,6 +168,7 @@ API — enable debug-level
167168

168169
```python
169170
import logging
171+
170172
logging.basicConfig(level=logging.DEBUG)
171173
```
172174

@@ -181,14 +183,14 @@ from dataretrieval import ngwmn
181183

182184
# Find the groundwater monitoring sites in a state
183185
# (state accepts a full name, a postal code like 'WI', or a FIPS code like '55')
184-
sites, metadata = ngwmn.get_sites(state='Wisconsin')
186+
sites, metadata = ngwmn.get_sites(state="Wisconsin")
185187

186188
print(f"Found {len(sites)} NGWMN sites in Wisconsin")
187189

188190
# Pull water levels from the first twenty sites over a time window.
189191
water_levels, metadata = ngwmn.get_water_level(
190-
monitoring_location_id=sites['monitoring_location_id'][:20],
191-
datetime=['2022-01-01', '2024-01-01']
192+
monitoring_location_id=sites["monitoring_location_id"][:20],
193+
datetime=["2022-01-01", "2024-01-01"],
192194
)
193195

194196
print(f"Retrieved {len(water_levels)} water-level observations")
@@ -203,16 +205,15 @@ from dataretrieval import wqp
203205

204206
# Find water quality monitoring sites (returns a DataFrame and metadata)
205207
sites, metadata = wqp.what_sites(
206-
statecode='US:55', # Wisconsin
207-
siteType='Stream'
208+
statecode="US:55", # Wisconsin
209+
siteType="Stream",
208210
)
209211

210212
print(f"Found {len(sites)} stream monitoring sites in Wisconsin")
211213

212214
# Get water quality results
213215
results, metadata = wqp.get_results(
214-
siteid='USGS-05427718',
215-
characteristicName='Temperature, water'
216+
siteid="USGS-05427718", characteristicName="Temperature, water"
216217
)
217218

218219
print(f"Retrieved {len(results)} temperature measurements")
@@ -227,18 +228,18 @@ from dataretrieval import nldi
227228

228229
# Get watershed basin for a stream reach
229230
basin = nldi.get_basin(
230-
feature_source='comid',
231-
feature_id='13293474' # NHD reach identifier
231+
feature_source="comid",
232+
feature_id="13293474", # NHD reach identifier
232233
)
233234

234235
print(f"Basin contains {len(basin)} feature(s)")
235236

236237
# Find upstream flowlines
237238
flowlines = nldi.get_flowlines(
238-
feature_source='comid',
239-
feature_id='13293474',
240-
navigation_mode='UT', # Upstream tributaries
241-
distance=50 # km
239+
feature_source="comid",
240+
feature_id="13293474",
241+
navigation_mode="UT", # Upstream tributaries
242+
distance=50, # km
242243
)
243244

244245
print(f"Found {len(flowlines)} upstream tributaries within 50km")
@@ -255,17 +256,17 @@ from dataretrieval import wateruse
255256
# Monthly public-supply withdrawals for Rhode Island, split into
256257
# groundwater and surface-water sources (returns a DataFrame and metadata).
257258
df, metadata = wateruse.get_wateruse(
258-
model='wu-public-supply-wd',
259-
variable=['pswdtot', 'pswdgw', 'pswdsw'],
260-
state='RI', # name/postal/FIPS; pass a list to fan out over several areas
261-
start_date='2020-01',
262-
time_resolution='monthly',
259+
model="wu-public-supply-wd",
260+
variable=["pswdtot", "pswdgw", "pswdsw"],
261+
state="RI", # name/postal/FIPS; pass a list to fan out over several areas
262+
start_date="2020-01",
263+
time_resolution="monthly",
263264
)
264265

265266
print(f"Retrieved {len(df)} records across {df['huc12_id'].nunique()} watersheds")
266267

267268
# Aggregate the HUC12 grid to a statewide monthly total (million gallons/day)
268-
statewide = df.groupby('year_month')['pswdtot_mgd'].sum()
269+
statewide = df.groupby("year_month")["pswdtot_mgd"].sum()
269270
print(statewide.head())
270271
```
271272

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test = [
5454
"pytest-rerunfailures",
5555
"coverage",
5656
"pytest-httpx",
57-
"ruff==0.15.15",
57+
"ruff==0.16.1",
5858
"dataretrieval[type-check]", # mypy, pinned once in the type-check extra
5959
]
6060
doc = [

0 commit comments

Comments
 (0)