<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">Hi Phil,<br><br><br>Thank you for the fix! :)<br><br>However, I've got to install PyQt 5.5.1 and got the following behaviour; When repeating my previous example, I get indeed a docstring, but its always the same and it comes from the standard docstring `str.__doc__`.<br><br>I've tried both Python 3 and Python 2 with PyQt5 5.5.1<br><br> Python 3.5.0 (default, Sep 20 2015, 11:28:25)<br> Python 2.7.10 (default, Sep 7 2015, 13:51:49)<br><br> print(PYQT_VERSION_STR) <br> 5.5.1<br> print(QT_VERSION_STR) <br> 5.5.1<br> print(SIP_VERSION_STR)<br> 4.16.9<br><br>Now the tests:<br><br> # Trying to get __doc__ from the property docstring<br><br> from PyQt5.QtWidgets import QApplication, QWidget<br> from PyQt5.QtCore import pyqtProperty<br><br> app = QApplication([])<br><br> class Widget(QWidget):<br> def __init__(self):<br> super(Widget, self).__init__()<br> @pyqtProperty(str)<br> def prop(self):<br> """from docstring"""<br> return ""<br><br> w = Widget()<br><br> print(w.prop.__doc__)<br><br> str(object='') -> str<br> str(bytes_or_buffer[, encoding[, errors]]) -> str<br><br> Create a new string object from the given object. If encoding or<br> errors is specified, then the object must expose a data buffer<br> that will be decoded using the given encoding and error handler.<br> Otherwise, returns the result of object.__str__() (if defined)<br> or repr(object).<br> encoding defaults to sys.getdefaultencoding().<br> errors defaults to 'strict'.<br><br> # Trying to get __doc__ from the doc parameter<br><br> class Widget(QWidget):<br> def __init__(self):<br> super(Widget, self).__init__()<br> @pyqtProperty(str, doc="from parameter")<br> def prop(self):<br> return "" <br><br> w = Widget()<br><br> print(w.prop.__doc__)<br><br> str(object='') -> str<br> str(bytes_or_buffer[, encoding[, errors]]) -> str<br><br> Create a new string object from the given object. If encoding or<br> errors is specified, then the object must expose a data buffer<br> that will be decoded using the given encoding and error handler.<br> Otherwise, returns the result of object.__str__() (if defined)<br> or repr(object).<br> encoding defaults to sys.getdefaultencoding().<br> errors defaults to 'strict'.<br><br> # Trying to change the property type<br><br> class Widget(QWidget):<br> def __init__(self):<br> super(Widget, self).__init__()<br> @pyqtProperty(object, doc="from parameter")<br> def prop(self):<br> return ""<br><br> w = Widget()<br><br> print(w.prop.__doc__)<br><br> str(object='') -> str<br> str(bytes_or_buffer[, encoding[, errors]]) -> str<br><br> Create a new string object from the given object. If encoding or<br> errors is specified, then the object must expose a data buffer<br> that will be decoded using the given encoding and error handler.<br> Otherwise, returns the result of object.__str__() (if defined)<br> or repr(object).<br> encoding defaults to sys.getdefaultencoding().<br> errors defaults to 'strict'.<br><br>I would love to help with this, though It's not totally clear to me, from searching the web, how a patch should be submitted or a pull request or any other mean of collaboration.<br><br>Thank you.<span class="HOEnZb"><font color="#888888"><br><br>Javier</font></span><div><div class="h5"><br><br><br><br>2015-10-25 12:10 GMT+01:00 Phil Thompson <<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>>:<br><br> On 8 Oct 2015, at 1:10 p.m., Javier Santacruz López-Cepero <<a href="mailto:jsl@taric.es" target="_blank">jsl@taric.es</a>> wrote:<br> ><br> > Hello to all,<br> ><br> > I think I detected a strange behaviour with docstrings when using the pyqtProperty decorator.<br> > It does get the docstring from the doc pyqtProperty parameter but not from the docstring itself:<br> ><br> > from PyQt5 import QtCore, QtWidgets<br> ><br> > class Test(QtWidgets.QWidget):<br> > @pyqtProperty(str)<br> > def data(self):<br> > """docstring"""<br> > return "result"<br> ><br> > When defining a property like this, the __doc__ attribute is not initialized:<br> ><br> ><br> > In [11]: print(Test.data.__doc__)<br> > None<br> ><br> > But it does work when set directly from the doc parameter:<br> ><br> ><br> > from PyQt5 import QtCore, QtWidgets<br> ><br> > class Test(QtWidgets.QWidget):<br> > @pyqtProperty(str, doc="docstring")<br> > def data(self):<br> > return "result"<br> ><br> > In [13]: print(Test.data.__doc__)<br> > doctoring<br><br> Should be fixed in tonight's snapshots.<br><br> Thanks,<br> Phil<br><br><br></div></div></div>
</div><br></div>