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.01k stars 39 forks source link

error on python 3.8 #813

Closed sergiynesterenko90 closed 1 year ago

sergiynesterenko90 commented 1 year ago

This morning I just encountered this error:

nbqa-black...............................................................Failed
- hook id: nbqa-black
- exit code: 1

Traceback (most recent call last):
  File "/home/sergiy/.cache/pre-commit/repo8bh6v87k/py_env-python3.8/bin/nbqa", line 5, in <module>
    from nbqa.__main__ import main
  File "/home/sergiy/.cache/pre-commit/repo8bh6v87k/py_env-python3.8/lib/python3.8/site-packages/nbqa/__main__.py", line 20, in <module>
    from nbqa import replace_source, save_code_source, save_markdown_source
  File "/home/sergiy/.cache/pre-commit/repo8bh6v87k/py_env-python3.8/lib/python3.8/site-packages/nbqa/replace_source.py", line 22, in <module>
    from nbqa.save_code_source import CODE_SEPARATOR
  File "/home/sergiy/.cache/pre-commit/repo8bh6v87k/py_env-python3.8/lib/python3.8/site-packages/nbqa/save_code_source.py", line 14, in <module>
    from IPython.core.inputtransformer2 import TransformerManager
  File "/home/sergiy/.cache/pre-commit/repo8bh6v87k/py_env-python3.8/lib/python3.8/site-packages/IPython/__init__.py", line 30, in <module>
    raise ImportError(
ImportError: 
IPython 8.13+ supports Python 3.9 and above, following NEP 29.
IPython 8.0-8.12 supports Python 3.8 and above, following NEP 29.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Python 3.3 and 3.4 were supported up to IPython 6.x.
Python 3.5 was supported with IPython 7.0 to 7.9.
Python 3.6 was supported with IPython up to 7.16.
Python 3.7 was still supported with the 7.x branch.

See IPython `README.rst` file for more information:

    https://github.com/ipython/ipython/blob/main/README.rst

Running rev 1.6.4 of https://github.com/nbQA-dev/nbQA

I didn't make any changes to my environment, nor precommit version. Is there some way to fix the ipython requirement to an older version like 8.12 that still works with python 3.8?

MarcoGorelli commented 1 year ago

hey - yup, you can specify additional_dependencies and pin ipython to the version you like

sergiynesterenko90 commented 1 year ago

Thanks @MarcoGorelli - that worked! Here's a snippet in case others find themselves looking for this:

-   repo: https://github.com/nbQA-dev/nbQA
    rev: 1.6.4
    hooks:
    - id: nbqa-black
      additional_dependencies: [ipython==8.12.0, black==22.3.0]