Uh oh!
There was an error while loading. Please reload this page.
bpo-46581: Propagate private vars via _GenericAlias.copy_with - #31061
Conversation
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
ae11f6fCompare
|
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 <eb3f73+github+com@yaymail.com>
) (cherry picked from commit 2031149) Co-authored-by: Matt Bogosian <eb3f73+github+com@yaymail.com>
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.
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.
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
6db57f5Compare| 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.
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.
Only this test was failed.
Fidget-Spinner
left a comment
There was a problem hiding this comment.
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. |
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 <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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 <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
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 <eb3f73+github+com@yaymail.com>
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