bpo-34963: Make the repr of the typing.NewType() result more meaningful.#9951
bpo-34963: Make the repr of the typing.NewType() result more meaningful.#9951serhiy-storchaka wants to merge 4 commits intopython:mainpython/cpython:mainfrom serhiy-storchaka:typing-newtype-qualnameserhiy-storchaka/cpython:typing-newtype-qualnameCopy head branch name to clipboard
Conversation
Add attributes __qualname__ and __module__. If the name argument is dotted, the __name__ attribute will be set to its last component.
ilevkivskyi
left a comment
There was a problem hiding this comment.
I actually like this solution. But before merging let us wait for the benchmarks for other approach, if they are OK, maybe we can have an even nicer repr in #9808
|
When you're done making the requested changes, leave the comment: |
vstinner
left a comment
There was a problem hiding this comment.
LGTM, but I would prefer that one of the typing maintainer double check this change. @ilevkivskyi?
|
I worked also on alternate implementations. But I don't know what properties should the NewType result have. |
|
Any news about PR? |
|
@serhiy-storchaka: This PR still LGTM. You can merge it.
It doesn't seem to define module. It doesn't seem to be directly related. This PR looks simple enough. |
|
It looks like the author of other PR is not responding. I leave up to Serhiy whether to just move with this PR or incorporate some ideas from other one too as I proposed in https://bugs.python.org/issue34963#msg328707 (This PR LGTM as is.) |
|
@serhiy-storchaka shall we move ahead with this or the alternate PR? |
|
This PR still applies and it would be useful, is there anything blocking it from being merged? |
gvanrossum
left a comment
There was a problem hiding this comment.
Okay, looks fine to me. I'll merge.
|
Closing and reopening since it looks like some tests are hanging. |
|
@serhiy-storchaka Can you look at the test failure? Maybe it just needs a merge from a more recent main branch? |
|
It needs some correction in |
|
Go for it!
|
|
typing.NewType has been reimplemented as a class in bpo-44353, so this trick is no longer needed. |
Add attributes
__qualname__and__module__.If the name argument is dotted, the
__name__attribute will be set to its last component.https://bugs.python.org/issue34963