<div dir="ltr"><div style="font-family:tahoma,sans-serif" class="gmail_default">​​</div><div class="gmail_default" style="font-family:tahoma,sans-serif">Dear PyQt developers/maintainers/documenters,</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">[Also cc'ed to "Florian Bruhin", as I believe you have indicated that you are "The Man"!]</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I'm getting a little peeved by the problems which arise when you seem to have chosen to make a PyQt function differ somewhat (in return result, so far) from the corresponding Qt C++ function, but no documentation to explain can be found.  (This may apply only to PyQt5, not PyQt4, I don't know.)<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I was just trying to write an override in my own class for <span style="font-family:monospace,monospace">QRegularExpression.validate()</span>.  The Qt documentation (<a href="http://doc.qt.io/qt-5/qregularexpressionvalidator.html#validate">http://doc.qt.io/qt-5/qregularexpressionvalidator.html#validate</a>) shows:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><h3 class="gmail-fn" id="gmail-validate"><span class="gmail-type"><a href="http://doc.qt.io/qt-5/qvalidator.html#State-enum">QValidator::State</a></span> QRegularExpressionValidator::<span class="gmail-name">validate</span>(<span class="gmail-type"><a href="http://doc.qt.io/qt-5/qstring.html">QString</a></span> &<i>input</i>, <span class="gmail-type">int</span> &<i>pos</i>) const</h3></div><div class="gmail_default" style="font-family:tahoma,sans-serif">So I expect it to return a <span style="font-family:monospace,monospace">QValidator.State</span>.  However, <span style="font-family:monospace,monospace">QtGui.pyi</span> shows:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(0,0,128);font-weight:bold">def </span>validate(<span style="color:rgb(148,85,141)">self</span>, input: <span style="color:rgb(0,0,128)">str</span>, pos: <span style="color:rgb(0,0,128)">int</span>) -> typing.Tuple[QValidator.State, <span style="color:rgb(0,0,128)">str</span>, <span style="color:rgb(0,0,128)">int</span>]: ...</pre></div><div class="gmail_default" style="font-family:tahoma,sans-serif">So this is a tuple, with an extra <span style="font-family:monospace,monospace">str</span> & <span style="font-family:monospace,monospace">int</span> returned.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Apart from the fact that it's a tuple instead of a plain enum returned, I have <i>no idea</i> what the extra <span style="font-family:monospace,monospace">str</span> & <span style="font-family:monospace,monospace">int</span> might be, what to do with them, etc.<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Googling around, the only thing I found was <a href="https://github.com/pycom/EricShort/blob/master/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardServer.py">https://github.com/pycom/EricShort/blob/master/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardServer.py</a>, which shows me:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_default" style="font-family:tahoma,sans-serif"><span class="gmail-pl-s">    @return tuple of flag indicating validity (boolean), error</span>
      
      
        <span class="gmail-pl-s">        string (string) and error offset (integer)<br></span></div></blockquote><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">While not the same class, I hazard a guess that this tells me what the <span style="font-family:monospace,monospace">str</span> & <span style="font-family:monospace,monospace">int</span> are about(?)  But without that I would have been lost if they mattered.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Previously I have come across this issue with <span style="font-family:monospace,monospace">QFileDialog.getOpen/SaveFileName()</span>, which returns a tuple of the filename <i>plus</i> some further information.  (Necessitating me to write an "intermediate" function which just returned the filename, as this is what the calling code expected).  This I had to track down via:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(128,128,128);font-style:italic"># (see <a href="https://riverbankcomputing.com/pipermail/pyqt/2014-March/033923.html">https://riverbankcomputing.com/pipermail/pyqt/2014-March/033923.html</a>,<br></span><span style="color:rgb(128,128,128);font-style:italic">#  <a href="http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#qfiledialog">http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#qfiledialog</a>,<br></span><span style="color:rgb(128,128,128);font-style:italic">#  also <a href="http://pyqt.sourceforge.net/Docs/PyQt5/gotchas.html">http://pyqt.sourceforge.net/Docs/PyQt5/gotchas.html</a>)</span></pre></div><div class="gmail_default" style="font-family:tahoma,sans-serif">If you <i>really</i> need to return different information from the C++ function (why?  to do with overloading not working the same??), could this not be documented somewhere reliable?  I can't find the PyQt5 <span style="font-family:monospace,monospace">QRegularExpressionValidator.validate()</span> anywhere.  <i>Much</i> better still would be if the function definition in the <span style="font-family:monospace,monospace">.pyi</span> file could explain, but you'll probably say that's auto-generated....</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">PyQt is great, and thank you for your efforts!  Just can anything be done about this (I have no idea how many other cases might be like this)?<br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><span class="gmail-pl-s"></span></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br clear="all"></div><br><br></div>