Extract require_valid_issue_id and require_valid_ss58 CLI helpers - #498
Conversation
e56e11a to
e9fe986
Compare
|
try:
validate_issue_id(issue_id)
validate_ss58_address(solver_hotkey, ...)
...
except click.BadParameter:
raise
except ValueError as e:
raise click.BadParameter(str(e), param_hint='pr_number_or_url')Swapping to Other 6 call sites look good. |
|
@anderdc I've updated. Please check again |
There was a problem hiding this comment.
Clean dedup. One small thing -- fill out the docstrings on require_valid_issue_id and require_valid_ss58 to match the existing validate_issue_id / validate_ss58_address pattern in the same file (Args, Returns sections). They're right next to each other so they should be consistent.
Thanks! Just checked - |
0583a0e to
01d790d
Compare
01d790d to
a76130d
Compare
anderdc
left a comment
There was a problem hiding this comment.
The val_vote_solution fix and dedup are correct. One remaining thing on the docstrings:
Both wrappers have a return statement and a -> int / -> str return type, but the docstrings don't mention what they return. At minimum add a Returns: line. For example:
def require_valid_issue_id(value: int, param_name: str = 'issue_id') -> int:
"""Validate an issue ID, raising ClickException on failure.
Returns:
The validated issue ID.
"""Same for require_valid_ss58 -- Returns: The validated SS58 address string.
This matches the level of detail in validate_ss58_address right above them, which has a multi-line docstring explaining what it does.
…tor/extract-cli-validation-helpers
|
@anderdc I've updated. Please review again. |
Fixes: #497
Summary
Extract
require_valid_issue_idandrequire_valid_ss58helpers intogittensor/cli/issue_commands/helpers.py, replacing 7 identical try/except/re-raise blocks acrossadmin.pyandvote.py.