| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… like annotationlib With string annotations, dataclasses looks up the first name of each annotation to detect ClassVar, InitVar and KW_ONLY. If that name was a lazy import that could not be resolved, the lookup raised and the class could not be created, while the same class works with non-string annotations. This resolves lazy imports the way annotationlib does: try to resolve them, and treat a failure like a missing name.
|
Thanks @brittanyrey for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
Sorry, something went wrong.
|
GH-158946 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Before this change, dataclasses would handle the failure case for lazily imported annotations differently based on if that annotation was materialized as a string or an object. For objects, imports that could not be materialized were ignored, but for strings the errors would bubble up and completely prevent the initialization of the dataclass.
After this change, string annotations will resolve lazy imports the same way that annotationlib does: try to resolve them, and treat a failure as a missing annotation.