-
-
Notifications
You must be signed in to change notification settings - Fork 33k
bpo-44761: Change default value of NewType __module__ attr #27406
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
Conversation
@Fidget-Spinner Could you please review this PR? |
if '.' in name: | ||
name = name.rpartition('.')[-1] | ||
self.__name__ = name | ||
self.__module__ = _callee(default='typing') |
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.
Let's replace the body of _callee()
with what we currently have in TypeVar.__init__
and use that instead here, in TypeVar, and in ParamSpec? So that all three use cases are identical.
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.
There's a PR refactoring all the uses of this pattern at GH-27387. Though I wasn't too comfortable backporting a refactoring along with a bugfix so I asked him to separate the bugfix into this PR (please let me know if you feel that was wrong).
If you are ok with backporting GH-27387, then we can just merge your suggestions here with that one too.
Misc/NEWS.d/next/Library/2021-07-28-13-10-17.bpo-44761.smjHBU.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Please add the test you described here #27387 (comment) |
@Fidget-Spinner could you please add |
I have made the requested changes; please review again |
Thanks for making the requested changes! @ambv: please review the changes made to this pull request. |
Wait, what is going on with those pull requests (this one and GH-27387)? I thought the entire point was to make all three types (TypeVar, ParamSpec, and NewType) behave the same. With this patch they don't because the default in Also, the test here now is missing any assert statement so it doesn't serve any purpose. I'll leave comments regarding GH-27387 on that PR. |
You're right, I missed that.
From what I understand, the test will raise |
This test is similar to cpython/Lib/test/test_typing.py Lines 245 to 250 in cb1d76f
My bad regarding default value. I have fixed it, and now it will return "main" when |
You added |
Agree, I will copy-paste |
GH-27477 is a backport of this pull request to the 3.10 branch. |
https://bugs.python.org/issue44761