]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46571: improve `typing.no_type_check` to skip foreign objects (GH-31042)
authorNikita Sobolev <mail@sobolevn.me>
Sat, 19 Feb 2022 01:53:29 +0000 (04:53 +0300)
committerGitHub <noreply@github.com>
Sat, 19 Feb 2022 01:53:29 +0000 (17:53 -0800)
commit395029b0bd343648b4da8044c7509672ea768775
treecdbf8b86c5bead4d8315c100a7f732f92902b817
parentf80a97b492f41afd3c42bb2bd6da7b2828dca215
bpo-46571: improve `typing.no_type_check` to skip foreign objects (GH-31042)

There are several changes:
1. We now don't explicitly check for any base / sub types, because new name check covers it
2. I've also checked that `no_type_check` do not modify foreign functions. It was the same as with `type`s
3. I've also covered `except TypeError` in `no_type_check` with a simple test case, it was not covered at all
4. I also felt like adding `lambda` test is a good idea: because `lambda` is a bit of both in class bodies: a function and an assignment

<!-- issue-number: [bpo-46571](https://bugs.python.org/issue46571) -->
https://bugs.python.org/issue46571
<!-- /issue-number -->
Doc/library/typing.rst
Lib/test/ann_module8.py [new file with mode: 0644]
Lib/test/test_typing.py
Lib/typing.py
Misc/NEWS.d/next/Library/2022-02-01-11-21-34.bpo-46571.L40xUJ.rst [new file with mode: 0644]