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

Switch back to upstream PyQt5-stubs for mypy #5368

Closed
The-Compiler opened this issue Apr 20, 2020 · 5 comments
Closed

Switch back to upstream PyQt5-stubs for mypy #5368

The-Compiler opened this issue Apr 20, 2020 · 5 comments
Labels
component: infrastructure Issues related to development scripts, CI, servers, etc. priority: 0 - high Issues which are currently the primary focus.
Projects

Comments

@The-Compiler
Copy link
Member

Right now, qutebrowser is still running with its own outdated fork of PyQt5-stubs. We should switch back to the upstream project.

From a quick test, that results in 456 new mypy errors (some of them I don't quite understand), so that will likely need a bit more work first.

@The-Compiler The-Compiler added component: infrastructure Issues related to development scripts, CI, servers, etc. priority: 0 - high Issues which are currently the primary focus. labels Apr 20, 2020
@The-Compiler
Copy link
Member Author

Ah, right, I'll probably need to resolve python-qt-tools/PyQt5-stubs#15 first.

@The-Compiler The-Compiler added this to Backlog in Roadmap Apr 29, 2020
@rakanalh
Copy link

rakanalh commented May 3, 2020

The PR for that issue: python-qt-tools/PyQt5-stubs#36 has been merged. Do you think it's possible to switch QB to use the latest package now?

@The-Compiler
Copy link
Member Author

Those stubs aren't in the master branch yet: python-qt-tools/PyQt5-stubs#42

Even then, there's still a lot to be fixed in the stubs (and perhaps in qutebrowser's codebase) - right now, I see:

Found 174 errors in 61 files (checked 179 source files)

and with the new modules in, that number might raise.

@The-Compiler
Copy link
Member Author

The new files are in master now, and things do look better:

Found 118 errors in 49 files (checked 179 source files)

I'll see if I can take a look at those.

@The-Compiler The-Compiler moved this from Backlog to Focus in Roadmap May 4, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
The-Compiler added a commit that referenced this issue May 9, 2020
@The-Compiler
Copy link
Member Author

The-Compiler commented May 9, 2020

Almost there after some changes:

 43 files changed, 207 insertions(+), 133 deletions(-)

Todo:

  • Can we improve the typing in keyutils.py?
  • What to do about PyQIODevice?
qutebrowser/utils/qtutils.py:233: error: Argument 1 to "TextIOWrapper" has incompatible type "PyQIODevice"; expected "IO[bytes]"  [arg-type]
                new_f = io.TextIOWrapper(PyQIODevice(f),
                                         ^
qutebrowser/utils/qtutils.py:305: error: Argument 1 to "QtOSError" has incompatible type "QIODevice"; expected "QFileDevice"  [arg-type]
                raise QtOSError(self.dev)
                                ^
qutebrowser/utils/qtutils.py:328: error: Argument 1 to "QtOSError" has incompatible type "QIODevice"; expected "QFileDevice"  [arg-type]
                raise QtOSError(self.dev, msg="seek failed!")
                                ^
qutebrowser/utils/qtutils.py:350: error: Return type "QByteArray" of "readline" incompatible with return type "bytes" in supertype "IOBase"  [override]
        def readline(self, size: int = -1) -> QByteArray:
        ^
qutebrowser/utils/qtutils.py:365: error: Incompatible types in assignment (expression has type "QByteArray", variable has type "bytes")  [assignment]
                    buf = self.dev.readAll()
                          ^
qutebrowser/utils/qtutils.py:371: error: Incompatible return value type (got "bytes", expected "QByteArray")  [return-value]
            return buf
                   ^
qutebrowser/utils/qtutils.py:384: error: Argument 1 of "write" is incompatible with supertype "BufferedIOBase"; supertype defines the argument type as "Union[bytes, bytearray]"  [override]
        def write(self, data: str) -> int:
        ^
qutebrowser/utils/qtutils.py:387: error: Argument 1 to "write" of "QIODevice" has incompatible type "str"; expected "Union[QByteArray, bytes, bytearray]"  [arg-type]
            num = self.dev.write(data)
                                 ^
qutebrowser/utils/qtutils.py:389: error: Argument 1 to "QtOSError" has incompatible type "QIODevice"; expected "QFileDevice"  [arg-type]
                raise QtOSError(self.dev)
                                ^
qutebrowser/utils/qtutils.py:392: error: Return type "QByteArray" of "read" incompatible with return type "bytes" in supertype "BufferedIOBase"  [override]
        def read(self, size: typing.Optional[int] = None) -> QByteArray:
        ^
qutebrowser/utils/qtutils.py:399: error: Incompatible types in assignment (expression has type "bytes", variable has type "QByteArray")  [assignment]
                buf = self.dev.read(size)
                      ^
qutebrowser/utils/qtutils.py:399: error: Argument 1 to "read" of "QIODevice" has incompatible type "Optional[int]"; expected "int"  [arg-type]
                buf = self.dev.read(size)
                                    ^
  • Is it a good idea that configtypes.QtFont inherits from configtypes.Font?
qutebrowser/config/configtypes.py:1347: error: Return type "Union[Unset, None, QFont]" of "to_py" incompatible with return type "Union[None, str, Unset]" in supertype "Font"  [override]
        def to_py(self, value: _StrUnset) -> typing.Union[usertypes.Unset,
        ^
  • Is this intended?
qutebrowser/browser/hints.py:896: error: Argument 1 to "_hint_strings" of "HintManager" has incompatible type "List[HintLabel]"; expected "Sequence[AbstractWebElement]"  [arg-type]
                strings = self._hint_strings(visible)
                                             ^

The-Compiler added a commit that referenced this issue May 10, 2020
The-Compiler added a commit that referenced this issue May 10, 2020
The-Compiler added a commit that referenced this issue May 10, 2020
We accidentally passed a list of HintLabels instead of a list of elements
there. That worked by accident, because all we use with number hints is
actually the length of that list.

See #5368
The-Compiler added a commit that referenced this issue May 10, 2020
Roadmap automation moved this from Focus to Done May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: infrastructure Issues related to development scripts, CI, servers, etc. priority: 0 - high Issues which are currently the primary focus.
Projects
Roadmap
  
Done
Development

No branches or pull requests

2 participants