-
Notifications
You must be signed in to change notification settings - Fork 815
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
calculate message namespace from __qualname__ when not specified #3940
calculate message namespace from __qualname__ when not specified #3940
Conversation
else: | ||
# a class defined inside of a function will have a qualified name like func.<locals>.Class, | ||
# so make sure we only use the actual class name(s) | ||
qualname = cls.__qualname__.rsplit("<locals>.", 1)[-1] |
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.
This seem brittle. Is it guaranteed that CPython and all other Python's will have a qualname formatted like this?
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.
It's explicitly defined in the PEP that introduced __qualname__
: https://peps.python.org/pep-3155/#proposal
Sorry for the delay on this - this is quite the gotcha! I've confirmed it fixes the issue and tested it in a complex app. I also updated the CHANGELOG. If the tests pass I think we're good to merge. |
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
Fixes #3939
Use
__qualname__
for the message namespace since it already contains the outer class, making thehandler_name
processing in_MessagePumpMeta
unnecessaryPlease review the following checklist.