Skip to content

Support hub function calls in type

argparse can use type to call a function to enforce validations on input. Unfortunately, it doesn't appear possible to call hub functions, so this can't be used.

CLI_CONFIG = {
    "workers": {"type": hub.validator.utils.check_positive}
}

Results in

Traceback (most recent call last):
  File "/root/.local/share/virtualenvs/mypop-mGqZu586/bin/validator", line 11, in <module>
    load_entry_point('validator', 'console_scripts', 'validator')()
  File "/root/gits/projects/validator/validator/scripts.py", line 10, in start
    hub.validator.init.cli()
  File "/root/gits/pop/pop/hub.py", line 259, in __getattr__
    raise AttributeError(f"'{self._subname}' has no attribute '{item}'")
AttributeError: 'validator' has no attribute 'init'
Edited by Christian McHugh