summaryrefslogtreecommitdiff
path: root/qutebrowser/commands
AgeCommit message (Collapse)Author
2023-06-30Remove vim modelinesPhilipp Albrecht
We're deprecating vim modelines in favor of `.editorconfig`. Removing vim modelines could be done using two one-liners. Most of the vim modelines were followed by an empty line, so this one-liner took care of these ones: ```sh rg '^# vim: .+\n\n' -l | xargs sed -i '/^# vim: /,+1d' ``` Then some of the vim modelines were followed by a pylint configuration line, so running this one-liner afterwards took care of that: ```sh rg '^# vim:' -l | xargs sed -i '/^# vim: /d' ```
2023-06-26Initial Python 3.7 dropFlorian Bruhin
2022-08-23Run scripts/dev/rewrite_enums.pyFlorian Bruhin
2022-08-23Run scripts/dev/rewrite_qt_imports.shFlorian Bruhin
2022-06-17Remove repeated item in listMohammed Anas
2022-05-09Fix lint and coverageFlorian Bruhin
2022-05-09Display close matches for invalid commandsFlorian Bruhin
2022-04-25mypy: Upgrade to PyQt5-stubs 5.15.6.0Florian Bruhin
For some unknown reason, those new stubs cause a *lot* of things now to be checked by mypy which formerly probably got skipped due to Any being implied somewhere. The stubs themselves mainly improved, with a couple of regressions too. In total, there were some 337 (!) new mypy errors. This commit fixes almost all of them, and the next commit improves a fix to get things down to 0 errors again. Overview of the changes: ==== qutebrowser/app.py - Drop type ignore due to improved stubs. ==== qutebrowser/browser/browsertab.py - Specify the type of _widget members more closely than just QWidget. This is debatable: I suppose the abstract stuff shouldn't need to know anything about the concrete backends at all. But it seems like we cut some corners when initially implementing things, and put some code in browsertab.py just because the APIs of both backends happened to be compatible. Perhaps something to reconsider once we drop QtWebKit and hopefully implement a dummy backend. - Add an additional assertion in AbstractAction.run_string. This is already covered by the isinstance(member, self.action_base) above it, but that's too dynamic for mypy to understand. - Fix the return type of AbstractScroller.pos_px, which is a QPoint (with x and y components), not a single int. - Fix the return type of AbstractScroller.pos_perc, which is a Tuple (with x and y components), not a single int. - Fix the argument types of AbstractScroller.to_perc, as it's possible to pass fractional percentages too. - Specify the type for AbstractHistoryPrivate._history. See above (_widget) re this being debatable. - Fix the return type of AbstractTabPrivate.event_target(), which can be None (see #3888). - Fix the return type of AbstractTabPrivate.run_js_sync, which is Any (the JS return value), not None. - Fix the argument type for AbstractTabPrivate.toggle_inspector: position can be None to use the last used position. - Declare the type of sub-objects of AbstractTab. - Fix the return value of AbstractTab.icon(), which is the QIcon, not None. ==== qutebrowser/browser/commands.py - Make sure the active window is a MainWindow (with a .win_id attribute). ==== qutebrowser/browser/downloadview.py - Add _model() which makes sure that self.model() is a DownloadModel, not None or any other model. This is needed because other methods access a variety of custom attributes on it, e.g. last_index(). ==== qutebrowser/browser/greasemonkey.py - Add an ignore for AbstractDownload.requested_url which we patch onto the downloads. Probably would be nicer to add it as a proper attribute which always gets set by the DownloadManager. ==== qutebrowser/browser/hints.py - Remove type ignores for QUrl.toString(). - Add a new type ignore for combining different URL flags (which works, but is not exactly type safe... still probably a regression in the stubs). - Make sure the things we get back from self._get_keyparser are what we actually expect. Probably should introduce a TypedDict (and/or overloads for _get_keyparser with typing.Literal) to teach mypy about the exact return value. See #7098. This is needed because we access Hint/NormalKeyParser-specific attributes such as .set_inhibited_timout() or .update_bindings(). ==== qutebrowser/browser/inspector.py - Similar changes than in browsertab.py to make some types where we share API (e.g. .setPage()) more concrete. Didn't work out unfortunately, see next commit. ==== qutebrowser/browser/network/pac.py - Remove now unneeded type ignore for signal. ==== qutebrowser/browser/qtnetworkdownloads.py - Make sure that downloads is a qtnetworkdownloads.DownloadItem (rather than an AbstractDownload), so that we can call ._uses_nam() on it. ==== qutebrowser/browser/qutescheme.py - Remove now unneeded type ignore for QUrl flags. ==== qutebrowser/browser/urlmarks.py - Specify the type of UrlMarkManager._lineparser, as those only get initialized in _init_lineparser of subclasses, so mypy doesn't know it's supposed to exist. ==== qutebrowser/browser/webelem.py - New casts to turn single KeyboardModifier (enum) entries into KeyboardModifiers (flags). Might not be needed anymore with Qt 6. - With that, casting the final value is now unneeded. ==== qutebrowser/browser/webengine/notification.py - Remove now unneeded type ignore for signal. - Make sure the self.sender() we get in HerbeNotificationAdapter._on_finished() is a QProcess, not just any QObject. ==== qutebrowser/browser/webengine/webenginedownloads.py - Remove now unneeded type ignores for signals. ==== qutebrowser/browser/webengine/webengineelem.py - Specify the type of WebEngineElement._tab. - Remove now unneeded type ignore for mixed flags. ==== qutebrowser/browser/webengine/webengineinspector.py - See changes to inspector.py and next commit. - Remove now unneeded type ignore for signal. ==== qutebrowser/browser/webengine/webenginequtescheme.py - Remove now unneeded type ignore for mixed flags. ==== qutebrowser/browser/webengine/webenginesettings.py - Ignore access of .setter attribute which we patch onto QWebEngineProfile. Would be nice to have a subclass or wrapper-class instead. ==== qutebrowser/browser/webengine/webenginetab.py - Specified the type of _widget members more closely than just QWidget. See browsertab.py changes for details. - Remove some now-unneeded type ignores for creating FindFlags. - Specify more concrete types for WebEngineTab members where we actually need to access WebEngine-specific attributes. - Make sure the page we get is our custom WebEnginePage subclass, not just any QWebEnginePage. This is needed because we access custom attributes on it. ==== qutebrowser/browser/webengine/webview.py - Make sure the page we get is our custom WebEnginePage subclass, not just any QWebEnginePage. This is needed because we access custom attributes on it. ==== qutebrowser/browser/webkit/network/networkreply.py - Remove now unneeded type ignores for signals. ==== qutebrowser/browser/webkit/webkitinspector.py - See changes to inspector.py and next commit. ==== qutebrowser/browser/webkit/webkittab.py - Specify the type of _widget members more closely than just QWidget. See browsertab.py changes for details. - Add a type ignore for WebKitAction because our workaround needs to treat them as ints (which is allowed by PyQt, even if not type-safe). - Add new ignores for findText calls: The text is a QString and can be None; the flags are valid despite mypy thinking they aren't (stubs regression?). - Specify the type for WebKitHistoryPrivate._history, because we access WebKit-specific attributes. See above (_widget) re this being debatable. - Make mypy aware that .currentFrame() and .frameAt() can return None (stubs regression?). - Make sure the .page() and .page().networkAccessManager() are our subclasses rather than the more generic QtWebKit objects, as we use custom attributes. - Add new type ignores for signals (stubs regression!) ==== qutebrowser/browser/webkit/webpage.py - Make sure the .networkAccessManager() is our subclass rather than the more generic QtWebKit object, as we use custom attributes. - Replace a cast by a type ignore. The cast didn't work anymore. ==== qutebrowser/browser/webkit/webview.py - Make sure the .page() is our subclass rather than the more generic QtWebKit object, as we use custom attributes. ==== qutebrowser/commands/userscripts.py - Remove now unneeded type ignore for signal. ==== qutebrowser/completion/completer.py - Add a new _completion() getter (which ensures it actually gets the completion view) rather than accessing the .parent() directly (which could be any QObject). ==== qutebrowser/completion/completiondelegate.py - Make sure self.parent() is a CompletionView (no helper method as there is only one instance). - Remove a now-unneeded type ignore for adding QSizes. ==== qutebrowser/completion/completionwidget.py - Add a ._model() getter which ensures that we get a CompletionModel (with custom attributes) rather than Qt's .model() which can be any QAbstractItemModel (or None). - Removed a now-unneeded type ignore for OR-ing flags. ==== qutebrowser/completion/models/completionmodel.py - Remove now unneeded type ignores for signals. - Ignore a complaint about .set_pattern() not being defined. Completion categories don't share any common parent class, so it would be good to introduce a typing.Protocol for this. See #7098. ==== qutebrowser/components/misccommands.py - Removed a now-unneeded type ignore for OR-ing flags. ==== qutebrowser/components/readlinecommands.py - Make sure QApplication.instance() is a QApplication (and not just a QCoreApplication). This includes the former "not None" check. ==== qutebrowser/components/scrollcommands.py - Add basic annotation for "funcs" dict. Could have a callable protocol to specify it needs a count kwarg, see #7098. ==== qutebrowser/config/stylesheet.py - Correctly specify that stylesheet apply to QWidgets, not any QObject. - Ignore an attr-defined for obj.STYLESHEET. Perhaps could somehow teach mypy about this with overloads and protocols (stylesheet for set_register being None => STYLESHEET needs to be defined, otherwise anything goes), but perhaps not worth the troble. See #7098. ==== qutebrowser/keyinput/keyutils.py - Remove some now-unneeded type ignores and add a cast for using a single enum value as flags. Might need to look at this again with Qt 6 support. ==== qutebrowser/keyinput/modeman.py - Add a FIXME for using a TypedDict, see comments for hints.py above. ==== qutebrowser/mainwindow/mainwindow.py - Remove now-unneeded type ignores for calling with OR-ed flags. - Improve where we cast from WindowType to WindowFlags, no int needed - Use new .tab_bar() getter, see below. ==== qutebrowser/mainwindow/prompt.py - Remove now-unneeded type ignores for calling with OR-ed flags. ==== qutebrowser/mainwindow/statusbar/bar.py - Adjust type ignores around @pyqtProperty. The fact one is still needed seems like a stub regression. ==== qutebrowser/mainwindow/statusbar/command.py - Fix type for setText() override (from QLineEdit): text can be None (QString in C++). ==== qutebrowser/mainwindow/statusbar/url.py - Adjust type ignores around @pyqtProperty. The fact one is still needed seems like a stub regression. ==== qutebrowser/mainwindow/tabbedbrowser.py - Specify that TabDeque manages browser tabs, not any QWidgets. It accesses AbstractTab-specific attributes. - Make sure that the .tabBar() we get is a tabwidget.TabBar, as we access .maybe_hide. - Fix the annotations for stored marks: Scroll positions are a QPoint, not int. - Add _current_tab() and _tab_by_idx() wrappers for .currentWidget() and .widget(), which ensures that the return values are valid AbstractTabs (or None for _tab_by_idx). This is needed because we access AbstractTab-specific attributes. - For some places, where the tab can be None, continue using .currentTab() but add asserts. - Remove some now-unneeded [unreachable] ignores, as mypy knows about the None possibility now. ==== qutebrowser/mainwindow/tabwidget.py - Add new tab_bar() and _tab_by_idx() helpers which check that the .tabBar() and .widget() are of type TabBar and AbstractTab, respectively. - Add additional assertions where we expect ._tab_by_idx() to never be None. - Remove dead code in get_tab_fields for handling a None y scroll position. I was unable to find any place in the code where this could be set to None. - Remove some now-unneeded type ignores and casts, as mypy now knows that _type_by_idx() could be None. - Work around a strange instance where mypy complains about not being able to find the type of TabBar.drag_in_progress from TabWidget._toggle_visibility, despite it clearly being shown as a bool *inside* that class without any annotation. - Add a ._tab_widget() getter in TabBar which ensures that the .parent() is in fact a TabWidget. ==== qutebrowser/misc/crashsignal.py - Remove now unneeded type ignores for signals. ==== qutebrowser/misc/editor.py - Remove now unneeded type ignores for signals. ==== qutebrowser/misc/ipc.py - Remove now unneeded type ignores for signals. - Add new type ignores for .error() which is both a signal and a getter (stub regression?). Won't be relevant for Qt 6 anymore, as the signal was renamed to errorOccurred in 5.15. ==== qutebrowser/misc/objects.py - Make sure mypy knows that objects.app is our custom Application (with custom attributes) rather than any QApplication. ==== qutebrowser/utils/objreg.py - Ignore attr-defined for .win_id attributes. Maybe could add a typing.Protocol, but ideally, the whole objreg stuff should die one day anyways. ==== tests/unit/completion/test_completer.py - Make CompletionWidgetStub inherit from CompletionView so that it passes the new isinstance() asserts in completer.py (see above).
2021-12-03pylint: Enable docparams checkerFlorian Bruhin
2021-12-03pylint: Enable else-if-usedpylint-2-12Florian Bruhin
2021-12-02pylint: Handle consider-using-withFlorian Bruhin
2021-04-23Fix :spawn -u -oFlorian Bruhin
Fixes #6407
2021-03-23Get rid of qute://spawn-outputFlorian Bruhin
2021-03-18Fix lintdev-split-parserFlorian Bruhin
As for the mypy unreachable warning, see: See https://github.com/python/mypy/issues/7214 and https://github.com/python/mypy/issues/8766 Includes cherry-pick of 27ad47825279a39141efd11ec9cc54ff2a872517
2021-03-18Move completion fallback handling out of CommandParserFlorian Bruhin
This makes CompletionParser.parse simpler and makes ParseResult.cmd and .args non-Optional. Them being Optional would mean we would've to either resort to more complex typing with Literal, or to check whether they are really non-None everywhere. Since fallback=True is only used at one point, let's just handle this at the calling site instead. In theory, this changes the behavior when the cmdstr is empty and self._partial_match is set, because we now raise early and self._completion_match isn't called anymore. In practice, I think this shouldn't make a difference anywhere, and tests seem to agree. If cmdstr is empty and self._partial_match is False, the behavior should be the same, because objects.commands[''] will raise KeyError.
2021-03-18Fix copy-paste issueFlorian Bruhin
2021-03-18Restore config access in commands.parserFlorian Bruhin
See https://github.com/qutebrowser/qutebrowser/pull/5967#issuecomment-791373157 but no issues with circular imports here, from what I can see...
2021-03-03WIP: Add type annotations for parserFlorian Bruhin
2021-03-03Fix importsFlorian Bruhin
2021-03-03Document and rename use_best_matchFlorian Bruhin
2021-03-03Adjust importsFlorian Bruhin
2021-03-03Merge remote-tracking branch 'origin/pr/5967' into devFlorian Bruhin
2021-01-27command: Improve deprecationFlorian Bruhin
Add a test and also allow setting a deprecated alias for a command easily.
2021-01-26command: Only do function inspection onceFlorian Bruhin
2021-01-26Add initial support for Python 3.10 annotationsFlorian Bruhin
PEP 563: https://www.python.org/dev/peps/pep-0563/ See #5769
2021-01-26doc: Switch URLs to httpsFlorian Bruhin
2021-01-20Bump copyright yearsFlorian Bruhin
Closes #6015
2021-01-20userscripts: Add QUTE_VERSIONFlorian Bruhin
See #937
2021-01-20Rename :run-macro and :record-macroFlorian Bruhin
See #6022
2021-01-13dataclasses: Initial mypy fixFlorian Bruhin
See #6023
2021-01-13dataclasses: Adjust import orderFlorian Bruhin
See #6023
2021-01-13dataclasses: Initial switchFlorian Bruhin
See #6023
2021-01-06Remove unused imports in commands.parserRyan Roden-Corrent
2021-01-06Eliminate parser dependency on config.Ryan Roden-Corrent
commands.runners depends on config.config to get aliases and the best_match setting, while config.config depends on commands.runners to split commands. Eliminate this circular dependency by: - Moving CommandParser from commands.runners into its a new commands.parser module - Pass aliases/config settings into CommandParser as arguments
2020-11-29load scripts from config directoryBryon Meinka
fixes #5615
2020-10-28mypy: use from-import styleTim Brown
Update files in `api`, `commands`, `completion`, `components`, and `etensions`. See #5396
2020-10-26Initial drop of Python 3.5Florian Bruhin
See #4800
2020-10-02mypy: Update PyQt stubs and remove unneeded ignoresFlorian Bruhin
2020-06-16Use 0600 mode for uerscript FIFOFlorian Bruhin
os.mkfifo uses mode 0666 masked with the umask, i.e. 0644 on most systems by default. We'd like things to be more restrictive, to make sure other users can't get any data from another users' userscript FIFO. This shouldn't make any difference in practice because the FIFO is in standarddir.runtime() which must have 0700 permissions (and qutebrowser creates all standarddir directories with 0700 permissions if they don't exist). However, it's still a good idea to restrict the permissions as a second line of defense.
2020-06-16userscripts: Clear self._filepath on OSErrorFlorian Bruhin
As an additional precaution that a "tainted" path isn't being used anywhere. See https://github.com/qutebrowser/qutebrowser/security/code-scanning/2
2020-06-11command: Use consistent name for arg_infoFlorian Bruhin
(cherry picked from commit 279d28f982f3afe32c94fc938677bcad816b647e)
2020-05-10mypy: Disallow incomplete defs globallyFlorian Bruhin
2020-05-10mypy: Use explicit "type: ignore[...]" ignoresFlorian Bruhin
See #5368
2020-05-09mypy: Add cast for sip.voidptrFlorian Bruhin
See #5368
2020-05-09mypy: Fix typing for some re-assigned valuesFlorian Bruhin
See #5368
2020-04-02Make `spawn -m -u` work properlyuser202729
2020-01-04Adjust copyrights for 2020Florian Bruhin
2019-12-25Use (slightly) clearer wordingJethro Cao
2019-12-20Refactor user agent handlingFlorian Bruhin
We now use a format string for the user_agent setting and parse both backend's default user agents to get the needed information. Fixes #513
2019-11-25Use modeman.instance() to get mode managerFlorian Bruhin
See #640