chadrik / types-pyside Goto Github PK
View Code? Open in Web Editor NEWThe most accurate type stubs for PySide / Qt for Python
License: GNU Lesser General Public License v2.1
The most accurate type stubs for PySide / Qt for Python
License: GNU Lesser General Public License v2.1
Hello, I have been trying to get your stubs working alongside my PyCharm project.
I am using Qt.py from which types-PySide
is perfectly installed using 1.3.8
. But they are not being picked by PyCharm at all.
The reasons for now are :
External Libraries/Binary Skeletons
.pip install PySide2 --target "somedir/"
, look at the content of somedir
and notice a .pyi
file for each root Qt module. Again I can deleted those manually but though it's not a good practice as this need to be performed at each venv update.Here is a screenshot of the site-packages
directory of the venv :
So this would actually be more of a "discussion" than an "issue" as there is no issue with types-PySide
directly, just PyCharm being annoying to work with. I'm still creating the issue so it can maybe help other people having the same issue.
I'm looking for any advice on the resolution that would involve minimal hackery.
PySide2-stubs
stubs take priority over the .pyi files in PySide2
directory ?Context
PyCharm 2022.3.2
Poetry 1.2.0
Qt.py 1.3.8
types-PySide2 5.15.2.1.5
Feel free to close this if you don't estimate it's the right place to discuss it.
Cheers.
Liam.
Hi! First of all, thank you very much for the extension!
As the title suggests, the typing.Callable
is incomplete as an annotation. While mypy
never complains, not even in --strict
mode, pylance
will, since the complete statement (a very generic one) would be typing.Callable[..., typing.Any]
.
After updating the reference, I tried to compile the stubs myself, but there are a couple of problems, probably due to the exact Python, PySide, and mypy versions. For example, every Classvar
and Any
miss the typing
prefix, and Union[T, None]
has changed to Optional[T]
.
Not to mention that the biggest problem is the function in mypy/stubdoc.py:is_valid_type
. This function will complain about typing.Callable[..., Any]
as not being a valid type, which makes sense, so I've modified its regex pattern to make it work. But of course, this would only work in my environment.
I have a repo that generates Nuke python stubs, and I managed to fix some irresolvable problems by running some post-fixes after the stubs generation. While not the cleanest solution, it allows for a certain level of "manual" modifications.
So I did fork your project, made the modifications, and passed the tests. You can look into whether you are interested in implementing this in one way or another or accepting a PR.
Thanks again for this extension.
This produces a type error:
self.setFontWeight(QtGui.QFont.DemiBold)
Argument of type "Weight" cannot be assigned to parameter "w" of type "int" in function "setFontWeight"
"Weight" is incompatible with "int"
setFontWeight() allows QFont predefined weight enums, but they don't register as compatible with ints, even though they are
When I tried to use these stubs in vscode they didn't work, then checking the Output window (under python) I discovered a number of errors like this:
/stubs/PySide2-stubs/QtCore.pyi:377:5: error: Signature of "columnCount" incompatible with supertype "QAbstractItemModel"
I'm guessing vscode does a pass with mypy.stubtest first and doesn't use them unless it passes. (That's just a guess, I haven't gone to the trouble of testing this myself yet)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.