-
-
Notifications
You must be signed in to change notification settings - Fork 35k
bpo-38431: fix dataclasses.InitVar.__repr__ #16700
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2883,6 +2883,11 @@ class C: | |
| # x is not an InitVar, so there will be a member x. | ||
| self.assertEqual(C(10).x, 10) | ||
|
|
||
| def test_initvar_repr(self): | ||
| self.assertEqual(repr(InitVar[str]), 'dataclasses.InitVar[str]') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already a test for |
||
| self.assertEqual(repr(InitVar[Optional[str]]), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think optional does make sense, but I can change it if you like. |
||
| 'dataclasses.InitVar[typing.Union[str, NoneType]]') | ||
|
|
||
| def test_classvar_module_level_import(self): | ||
| from test import dataclass_module_1 | ||
| from test import dataclass_module_1_str | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Fix ``__repr__`` method for ``dataclasses.InitVar`` to work with typing | ||
| objects. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add "Patch by ...".
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume these comments also apply to #16702 I'm not sure what you mean here, could you elaborate?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding "patch by " at end of file for credit since this is added to changelog.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, it's "patch by full name." as additional sentence for credit. GitHub removed my content with tags <>
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait, you mean Or perhaps you're confused since you're commenting on the wrong PR? should be #16702
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just a bit confused since that format isn't used in any other news entries as far as I can tell.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I answered here since it had the question initially :) The news entry would be as below for other PR. Sorry for the confusion due to markdown rendering.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, that's pretty much what I have in the other PR. Is there still something to change?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing else, I added the verbatim version since patch by would be a separate sentence and not in past tense as above for most cases. But I will leave it to the core dev who is merging to take care of wording and not pedantic about it. Thanks for the changes. https://devguide.python.org/committing/#handling-others-code and has an example of the format widely used. |
||
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.
Functions have the
__name__attribute. I suggest to useisinstance(self.type, type).