Skip to content

Add validation to or deprectate Options.get_option #858

@genedan

Description

@genedan

There's no validation on Options.get_option. A validation message would remind the user what the valid options are:

from chainladder import options
options.get_option('asdf')
Traceback (most recent call last):
  File "/home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/IPython/core/interactiveshell.py", line 3699, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<ipython-input-4-e63857fae696>", line 1, in <module>
    options.get_option('asdf')
    ~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/ubuntu/Repos/chainladder-python/chainladder/__init__.py", line 45, in get_option
    return getattr(self, option)
AttributeError: 'Options' object has no attribute 'asdf'

Alternatively, we could deprecate the function. There's not really much in the function other than extracting the attribute. For example

options.get_option("ARRAY_BACKEND")

is the same as (assuming #857 is approved)

options.ARRAY_BACKEND

Deprecation would reduce maintenance. However, we'd lose the analogue to pandas.get_option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions