This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author n_rosenstein
Recipients BTaskaya, eric.smith, gvanrossum, joperez, kj, levkivskyi, lukasz.langa, miss-islington, n_rosenstein
Date 2022-01-25.18:17:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643134652.88.0.707515310503.issue41370@roundup.psfhosted.org>
In-reply-to
Content
Guido, sorry for the late response on this. I have a work around, but it involves passing along my own "context" from which to resolve strings on the go as they are encountered while decomposing the type hint.

https://github.com/NiklasRosenstein/databind/commit/960da61149b7139ec81b0e49d407fae321581914

I'm using `typing.get_type_hints()` expecting it to fully resolve all forward references, but that no longer happens with PEP 585 generics. 

https://github.com/NiklasRosenstein/databind/blob/960da61149b7139ec81b0e49d407fae321581914/databind.core/src/databind/core/types/utils.py#L129-L138

I understand the documentation has been updated to reflect this behaviour, but it was an issue for me because it broke it's original API contract.

> In addition, forward references encoded as string literals are handled by evaluating them in globals and locals namespaces.

Arguably the same has happened when `include_extras` was added (Annotated was now stripped from the returned resolved type hints by default), but that had an easy fix by simply wrapping it with `include_extra=True` depending on the Python version. The fix for the forward references in PEP 585 was not so trivial because we can't hook into what `get_type_hints()` does when it encounters a string.
History
Date User Action Args
2022-01-25 18:17:32n_rosensteinsetrecipients: + n_rosenstein, gvanrossum, eric.smith, lukasz.langa, levkivskyi, miss-islington, BTaskaya, joperez, kj
2022-01-25 18:17:32n_rosensteinsetmessageid: <1643134652.88.0.707515310503.issue41370@roundup.psfhosted.org>
2022-01-25 18:17:32n_rosensteinlinkissue41370 messages
2022-01-25 18:17:32n_rosensteincreate