GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing github.com — gh-82129: Provide `__annotate__` method for dataclasses from `make_dataclass` by sobolevn · Pull Request #122262 · python/cpython Conversation
|
|
Test failure: is expected, I just don't want to touch tests at this point. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
__annotate__ method for dataclasses from make_dataclass__annotate__ method for dataclasses from make_dataclass
|
I mentioned it on the issue but with this change If you want to avoid the typing import this way you need to put some placeholder for This doesn't happen on the 3.13 version proposed because dataclasses doesn't evaluate the strings so the import doesn't get called by dataclasses when it looks at the annotations. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
You might be able to get around @DavidCEllis's point by adding some internal-only flag to tell |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Perhaps you can take advantage of If it's called with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes, this is my go-to idea right now :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR still does not account for the problem mentioned by @DavidCEllis I will try to work around this problem. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
But, since cc @JelleZijlstra about my question in #122285 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Now Thanks everyone for your help and ideas! 🤝 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| def annotate_method(format): | ||
| typing = sys.modules.get("typing") | ||
| if typing is None and format == annotationlib.Format.FORWARDREF: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We could also avoid importing typing for the SOURCE format here I think; is that worth it?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we can. I need _convert_to_source, there can be complex annotations that should be formatted properly. I will open a new issue about converting annotations to string with public API though. Right now I don't see a clear way.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I opened #124412 for that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…wt3u.rst Co-authored-by: Carl Meyer <[email protected]>
There was an error while loading. Please reload this page.
|
I realized there's now new way to convert annotations to source. Fixing! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Blocked by #125507 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.