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

PR: Use QRegularExpression only for Qt 5.5+ #3994

Merged
merged 3 commits into from
Jan 20, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions spyder/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
from qtpy.QtCore import QPoint, Qt
from qtpy.QtGui import QCursor, QTextCursor, QTextDocument
from qtpy.QtWidgets import QApplication, QToolTip
from qtpy import PYQT5
from qtpy import QT_VERSION

if PYQT5:
QT55_VERSION = tuple(int(x) for x in QT_VERSION.split('.')) >= (5, 5)
Copy link
Member

Choose a reason for hiding this comment

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

Please use check_version from utils/programs.py to do the comparison here


Copy link
Member

Choose a reason for hiding this comment

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

Maybe its cleaner to define

PYQT55_VERSION = float(PYQT_VERSION) > 5.5

And use that in the conditions below?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm no, It's given an error due versions like 4.11.4

I'll implement:
MINOR_VERSION = int(PYQT_VERSION.split('.')[1])

if QT55_VERSION:
from qtpy.QtCore import QRegularExpression
else:
from qtpy.QtCore import QRegExp
Expand Down Expand Up @@ -490,7 +492,7 @@ def find_text(self, text, changed=True, forward=True, case=False,
moves += [QTextCursor.End]
if not regexp:
text = re.escape(to_text_string(text))
if PYQT5:
if QT55_VERSION:
pattern = QRegularExpression(r"\b{}\b".format(text) if words else
text)
if case:
Expand Down