Age | Commit message (Collapse) | Author |
|
It works! With lots of printf debugging!
Now that I've gone through and made it work I need to go back and try to
understand it and think about all the cases I haven't tested and might
have broken.
This is my minimal example:
before:
from qutebrowser.qt.QtCore import (QUrl,
QPoint)
from qutebrowser.qt.QtGui import QIcon
foo = QUrl("about:blank")
bar = QPoint()
qux = QIcon()
after:
from qutebrowser.qt import QtCore, QtGui
foo = QtCore.QUrl("about:blank")
bar = QtCore.QPoint()
qux = QtGui.QIcon()
I've already ran into one case that I didn't cover with that:
from qutebrowser.qt.QtCore import Qt
foo = Qt.Key_Enter
|
|
Copies the upstream rename codemod because it has shown pretty good
results but I want to change it to support wildcards. For example:
python -m libcst.tool codemod rename.RenameCommand qutebrowser/browser/browsertab.py --old_name=qutebrowser.qt.QtCore.pyqtSignal --new_name=qutebrowser.qt:QtCore.pyqtSignal --no-format
With the vanilla codemod correctly handles the pyqtSignal import and all
the references but I don't want to have to run it for every Qt type. I
would like to be able to specify names like:
--old_name=qutebrowser.qt.QtCore.* --new_name=qutebrowser.qt:QtCore.*
|
|
mypy is still confused. Probably we can install PyQt5-stubs as
qutebrowser.qt-stubs. Might try to do the actual import re-writes before
figuring out how to make that work (and in CI) though.
Mostly line-to-long and ungrouped imports. If we had black and isort set
up they would have done it for me!
Not sure why there isn't more stuff complaining about visible indent
whatever.
|
|
We want to load modules from PyQt via our own wrapper so we can
transparently support both PyQt5 and PyQt6 without having conditional
imports all through the codebase. We have a few options for this:
1. fake modules/packages and do a search and replace of imports
2. import everything we need into one module and adjust imports to use
those module attributes
3. do either 1 or 2 AND adjust all the references to Qt types to not be
the upstream QtThing but just like "thing"
(1) is the least effort and so of course what I have implemented here.
Apart from the package stuff is imported from no code needs changing.
For example:
from PyQt5.QtGui import QKeyEvent, QIcon, QPixmap
changes to
from qutebrowser.qt.QtGui import QKeyEvent, QIcon, QPixmap
For (2) we would have to change that to
from qutebrowser.qt import QtGui
And then refer to the types like QtGui.QKeyEvent, QtGui.QIcon and QtGui.QPixmap.
Automating that re-write would mean learning some new stuff for me so I
stuck with the option that can be done in an afternoon for now.
(3) just builds on (2) to not have Qt on everything. And it may make
adapting to some webengine classes moving in Qt6 easier.
This will likely make pylint, mypy and some other stuff very confused.
To get a list of all the Qt modules we use you can use semgrep, although
I didn't quite get it to re-write stuff for me:
semgrep --lang=py -e 'from PyQt5.$SUBMODULE import ($IMPORTEES)' -o findings.json --json qutebrowser scripts/ tests/
And then to parse the json:
with open("findings.json") as f: data=json.load(f)
results = data['results']
submodules = sorted(set(r['extra']['metavars']['$SUBMODULE']['abstract_content'] for r in results))
for m in submodules: print(f"from pyqt import {m}")
for m in submodules: print(f'{m} = importlib.import_module("PyQt5.{m}")')
Does the qt.py file need to be moved to be a package? Probably not for
this setup, I was trying to do something else at the start...
TODO:
* see if we can get the static analyses working with this
* or try using PyParsing, lib2to3, libCST, or pyupgrade to do (2) and
get rid of the proxy loader
* undo the mechanical changes to scripts/ (leave them referring to PyQt
directly and change them on the Qt branch
* undo the mechanical changes to the userscripts (maybe make a
standalone version of this for them?)
Relates to #995
|
|
This is the first step in making qutebrowser work with both PyQt5 and
PyQt6. Namely: not having that module name everywhere throughout the
codebase.
This was a mechanical re-write performed like so:
git ls-files -z | xargs -0 sed -i 's/^\(\s*\)from PyQt5\./\1from qutebrowser.qt./'
git ls-files -z | xargs -0 sed -i 's/^\(\s*\)import PyQt5\./\1import qutebrowser.qt./'
git ls-files -z | xargs -0 sed -i 's/^\(\s*\)from PyQt5 import/\1from qutebrowser.qt import/'
This commit won't run as the imports will currently fail, see the next
commit for making them work.
I was hoping to use semgrep but, while it seems to detect import
patterns fine, using it to autofix them doesn't work so well. When
multiple objects are imported from somewhere it attempts to do the
autofix once for each thing imported. So the fixes mangle each other
because they don't re-compute what they are supposed to do.
Eg `semgrep --lang=py -e 'from PyQt5.$SUBMODULE import ($IMPORTEES)' --replacement 'from qutebrowser.qt.$SUBMODULE import ($IMPORTEES)' qutebrowser/mainwindow/tabbedbrowser.py -a`
The "importees" part of the import pattern doesn't seem to be optional
either.
|
|
|
|
|
|
|
|
Fixes #7108
|
|
For Makefile installs (broke while copying stuff over) and pyinstaller
installs (broke on launch).
|
|
|
|
Follow-up for #6905
|
|
|
|
This reverts commit 2b76b6164093754482d848e7487356215556d0d0.
|
|
|
|
|
|
Regressed in ac2cb6bb303ceec8429b084cdf372a6c8584d780
|
|
|
|
|
|
The 'generator_stop' future import is default in Python 3.7:
https://docs.python.org/3/library/__future__.html
While we do want 'annotations' eventually, it doesn't bring us any gain
right now, see #7098.
|
|
There is https://github.com/python/typeshed/blob/master/stdlib/dataclasses.pyi for the stdlib one
|
|
|
|
The PyQt resources system is gone in 6.2 and deprecated before that. This
should be the last usage of it.
Switches icons to be read with `utils.resources.read_file_binary()` in
`notification.py` (fallback desktop notification icon) and `app.py` (icon for
the desktop window).
importlib only loads resources under a package, so the icons are moved under
the `qutebrowser/` directory.
Closes: #6062
|
|
The test case on the bug works for me on py37 but CI is failing on 3.10,
maybe this isn't quite the same issue. Anyway, we are getting rid of
webkit soon.
|
|
Then regenerate the relevant files.
Also drop dataclasses from requirements files.
TODO: should we drop the dataclasses-types requirement for mypy too?
|
|
Commits for dropping 3.5 support to copy from:
c245b7d855ccd "Initial drop of Python 3.5"
ccdfb44b8568b "Drop support for Python 3.6.0"
Anything needed to update regarding OS version support in
doc/install.asciidoc?
TODO: remove 3.6/7 annotations in requirements files and
rebuild
workflows: not sure I updated it right (run 5.12 with 3.7, same 18.04 OS) but
18.04 seems to have 3.7 on it too so it should work. It'll all change when we
drop <5.15 anyway. Not sure what the minimum ubuntu version will be going
forward.
Regarding mimetype overrides (ebb3046822adb) the doctring says they can all go
in 3.7 but .h5 is still missing on py39, not sure if we should care.
There are a bunch of old(?) warning messages still ignored in tests/end2end/fixtures/quteprocess.py.
|
|
|
|
Thanks to (a hacked) pyupgrade
|
|
Found via pyupgrade
|
|
|
|
|
|
Regressed in #7068
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Closes #4561
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|