Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct identification of stdlib TypeVar objs (#412)
* correct identification of stdlib TypeVar objs In Python <= 3.7, the module attribute of TypeVar constructs is always set to typing and thus irrelevant to the true origin of the construct (stdlib, third-party, user-defined). cloudpickle used to cirumvent this issue in `_whichmodule` by exhaustively search for the construct in all imported modules. This would generate false positive in the case of stdlib TypeVar constructs such as AnyStr being used by imported third-party module. For such TypeVar construct, `_whichmodule` would occasionally flag them as belonging to the third party module. This resulted in a flaky test (`test_lookup_module_and_qualname_stdlib_typevar`) where `typing.AnyStr` was occasionally marked as defined in `_pytest.capture` instead of `typing`. Co-authored-by: Olivier Grisel <olivier.grisel@gmail.com>
- Loading branch information