Invoke: DeprecationWarning on usage of imp in loader.py

Created on 10 Oct 2019  路  2Comments  路  Source: pyinvoke/invoke

When running my test suite which uses invoke (via fabric) I see:

======================= warnings summary ========================
venv/lib64/python3.7/site-packages/invoke/loader.py:3
  venv/lib64/python3.7/site-packages/invoke/loader.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import imp

-- Docs: https://docs.pytest.org/en/latest/warnings.html
========== 6 passed, 1 warnings in 1651.00s (0:27:30) ===========

The used parts of the imp module have been deprecated since Python 3.3 and the replacement importlib has been available since Python 3.1.

Most helpful comment

I have also spotted this - the question is really: which versions of python is invoke committed to supporting? The docs say 2.7 and >=3.4. However, we have now passed 2020-01-01, so the sun has officially gone down on python 2. If I had a vote (which I don't obviously), it would be to drop support for 2.7 and switch this code to importlib

Instead I'm adding a warning filter (https://docs.pytest.org/en/latest/warnings.html#pytest-mark-filterwarnings) and have logged an issue on our project.

All 2 comments

For what it's worth, there's a workaround that will suppress that one particular warning. I use it on pytest but I believe it's going to be mostly the same with other test frameworks:

-W ignore::DeprecationWarning:invoke.loader

I have also spotted this - the question is really: which versions of python is invoke committed to supporting? The docs say 2.7 and >=3.4. However, we have now passed 2020-01-01, so the sun has officially gone down on python 2. If I had a vote (which I don't obviously), it would be to drop support for 2.7 and switch this code to importlib

Instead I'm adding a warning filter (https://docs.pytest.org/en/latest/warnings.html#pytest-mark-filterwarnings) and have logged an issue on our project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NathanUrwin picture NathanUrwin  路  5Comments

juanAFernandez picture juanAFernandez  路  4Comments

MinchinWeb picture MinchinWeb  路  10Comments

lukeorland picture lukeorland  路  7Comments

Zeioth picture Zeioth  路  5Comments