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
Fix EventedModel signatures with PySide2 imported #2265
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2265 +/- ##
==========================================
- Coverage 67.10% 67.09% -0.01%
==========================================
Files 400 400
Lines 33652 33672 +20
==========================================
+ Hits 22581 22593 +12
- Misses 11071 11079 +8
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great debugging and crazy situation!!
def no_class_attributes(): | ||
"""Context in which pydantic.main.ClassAttribute just passes value 2. | ||
|
||
Due to a very annoying decision by PySide2, all class ``__signature__`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tlambert03 did you ever raise this issue with PySide2? |
Hi @basnijholt, no I didn't create a new issue. I did find this issue: https://bugreports.qt.io/browse/PYSIDE-1004 ... so they're aware of it to some degree. But I haven't checked to see how more recent versions of PySide2/6 are handling this |
Description
fixes #2264. This fixes a strange and unfortunate clash resulting from decisions made by PySide2 and pydantic (neither of which I feel we'd have much luck changing upstream). I put a more thorough explanation in the code docstring itself, but here's the gist:
__signature__
objects dynamically writable (as they should be), but only once (?!).__call__
method, uses a descriptor object calledClassAttribute
to wrap their custominspect.Signature
object during class creation. such thatcls.__signature__ = ClassAttribute('__signature__', actual_signature)
obj.__signature__
PySide2 seems to just return thatClassAttribute
descriptor rather than calling its__get__
method... soinspect.signature
fails.This PR temporarily monkeypatches pydantic's
ClassAttribute
object to just pass through the signature object directly when constructing our classes... then undoes the patch.Type of change
How has this been tested?
Final checklist: