nbQA-dev / nbQA

Run ruff, isort, pyupgrade, mypy, pylint, flake8, and more on Jupyter Notebooks
https://nbqa.readthedocs.io/en/latest/index.html
MIT License
1.04k stars 41 forks source link

test_pylint_works is not passing with pylint 2.14.1 #725

Closed carlosal1015 closed 2 years ago

carlosal1015 commented 2 years ago

Hi, with recent python-pylint 2.14.1, the test test_pylint_works is not passing.

=================================== FAILURES ===================================
______________________________ test_pylint_works _______________________________
capsys = <_pytest.capture.CaptureFixture object at 0x7faf9bf989d0>
    def test_pylint_works(capsys: "CaptureFixture") -> None:
        """
        Check pylint works. Check all the warnings raised by pylint on the notebook.

        Parameters
        ----------
        capsys
            Pytest fixture to capture stdout and stderr.
        """
        # Pass one file with absolute path and the other one with relative path
        notebook1 = os.path.join("tests", "data", "notebook_for_testing.ipynb")
        notebook2 = os.path.join("tests", "data", "notebook_with_indented_magics.ipynb")

        main(["pylint", notebook1, notebook2, "--disable=C0114"])

        # check out and err
        out, _ = capsys.readouterr()

        expected_out = (
            "************* Module tests.data.notebook_for_testing\n"  # noqa: E501
            f"{notebook1}:cell_2:19:8: C0303: Trailing whitespace (trailing-whitespace)\n"  # noqa: E501
            f"{notebook1}:cell_2:15:11: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)\n"  # noqa: E501
            f'{notebook1}:cell_4:1:0: C0413: Import "from random import randint" should be placed at the top of the module (wrong-import-position)\n'  # noqa: E501
            f'{notebook1}:cell_5:1:0: C0413: Import "import pprint" should be placed at the top of the module (wrong-import-position)\n'  # noqa: E501
            f'{notebook1}:cell_5:2:0: C0413: Import "import sys" should be placed at the top of the module (wrong-import-position)\n'  # noqa: E501
            f"{notebook1}:cell_1:1:0: W0611: Unused import os (unused-import)\n"  # noqa: E501
            f"{notebook1}:cell_1:3:0: W0611: Unused import glob (unused-import)\n"  # noqa: E501
            f"{notebook1}:cell_1:5:0: W0611: Unused import nbqa (unused-import)\n"  # noqa: E501
            f"{notebook1}:cell_4:1:0: W0611: Unused randint imported from random (unused-import)\n"  # noqa: E501
            f'{notebook1}:cell_4:1:0: C0411: standard import "from random import randint" should be placed before "import nbqa" (wrong-import-order)\n'  # noqa: E501
            f'{notebook1}:cell_5:1:0: C0411: standard import "import pprint" should be placed before "import nbqa" (wrong-import-order)\n'  # noqa: E501
            f'{notebook1}:cell_5:2:0: C0411: standard import "import sys" should be placed before "import nbqa" (wrong-import-order)\n'  # noqa: E501
            "************* Module tests.data.notebook_with_indented_magics\n"  # noqa: E501
            f"{notebook2}:cell_1:1:0: W0611: Unused randint imported from random (unused-import)\n"  # noqa: E501
            f"{notebook2}:cell_1:2:0: W0611: Unused get_ipython imported from IPython (unused-import)\n"  # noqa: E501
            f'{notebook2}:cell_3:3:0: C0411: standard import "import operator" should be placed before "from IPython import get_ipython" (wrong-import-order)\n'  # noqa: E501
            "\n"
            "-----------------------------------\n"
            "Your code has been rated at 4.32/10\n"
            "\n"
        )
        horizontal_bar = "-----------------------------------"
>       assert out.split(horizontal_bar)[0] == expected_out.split(horizontal_bar)[0]
E       assert '************...d-import)\n\n' == '************...rt-order)\n\n'
E         Skipping 773 identical leading characters in diff, use -v to show
E         + pynb:cell_4:1:0: C0411: standard import "from random import randint" should be placed before "import nbqa" (wrong-import-order)
E         + tests/data/notebook_for_testing.ipynb:cell_5:1:0: C0411: standard import "import pprint" should be placed before "import nbqa" (wrong-import-order)
E         + tests/data/notebook_for_testing.ipynb:cell_5:2:0: C0411: standard import "import sys" should be placed before "import nbqa" (wrong-import-order)
E         - pynb:cell_1:1:0: W0611: Unused import os (unused-import)
E         + tests/data/notebook_for_testing.ipynb:cell_1:1:0: W0611: Unused import os (unused-import)
E         ? +++++++++++++++++++++++++++++++++
E           tests/data/notebook_for_testing.ipynb:cell_1:3:0: W0611: Unused import glob (unused-import)
E           tests/data/notebook_for_testing.ipynb:cell_1:5:0: W0611: Unused import nbqa (unused-import)
E           tests/data/notebook_for_testing.ipynb:cell_4:1:0: W0611: Unused randint imported from random (unused-import)
E         - tests/data/notebook_for_testing.ipynb:cell_4:1:0: C0411: standard import "from random import randint" should be placed before "import nbqa" (wrong-import-order)
E         - tests/data/notebook_for_testing.ipynb:cell_5:1:0: C0411: standard import "import pprint" should be placed before "import nbqa" (wrong-import-order)
E         - tests/data/notebook_for_testing.ipynb:cell_5:2:0: C0411: standard import "import sys" should be placed before "import nbqa" (wrong-import-order)
E           ************* Module tests.data.notebook_with_indented_magics
E         + tests/data/notebook_with_indented_magics.ipynb:cell_3:3:0: C0411: standard import "import operator" should be placed before "from IPython import get_ipython" (wrong-import-order)
E           tests/data/notebook_with_indented_magics.ipynb:cell_1:1:0: W0611: Unused randint imported from random (unused-import)
E           tests/data/notebook_with_indented_magics.ipynb:cell_1:2:0: W0611: Unused get_ipython imported from IPython (unused-import)
E         - tests/data/notebook_with_indented_magics.ipynb:cell_3:3:0: C0411: standard import "import operator" should be placed before "from IPython import get_ipython" (wrong-import-order)
tests/tools/test_pylint_works.py:54: AssertionError
=========================== short test summary info ============================
FAILED tests/tools/test_pylint_works.py::test_pylint_works - assert '********...
================= 1 failed, 72 passed, 27 deselected in 24.18s =================
==> ERROR: A failure occurred in check().
    Aborting...

OS: Arch Linux nbQA version: nbqa 1.3.1

Steps to reproduce

For example inside docker container.

$ docker run -it --rm registry.gitlab.com/dune-archiso/images/dune-archiso-yay
$ yay --noconfirm -Syu nbqa
MarcoGorelli commented 2 years ago

thanks @carlosal1015 for the report!

Are you interested in submitting a pull request to fix this?