Commit c68f41f
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 <[email protected]>1 parent fb83b83 commit c68f41f
1 file changed
+8
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
| |||
0 commit comments