
Will do. On Mon, 2021-01-11 at 20:55 -0800, Guido van Rossum wrote:
On Mon, Jan 11, 2021 at 3:51 PM Larry Hastings <larry@hastings.org> wrote:
This passage in PEP 563 appears not true in Python 3.9 with __future__ annotations, emphasis mine:
The get_type_hints() function automatically resolves the correct value of globalns for functions and classes. It also automatically provides the correct localns for classes.
If this passage was true, I believe the issue that resulted in my affixing type hints could have been averted. As you've discovered, this is one of the places where PEP 563 seems to be out-of-date with respect to its implementation. I sifted
[...] through the source code to typing.get_type_hints() twice, and near as I can figure out, localns is literally only ever set to None unless you override it with the parameter.
This seems to be a bug in get_type_hints() for which someone should file a bug on bpo, please!