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 raised on Python 3.11 #811

Closed JeppeKlitgaard closed 1 year ago

JeppeKlitgaard commented 1 year ago

Due to https://github.com/hhatto/autopep8/issues/581 nbQA currently gives the following when run in Python 3.11 environments:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 4570, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 4528, in main
    results = fix_multiple_files(args.files, args, sys.stdout)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 4423, in fix_multiple_files
    ret = _fix_file((name, options, output))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 4393, in _fix_file
    return fix_file(*parameters)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 3579, in fix_file
    original_source = readlines_from_file(filename)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 195, in readlines_from_file
    with open_with_encoding(filename) as input_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 172, in open_with_encoding
    encoding = detect_encoding(filename, limit_byte_check=limit_byte_check)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeppe/JaxIsingModel/.venv/lib/python3.11/site-packages/autopep8.py", line 182, in detect_encoding
    from lib2to3.pgen2 import tokenize as lib2to3_tokenize
ModuleNotFoundError: No module named 'lib2to3'

This is an upstream bug, but thought it might be nice to track it here as well

MarcoGorelli commented 1 year ago

thanks for the report!

MarcoGorelli commented 1 year ago

sounds like this is an upstream bug? closing then