Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-46581: Propagate private vars via _GenericAlias.copy_with#31061
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
bpo-46581: Propagate private vars via _GenericAlias.copy_with #31061
Uh oh!
There was an error while loading. Please reload this page.
Conversation
posita commented Feb 1, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ebe8d33 to ae11f6fCompareUh oh!
There was an error while loading. Please reload this page.
90d730e to ae11f6fCompareposita commented Feb 19, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
|
ae11f6f to 4efbc2cCompare4efbc2c to 7b9a6ffCompareUh oh!
There was an error while loading. Please reload this page.
Requested [here](python#31061 (comment)).
7b9a6ff to 9510c95Compare) (cherry picked from commit 2031149) Co-authored-by: Matt Bogosian <[email protected]>
) (cherry picked from commit 2031149) Co-authored-by: Matt Bogosian <[email protected]>
(cherry picked from commit 2031149) Co-authored-by: Matt Bogosian <[email protected]>
(cherry picked from commit 2031149) Co-authored-by: Matt Bogosian <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
ba8b094 to c9def58Compare
serhiy-storchaka left a comment
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 is more straightforward way to fix a conflict.
- Add
_typevar_types=(TypeVar, ParamSpec), _paramspec_tvars=Trueto the call of_ConcatenateGenericAliasin_Concatenate. - Remove
_ConcatenateGenericAlias.__initt__. - Remove a special case from
_GenericAlias.copy_with.
Also please move changes in comments and docstrings to enother PR. They distract.
Misc/NEWS.d/next/Library/2022-02-01-11-32-47.bpo-46581.t7Zw65.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot commented Mar 6, 2022
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 |
72b9e76 to 6bf1f6cCompare6bf1f6c to 6db57f5CompareLib/test/test_typing.py Outdated
| original = Callable[P, int] | ||
| self.assertEqual(original.__parameters__, (P,)) | ||
| copied = original[P] | ||
| self.assertEqual(original.__parameters__, copied.__parameters__) |
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.
Could you add some more complicated test cases? Ideas:
- The original has a
Concatenate[int, P]in it (original = Callable[Concatenate[int, P], int]; original[P].__paramaters__ == (P,)) - Instead of substituting a
Pin, substitute in aConcatenateor something like[int, T], and then theTshould be in__parameters__.
Uh oh!
There was an error while loading. Please reload this page.
| P2 = ParamSpec('P2') | ||
| C1 = Callable[P, int] | ||
| self.assertEqual(C1.__parameters__, (P,)) | ||
| self.assertEqual(C1[P2].__parameters__, (P2,)) |
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.
Only this test was failed.
Fidget-Spinner left a comment
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.
Thank you for pulling through @posita . This was a pretty tricky PR.
miss-islington commented Mar 10, 2022
Thanks @posita for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
miss-islington commented Mar 10, 2022
Sorry, @posita and @serhiy-storchaka, I could not cleanly backport this to |
posita commented Mar 10, 2022
Should I work on resolving this? |
JelleZijlstra commented Mar 10, 2022
Yes please :) Let me know if you need any help. |
posita commented Mar 11, 2022 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I would love a nudge on where to learn how to do this manually. (I'm unfamiliar with the process.) Is it as simple as resolving any conflicts against the 3.10 branch and then submitting a PR or is there more involved? |
Fidget-Spinner commented Mar 11, 2022
Yup. Submit a PR against the 3.10 and/or 3.9 branch after resolving conflicts. The bot is a little off. An easier way without installing things is to use the The other even easier alternative if you're using GitHub desktop, is to drag and drop the commit from the left panel from main into your new branch that is based off 3.10/3.9. The app will then warn you about conflicts, and you can resolve them in a code editor (this means accepting/rejecting changes or overwriting them altogether manually). |
…ythonGH-31061) (Cherry-picked from 32bf359.) pythonGH-26091 added the _typevar_types and _paramspec_tvars instance variables to _GenericAlias. However, they were not propagated consistently. This commit addresses the most prominent deficiency identified in bpo-46581 (namely their absence from _GenericAlias.copy_with), but there could be others. Co-authored-by: Ken Jin <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
bedevere-bot commented Mar 11, 2022
GH-31821 is a backport of this pull request to the 3.10 branch. |
posita commented Mar 11, 2022
Thanks @Fidget-Spinner! Cherry-picking is all good. I just didn't know if there was other repo- or CI-specific magical incantations I needed to invoke or procedures I needed to follow. Question (maybe for @JelleZijlstra): This is marked as needed a back-port to 3.10, but not to 3.9. Should this also be back-ported to 3.9? |
…H-31061) (GH-31821) (Cherry-picked from 32bf359.) GH-26091 added the _typevar_types and _paramspec_tvars instance variables to _GenericAlias. However, they were not propagated consistently. This commit addresses the most prominent deficiency identified in bpo-46581 (namely their absence from _GenericAlias.copy_with), but there could be others. Co-authored-by: Ken Jin <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Ken Jin <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
Fidget-Spinner commented Mar 11, 2022
@posita re backporting to 3.9, we don't need it as pre-3.10 ParamSpec didn't exist so we never needed these parameters then. Anyways, congrats on becoming a CPython contributor! |
posita commented Mar 11, 2022
Oh, right! Duh. Thanks all! I very much appreciate all the hand-holding. |
) (cherry picked from commit 2031149) Co-authored-by: Matt Bogosian <[email protected]>
GH-26091 added the
_typevar_typesand_paramspec_tvarsinstance variables to_GenericAlias. However, they were not propagated consistently. This commit addresses the most prominent deficiency identified in bpo-46581 (namely their absence from_GenericAlias.copy_with), but there could be others.https://bugs.python.org/issue46581