Title: get_type_hints does not provide localns for classes
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, kj, larry, pbryan
Priority: normal Keywords: patch

Created on 2021-01-12 05:00 by pbryan, last changed 2021-01-12 15:22 by kj.

Pull Requests
URL Status Linked Edit
PR 24201 open kj, 2021-01-12 15:22
Messages (4)
msg384885 - (view) Author: Paul Bryan (pbryan) * Date: 2021-01-12 05:00
According to PEP 563:

> 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.

This statement about providing correct localns for classes does not appear to be true.

Guido suggested this should be treated as a bug.
msg384887 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-01-12 05:12
Fidget-Spinner, are you interested in taking this?
msg384888 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-01-12 05:13
It's apparently a bug in all versions that support `from __future__ import annotations` (and only when that is used). Though perhaps we should only fix in in 3.10.
msg384925 - (view) Author: Ken Jin (kj) * Date: 2021-01-12 12:33
> Fidget-Spinner, are you interested in taking this?

Sure thing! Please give me some time to look at it - I don't really use the runtime type validation stuff from typing (I usually defer that to 3rd party libraries), so I need to familiarize myself first.
Date User Action Args
2021-01-12 15:22:13kjsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23026
2021-01-12 12:33:43kjsetnosy: + kj
messages: + msg384925
2021-01-12 05:13:26gvanrossumsetmessages: + msg384888
2021-01-12 05:12:27gvanrossumsetmessages: + msg384887
2021-01-12 05:00:58pbryansetnosy: + larry
2021-01-12 05:00:15pbryancreate