nldi: raise ValueError (not TypeError) for invalid navigation mode#258
Merged
thodson-usgs merged 2 commits intoMay 4, 2026
Merged
Conversation
`_validate_navigation_mode` raised `TypeError` for an invalid string value (e.g. "ABC"). The sister helper `_validate_data_source` in the same file already raises `ValueError` for the same kind of bad-input case. `TypeError` is reserved for cases where an argument's type is wrong; an unrecognized navigation-mode string is a value error. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns NLDI input validation semantics with Python conventions by raising ValueError (not TypeError) when a caller provides an unrecognized navigation-mode value, matching existing validation behavior in the same module.
Changes:
- Change
_validate_navigation_modeto raiseValueErrorfor invalid navigation mode strings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_validate_navigation_moderaisesTypeErrorfor an invalid string value (e.g.,"XX"). The sister helper_validate_data_sourcein the same file already raisesValueErrorfor the same kind of bad-input case.TypeErroris reserved for cases where an arguments type is wrong; an unrecognized navigation-mode string is a value error, so callers writingexcept ValueError:would not catch it today.One-line change; no regression test (the assertion would just re-state the diff).
Related PRs
This is a strict subset of #252 (
nldi-cleanup), which also changesTypeError->ValueErrorhere as part of a larger refactor (extracts_VALID_NAVIGATION_MODES, normalizes input and returns it, adds aNoneguard). If #252 lands first, this PR can be closed.#246 (
nldi-data-source-validation) also touchesnldi.pybut a different function (_validate_data_source); no conflict.🤖 Generated with Claude Code