Skip to content
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

observe should raise with better error if wrong argument passed. #221

Closed
Carreau opened this issue May 17, 2016 · 1 comment · Fixed by #253
Closed

observe should raise with better error if wrong argument passed. #221

Carreau opened this issue May 17, 2016 · 1 comment · Fixed by #253
Milestone

Comments

@Carreau
Copy link
Member

Carreau commented May 17, 2016

Do you see the mistake :

    readline_parse_and_bind = List(default_value=[
            'tab: complete',
            '"\C-l": clear-screen',
            'set show-all-if-ambiguous on',
            '"\C-o": tab-insert',
            '"\C-r": reverse-search-history',
            '"\C-s": forward-search-history',
            '"\C-p": history-search-backward',
            '"\C-n": history-search-forward',
            '"\e[A": history-search-backward',
            '"\e[B": history-search-forward',
            '"\C-k": kill-line',
            '"\C-u": unix-line-discard',
        ]).tag(config=True)

    _custom_readline_config = False

    @observe(readline_parse_and_bind)
    def _readline_parse_and_bind_changed(self, change):
        # notice that readline config is customized
        # indicates that it should have higher priority than inputrc
        self._custom_readline_config = True

it took me 1/2 an hour to figure out I was missing a quote, because it took me 1/2 an hour to figure out which observe was wrong:

Traceback (most recent call last):
  File "/Users/bussonniermatthias/anaconda/bin/ipython", line 9, in <module>
    load_entry_point('ipython', 'console_scripts', 'ipython')()
  File "/Users/bussonniermatthias/dev/ipython/IPython/__init__.py", line 119, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/config/application.py", line 595, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-111>", line 2, in initialize
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/config/application.py", line 74, in catch_config_error
    return method(app, *args, **kwargs)
  File "/Users/bussonniermatthias/dev/ipython/IPython/terminal/ipapp.py", line 305, in initialize
    self.init_shell()
  File "/Users/bussonniermatthias/dev/ipython/IPython/terminal/ipapp.py", line 321, in init_shell
    ipython_dir=self.ipython_dir, user_ns=self.user_ns)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/config/configurable.py", line 405, in instance
    inst = cls(*args, **kwargs)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 912, in __new__
    inst.setup_instance(*args, **kwargs)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 940, in setup_instance
    super(HasTraits, self).setup_instance(*args, **kwargs)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 931, in setup_instance
    value.instance_init(self)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 878, in instance_init
    inst.observe(self, self.trait_names, type=self.type)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 1216, in observe
    names = parse_notifier_name(names)
  File "/Users/bussonniermatthias/anaconda/lib/python3.5/site-packages/traitlets/traitlets.py", line 179, in parse_notifier_name
    raise ValueError("names must be strings")
ValueError: names must be strings

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

Could we add the name of the trait to the error message at least ?

Note that the file of the error does not even appear in the stack.

@SylvainCorlay
Copy link
Member

👍

@minrk minrk changed the title observe should raise with bettern error if wrong argument passed. observe should raise with better error if wrong argument passed. May 20, 2016
@minrk minrk closed this as completed in #253 Aug 4, 2016
@minrk minrk added this to the 4.3 milestone Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants