Auto-complete parameter name when set on existing Configurable
Extends #1 (closed).
This is implemented as an add-on and hence needs to be installed manually.
from hanna.addons import AutocompleteParameterNames
AutocompleteParameterNames.install()
from hanna import Configurable # Imports must come after the add-on is installed because
# it will change the Configurable class.
Then we can use the feature:
class Book(Configurable):
pass
Book.year = Integer()
assert Book.year.title == 'year'
This does not modify the parameter instance that is set but instead creates a (deep) copy:
class Book(Configurable):
pass
p_year = Integer()
Book.year = p_year
assert Book.year.title == 'year'
assert p_year.name is None
We can uninstall the feature via:
AutocompleteParameterNames.uninstall()
from hanna import Configurable # Don't forget to import again what you need since
# the Configurable class has been reset.
Edited by Dominik Vilsmeier