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 1ace
Recipients 1ace
Date 2021-03-01.16:01:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614614520.28.0.353733927276.issue43355@roundup.psfhosted.org>
In-reply-to
Content
We have a pytest that boils down to the following:

```
#from __future__ import annotations
from inspect import Parameter, signature


def foo(x: str) -> str:
    return x + x


def test_foo():
    expected = (
        Parameter("x", Parameter.POSITIONAL_OR_KEYWORD, annotation=str),
    )

    actual = tuple(signature(foo).parameters.values())

    assert expected == actual
```

(execute with `pip install pytest && pytest -vv test_foo.py`)

I tried importing 3.10 annotations (so that we can get rid of quotes around the class containing `foo()`, which is omitted here because it isn't necessary to reproduce the bug), but doing so changes the output of `inspect.signature()` but not the output `inspect.Parameter()`, causing a mismatch between the two that breaks the test.

The above passes on 3.7.9, 3.8.7 & 3.9.1, and if I uncomment the first line, it fails on those same versions.
As can be expected, the annotations import is a no-op on 3.10.0a5 and the test passes either way.

I expect `inspect` might have not been correctly updated to support postponed annotations, but I haven't looked at the implementation (I'm not familiar with the CPython codebase at all) so it's just a guess.
History
Date User Action Args
2021-03-01 16:02:001acesetrecipients: + 1ace
2021-03-01 16:02:001acesetmessageid: <1614614520.28.0.353733927276.issue43355@roundup.psfhosted.org>
2021-03-01 16:02:001acelinkissue43355 messages
2021-03-01 16:01:591acecreate