Age | Commit message (Collapse) | Author |
|
also update the default tox env list which I forgot to do when changing
the mypy targets.
|
|
Follow-up to 377bdf736f96605b998ca6f2ea2b062e190653b0 - less confusing
that way IMHO, as the value now is already an int in that branch.
|
|
Follow-up to 76ca4a9dd61e7179881044757d83d2bf5928819d.
|
|
Follow-up to 3d93e1537836e91580eae32714f440626a2a1e15
|
|
|
|
Follow-up to 9c193c18f08f30c341e4869d5e84a4564a58afd1
|
|
|
|
Follow-up to b0e3dcef819d9e24361051d2dc85f6f0e8762aa6.
|
|
Now that the two implementations are in the same class, there's no need
for the indirection anymore.
Follow-up to 647b74197a779e00cae1847654796581df28a7b0.
|
|
The problem here is that mypy (correctly) complains that self._dialog
could be None again at the point that the lambda runs, which is a
different variable scope.
The assert can be dropped (in the show_dialog locals scope, mypy *knows*
it's never None, as we just assigned it!).
Follow-up to 1bbf75ae7dbbfa2568bd5fe50dc1d7d213377f4e.
|
|
(Ab)using an environment variable indeed seems like the easiest way
forward here, but since it is exposed in the environment for the called
processes, let's give it a name which is less likely to clash, and more
easily identifyable.
Follow-up to c1738ca55006966e7c0ad9eacbfb58625aa88c44.
|
|
The changes in requirements-mypy.txt would get overwritten on the next
dependency update. Also, it looks like we don't actually need PyQt6 (or
the PyQt6 stubs) available for checking PyQt 5 code if all Qt 6 imports
are appropriately gated by conditionals mypy knows about.
Follow-up to c1738ca55006966e7c0ad9eacbfb58625aa88c44.
|
|
I only had the old way save in my bash history and this one was only
mentioned in the changelog.
Also changed the heading above the new entry to be title case, which
seems to be more consistent with the other headinfs in the file.
Also remove the one remaining mention of `QUTE_BDD_WEBENGINE` since it
does nothing anymore.
|
|
Leftover from 62515fecf0a64f ref #7091
|
|
Get mypy working, with pyqt5, on qt6-v2 branch
|
|
|
|
We'll be going forward with type checking on PyQt5 for now while
figuring out what to do with PyQt6 type checking.
See https://github.com/qutebrowser/qutebrowser/discussions/7372#discussioncomment-3502200
|
|
1. stop pretending to propagate None to the qt/python debug methods
2. handle simplewrapper in extract_enum_val
I think this stuff will need a little more cleaning up when we get to
sorting out type checking on PyQt6.
The whole key debug module seems to be a bit fuzzy about when it's going
to be passing around a simplewrapper, int and enum.
I believe we are using sip.simplerwapper as a common parent type of all
the Qt Flag/Enum values. I think it gets better on PyQt6, don't remember
though. It might just change to be sip.wrapper instead.
|
|
Mypy doesn't seem to know that QKeySequence is an iterable, so it
complains about itertools not handling it. And since we lose type
information there we have to add it back in a couple of places.
|
|
That wasn't so hard, just put everything behind compile time constants,
even the type definition.
|
|
There are several cases where PyQt5 methods expects the plural flags version but
we've got the singular Enum version from accessing enum members directly.
It's not easy to turn those enums into flags and the flags don't even
exist in PyQt6.
|
|
I'm not sure how theoretical this case is. There is a comment somewhere
else indicating the reply can "disappear".
|
|
Not sure why mypy was failing to see the inner dicts in
_PREFERRED_COLOR_SCHEME_DEFINITIONS where being seen as "object" by mypy
and not dict, I think the syntax is correct.
Add some basic type hints to help it.
They Any is because usertype.UNSET() is a sentinal object
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Apparently this got changed by the scripts/dev/rewrite_enums.py script?
Strange. 0877fb0d78635
|
|
The docs say:
> The options from QUrl::ComponentFormattingOptions are also possible.
> The FormattingOptions type is a typedef for QFlags<UrlFormattingOption>. It stores an OR combination of UrlFormattingOption values.
Maybe we should be should be definining out own types for some of the
enums that include both the QFlag, enum and any child enums.
|
|
|
|
They are the same damn thing: https://doc.qt.io/qt-6/qt.html#WindowType-enum
|
|
PyQt5 stubs require a flags object that doesn't exist in PyQt6
|
|
|
|
Yet another case of confusion between flags and enum objects.
|
|
Conditionally define a type so it can work with PyQt5s mismatch of enums
and flags and PyQt6s enums.
|
|
|
|
|
|
|
|
Get rid of the per-backend classes and move the backend specific
conditionals into a common class.
Sadly it seems mypy isn't clever enough to reason ignore a class it should
know is never used. Possibly it looks at them at parse time. Probably putting
the whole class definitions into conditionals would do it but I'm not sure if
I want to go down that route for such a small example. Hopefully there aren't
too many more of these.
|
|
Also turn the qt5 value into a list instead of a dict_values, for the
sake of mypy
|
|
|
|
|
|
PyQt5 exposes Enums and their corresponding QtFlags objects seperately,
and for some reason they aren't interchangeable. ref https://github.com/python-qt-tools/PyQt5-stubs/issues/142
We could handle this by casting values back and forth between the enum
value (for working with) and the flags value (for passing to methods),
but this situation doesn't even exist with PyQt6, you can use everything
as enums just fine.
So I'm just adding ignore comments and making type definitions
conditional.
Not sure if this is the right thing to be doing or not.
for b3cdb28d044
|
|
|
|
Putting ignore[type] on the second import works fine. But if we have it
on both the pyqt5 and pyqt6 branch it'll complain about the other branch
on each run. So pull it out to a common place we can ignore.
|
|
Would be nice to have a bare `mypy` env which ran both the more specific ones
in sequence but I don't know how to do that.
Not sure if there is a way to pull the CONSTANTS_ARGS stuff out to a non-env
parameter and pass it into commands but I couldn't figure out a way. So via
the environment it is.
TODO: compare PyQt6 as-is with the WIP PyQt6-Stub
|
|
I prefer consistency of import over this complaint which doesn't even
apply here (the conditionals are mutually exclusive).
|
|
When pyright tags an object as "Unknown" (even if that is just one part of a
union of possible definitions) then VS code doesn't provide autocompletion for
that objects. Additionally, if you import that same object from multiple
modules in a file pyright (or VS Code?) will go through them in order and
prefer the last one.
1. if you import an object by name from two modules and that latter module
isn't installed the object will be marked as "Unknown"
if machinery.USE_PYQT5: # installed
from PyQt5.QtWebEngineWidgets import QWebEngineHistory
elif machinery.USE_PYSIDE2: # not installed
from PySide2.QtWebEngineWidgets import QWebEngineHistory
reveal_type(QWebEngineHistory) # class(QWebEngineHistory) | Unknown
2. if you import an object by name from a module that isn't installed and that
module isn't later overridden it'll be marked as "Unknown"
if machinery.USE_PYQT6: # installed
from from PyQt6.QtWebEngineCore import *
elif machinery.USE_PYQT5: # not installed
from PyQt5.QtWebEngineWidgets import QWebEngineHistory
reveal_type(QWebEngineHistory) # class(QWebEngineHistory) | Unknown
if machinery.USE_PYQT5: # not installed
from PyQt5.QtWebEngineWidgets import QWebEngineHistory
elif machinery.USE_PYQT6: # installed
from from PyQt6.QtWebEngineCore import *
reveal_type(QWebEngineHistory) # class(QWebEngineHistory)
So in general we want to put modules most likely to be installed at the
bottom. Except if it imports an object by name and there is a possibility it
won't be installed we want to bump it up.
So now we have:
1. PySide6: not currently supported
2. PyQt5: main supported type checking language, but not guaranteed to be
installed
3. PyQt6: quite likely to be installed but not yet supported for type checking
This means that if you have both PyQt6 and PyQt5 installed you will get
autocompletion from PyQt6. It might be better to get it from PyQt5 instead,
since that's what we will be type checking with on CI for now, but getting no
autocompletion because you only have PyQt6 installed and not PyQt5 is not
ideal.
You can confirm this by using the "go to definition" feature.
Hopefully we can use the defineConstant configuration parameter for
pyright to make this ordering less important in the future by using that
to set the proffered bindings for type checking.
|