You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
some way to skip replacing mock with unittest.mock #314
when you're using python 3.6 or 3.7 unittest.mock.AsyncMock is unavailable, but mock.AsyncMock is available if you're using the latest backport
there should be some way to skip replacing mock with unittest.mock, or the fixer should be moved to --py38-plus and then to a later --py...-plus as and when unittest.mock gains features
Reacted by Felipe S. S. Schneider, Marjeta and Edgar Ramírez Mondragón
I suppose we could hardcode of a list of unittest.mock attrs and the version they were added into unittest.mock, and rewrite conditionally based on that
only this case because there's a good reason to keep it (%-rewrite could break python2 in some exotic scenarios) -- unless we can actually detect it properly and then we don't need an option
Activity
asottile commentedon May 26, 2020
@mxr ^ thoughts
mxr commentedon May 26, 2020
I suppose we could hardcode of a list of
unittest.mockattrs and the version they were added intounittest.mock, and rewrite conditionally based on thatasottile commentedon May 26, 2020
maybe
--no-mockis easier, idkmxr commentedon May 26, 2020
But would you want
--no-xxfor suppressing an arbitrary rewrite? If not, why this specific case?asottile commentedon May 26, 2020
only this case because there's a good reason to keep it (%-rewrite could break python2 in some exotic scenarios) -- unless we can actually detect it properly and then we don't need an option
mxr commentedon May 26, 2020
It should be possible to detect it properly using the approach I outlined
graingert commentedon May 26, 2020
also mock.patch behaves differently (on 3.6/3.7 Vs pypi mock/3.8) when applied to a coroutinefunction
graingert commentedon May 26, 2020
Also I don't like an autodetect because I don't want some project files using unittest.mock and others using mock
graingert commentedon May 26, 2020
thirdly how should other backports be handled? eg functools32 contextlib2 pkg_util_resolve_name etc?
mxr commentedon May 27, 2020
Good points, sounds like
--no-mockis the best approach for now