ipywidgets
ipywidgets copied to clipboard
AttributeError raised by DatetimePicker
https://github.com/jupyter-widgets/ipywidgets/blob/84abba08bd242133b63fe992ebc65b8358b8b2f9/python/ipywidgets/ipywidgets/widgets/widget_datetime.py#L56
This line will raise an error AttributeError when I clear the picked datetime. As described in: https://github.com/vidartf/ipydatetime/issues/8
venv/lib/python3.8/site-packages/ipydatetime/datetime_widget.py in _validate_tz(self, value)
135
136 def _validate_tz(self, value):
--> 137 if value.tzinfo is not None:
138 raise TraitError('%s values needs to be timezone unaware' % (self.__class__.__name__,))
139 return value
AttributeError: 'NoneType' object has no attribute 'tzinfo'
@huyuhuster The issue you linked describes a proposed solution. Do you have the opportunity to verify if that works? And if it does, would you be interested in making a PR with it? :)
@huyuhuster The issue you linked describes a proposed solution. Do you have the opportunity to verify if that works? And if it does, would you be interested in making a PR with it? :)
@vidartf I will try that later. If it work, I will make a PR with it.
@huyuhuster Actually, I'm not able to reproduce this, and we do have a unit test that covers this case:
https://github.com/jupyter-widgets/ipywidgets/blob/90e6be0212faefcf6643c9aa0ec0a7429a01d083/python/ipywidgets/ipywidgets/widgets/tests/test_widget_datetime.py#L28-L34
I've tested this with the version of Python indicated by the error report (py 3.8), and it doesn't seem to trigger for me. I've tried some older versions of traitlets as well, but I'm simply not able to reproduce it. Would you mind sharing which versions of python (CPython?), traitlets, and ipywidgets you are using?
Ah, I see why the test didn't check it: the trait's _validate shortcuts for None if allow_none is true, but when being set from the client side with hold_traits_notification, this shortcut does not happen.