Ken Jin <kenjin4...@gmail.com> added the comment:

For anyone interested, I went to do some digging on the 3 issues Zac listed:

1. Similar to the first message, this is caused by inspect.getfullarg/signature 
using get_type_hints in Py 3.10. get_type_hints internally converts None to 
NoneType.

2. I don't know what's causing that TypeDict signature to fail.

3. I'm not too sure, but maybe this is intentional according to 
https://www.python.org/dev/peps/pep-0563/#keeping-the-ability-to-use-function-local-state-when-defining-annotations
 ? You can fix it by passing in locals() to get_type_hints (this should work 
all the way back to 3.6)::

import typing

def f():
    A = typing.TypeVar("A")
    def same_type_args(a: A, b: A):
        assert type(a) == type(b)
    print(typing.get_type_hints(same_type_args, localns=locals()))

>>> f()
{'a': ~A, 'b': ~A}

The whatsnew should probably be updated to mention this, this is a backwards 
incompatible change after all.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43006>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to