New submission from Zac Hatfield-Dodds <zac.hatfield.do...@gmail.com>:

Consider the following snippet, which passes on Python 3.9 and earlier:


    import inspect

    def f(x: int = None):
        pass

    print(inspect.signature(constructor))
    assert inspect.signature(constructor).parameters["a"].annotation == int


But under Python 3.10 (alpha 4), the annotation is instead read as 
Optional[int].  This is correct for typing.get_type_hints(), but *not* for 
inspect.signature().

I therefore suspect that this is an accidental side-effect from support for 
PEP-563 deferred evaluation of annotations.

----------
components: Library (Lib)
messages: 385524
nosy: Zac Hatfield-Dodds
priority: normal
severity: normal
status: open
title: Changed behaviour of inspect.signature() in Python 3.10
versions: Python 3.10

_______________________________________
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