Package: optioneer
Optioneer makes in-program options, that:are nestable and groupable,are tab-able in the REPL for easy options discoverabilitygive each option a optional doc string, for easily explaining the optionmay deprecate according to a transparent deprecation cyclemay be validated upon changecan do custom  callbacksOptioneer is based on thecore/config.pymodule inpandas.InstallationInstalling is easy using pip:pipinstalloptioneerUsage guideIn aconfig.pyfile set up your options:fromoptioneerimportOptioneeroptions_maker=Optioneer()options_maker.register_option('api_key','abcdefg')options_maker.register_option('display.width',200,doc='Width of our display')options_maker.register_option('display.height',200,doc='Height of our display')options_maker.register_option('color','red',validator=options_maker.is_str)options=options_maker.optionsThen, in the relevant location of your library, just dofrom config import optionsand you’re got your options set up.Users of your library can now access the options from the relevant location
in your package, e.g. if you’ve made it available in the top-level__init__.pyof a package calledmylib:>>>importmylib>>>importmylib.optionsOptions(api_key:Nodescriptionavailable.[default:abcdefg][currently:abcdefg]color:Nodescriptionavailable.[default:red][currently:red]display.height:Heightofourdisplay[default:200][currently:200]display.width:Widthofourdisplay[default:200][currently:200])Notice how the repr output shows the relevant options and their descriptions.The relevant options are discoverable using tabs in the REPL:>>>mylib.options.<TAB>option.api_keyoptions.coloroptions.display>>>mylib.options.display.<TAB>options.display.heightoptions.display.widthYou can also easily see the options and their values and docs for subgroups in
the repr string:>>>mylib.options.displayOptions(display.height:Heightofourdisplay[default:200][currently:200]display.width:Widthofourdisplay[default:200][currently:200])CallbacksBy providing a callback when registering options, changing options may trigger
a desired actions. For example, if you in yourconfig.pydo:options_maker.register_option('shout',True,callback=lambdax:print("YEAH!"))Then the user, when changing that option will see:>>>mylib.options.shout=FalseYEAH!Of course, the callback can be more realistic than above, e.g. logging or
setting some internal option or something else.Deprecating optionsIf you want to deprecate an option,optioneerallows you to do that:options_maker.deprecate_option('api_key',msg='An api key is no longer needed')Now your users get a deprecation warning, if they access this option:>>>mylib.options.api_keyAnapikeyisnolongerneededC:\Users\TP\Documents\Python\optioneer\optioneer\lib.py:677:FutureWarning:Anapikeyisnolongerneededwarnings.warn(deprecated_option.msg,FutureWarning)Out[20]:'abcdefg'If an options should be renamed and/or a marker should be for when the option will
be removed, that is also possible:options_maker.register_option('display.length',300,doc='Length of our display')options_maker.deprecate_option('display.height',redirect_key='display.length',removal_version='v1.3')Then accessing the option will show>>>mylib.options.display.heightC:\Users\TP\Documents\Python\optioneer\optioneer\lib.py:689:FutureWarning:'display.height'isdeprecatedandwillberemovedinv1.3,pleaseuse'display.length'instead.warnings.warn(msg,FutureWarning)Out[24]:300Deprecated options will not show up in repr output or when tab-completing.DependenciesOptioneer has no external dependencies.Optioneer uses pytest for testing.LicenseOptioneer is BSD 3-licensed.