New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config.register_option allows registering invalid options #29242
Labels
Comments
why would you not want this? it’s a pretty clear message |
if a.b.c is registered you shouldn't be able to register a.b |
>>> import pandas as pd
>>>
>>> pd.__version__
'0.26.0.dev0+684.g953757a3e'
>>>
>>> from pandas._config import config
>>>
>>> config.get_option("a.b.c")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\simon\pandas\pandas\_config\config.py", line 233, in __call__
return self.__func__(*args, **kwds)
File "C:\Users\simon\pandas\pandas\_config\config.py", line 102, in _get_option
key = _get_single_key(pat, silent)
File "C:\Users\simon\pandas\pandas\_config\config.py", line 88, in _get_single_key
raise OptionError("No such keys(s): {pat!r}".format(pat=pat))
pandas._config.config.OptionError: "No such keys(s): 'a.b.c'"
>>>
>>> config.register_option("a.b.c", 1)
>>>
>>> config.get_option("a.b.c")
1
>>>
>>> config.register_option("a.b.c", 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\simon\pandas\pandas\_config\config.py", line 445, in register_option
raise OptionError(msg.format(key=key))
pandas._config.config.OptionError: "Option 'a.b.c' has already been registered"
>>>
>>> config.register_option("a.b", "foo")
>>>
>>> config.get_option("a.b.c")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\simon\pandas\pandas\_config\config.py", line 233, in __call__
return self.__func__(*args, **kwds)
File "C:\Users\simon\pandas\pandas\_config\config.py", line 106, in _get_option
return root[k]
TypeError: string indices must be integers
>>> |
i would be more concerned with registering invalid options |
i'll update the title |
simonjayhawkins
changed the title
config.register_option allows re-registering previously registered option.
config.register_option allows registering invalid options
Oct 27, 2019
Does this need fixing? I would be happy to get working on this :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: