Skip to content

show RuntimeWarning if super init raises TypeError - #177

Merged
takluyver merged 3 commits into
ipython:masterfrom
minrk:warn-bad-init-args
Feb 17, 2016
Merged

takluyver merged 3 commits into
ipython:masterfrom
minrk:warn-bad-init-args

Conversation

@minrk

@minrk minrk commented Feb 17, 2016

Copy link
Copy Markdown
Member

Since we are now passing unused constructor args to super().__init__, improper arguments that were being silently ignored will raise.

This shows a warning in that case, so that downstream bugs have a release cycle to fix their bugs revealed by the change.

I decided to use RuntimeWarning instead of a DeprecationWarning because anything that causes this was always a bug, it was just a silently ignored bug and silence is bad.

closes #176

Since we are now passing unused constructor args to `super().__init__`,
improper arguments that were being silently ignored will raise.

This shows a warning in that case,
so that downstream bugs have a release cycle to fix their bugs revealed by the change.
@takluyver

Copy link
Copy Markdown
Member

sigh on Python 2, object itself issues a warning instead of raising in this same situation, so the test is failing there with:

ValueError: Unexpected warning: object.__init__() takes no parameters

@minrk

minrk commented Feb 17, 2016

Copy link
Copy Markdown
Member Author

Le sigh...

takluyver added a commit that referenced this pull request Feb 17, 2016
show RuntimeWarning if super init raises TypeError
@takluyver
takluyver merged commit 7fd7869 into ipython:master Feb 17, 2016
Comment thread traitlets/traitlets.py
super(HasTraits, self).__init__(*super_args, **super_kwargs)
except TypeError as e:
arg_s_list = [ repr(arg) for arg in super_args ]
for k, v in kwargs.items():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be super_kwargs instead of kwargs (sorry, didn't spot this until after merging)

@minrk minrk mentioned this pull request Feb 17, 2016
@minrk minrk modified the milestone: 4.2 Mar 14, 2016
@minrk
minrk deleted the warn-bad-init-args branch June 24, 2019 12:46
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 this pull request may close these issues.

IPython tests fail with traitlets master

2 participants