Skip to content

Commit e5d1afd

Browse files
thodson-usgsclaude
andcommitted
Revert get_results dataProfile changes (covered by PR DOI-USGS#250)
The simplify pass added `TypeError(msg, msg)` -> `ValueError(single_msg)` fixes to `get_results`'s two `dataProfile` validators. PR DOI-USGS#250 ("Fix get_results: preserve user-supplied WQX3.0 dataProfile") restructures the same code more thoroughly and addresses the same exception-shape bug as a side effect, so this PR should not duplicate that work. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8c86ebd commit e5d1afd

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

dataretrieval/wqp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ def get_results(
131131
"dataProfile" in kwargs
132132
and kwargs["dataProfile"] not in result_profiles_legacy
133133
):
134-
raise ValueError(
135-
f"dataProfile {kwargs['dataProfile']} is not a legacy profile. "
136-
f"Valid options are {result_profiles_legacy}."
134+
raise TypeError(
135+
f"dataProfile {kwargs['dataProfile']} is not a legacy profile.",
136+
f"Valid options are {result_profiles_legacy}.",
137137
)
138138

139139
url = wqp_url("Result")
@@ -143,9 +143,9 @@ def get_results(
143143
"dataProfile" in kwargs
144144
and kwargs["dataProfile"] not in result_profiles_wqx3
145145
):
146-
raise ValueError(
147-
f"dataProfile {kwargs['dataProfile']} is not a valid WQX3.0 "
148-
f"profile. Valid options are {result_profiles_wqx3}."
146+
raise TypeError(
147+
f"dataProfile {kwargs['dataProfile']} is not a valid WQX3.0"
148+
f"profile. Valid options are {result_profiles_wqx3}.",
149149
)
150150
else:
151151
kwargs["dataProfile"] = "fullPhysChem"

tests/wqp_test.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,3 @@ def test_what_organizations_legacy_false_warns(requests_mock):
243243
what_organizations(
244244
statecode="US:34", characteristicName="Chloride", legacy=False
245245
)
246-
247-
248-
def test_get_results_invalid_legacy_dataprofile_raises_value_error():
249-
"""Invalid legacy dataProfile -> ValueError with single readable message."""
250-
with pytest.raises(ValueError, match="is not a legacy profile"):
251-
get_results(dataProfile="not_a_real_profile")
252-
253-
254-
def test_get_results_invalid_wqx3_dataprofile_raises_value_error():
255-
"""Invalid WQX3.0 dataProfile -> ValueError with single readable message."""
256-
with pytest.raises(ValueError, match="is not a valid WQX3.0 profile"):
257-
get_results(legacy=False, dataProfile="not_a_real_profile")

0 commit comments

Comments
 (0)