question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

black being pinned to an older version causes a crash

See original GitHub issue

There was a breaking change recently in the click library which is a dependency in black. black has updated the dependency version and released a new version, however because black is pinned to an older version, this fix isn’t getting propagated. For the moment, we can workaround this by pinning click to an older version, but I think nbqa-black itself can fix this by moving to the newest black version.

I checked the commit that introduced the version pin, but I couldn’t figure out the reason for doing so.

Refer to the upstream issue for more details.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dnolivercommented, Aug 19, 2022

Hi, run into an issue while testing nbqa black for the first time today. Want to check first if it is related to this one.

I was trying to run this tools against a notebook I have, my setup is a windows laptop with docker, and I pulled python:3.6 from dockerhub, started an interactive container with my code mounted as a volume.

Then, created a virtual environment and installed nbqa as:

python3.6 -m venv .venv
python3.6 -m pip install -U nbqa
nbqa black tiny_yolo_v3.ipynb
python3.6 -m pip install black

In line 3 above, nbqa complained that the “black” command was not found. I thought those tools described in https://nbqa.readthedocs.io/en/latest/examples.html came pre-packaged with nbqa 😃, so I installed black with pip. Then trying to run it, gave me this error (the traces are shortened):

(.venv) root@347d11468761:~/tiny-yolo-v3-python# nbqa black tiny_yolo_v3.ipynb
Traceback (most recent call last):
  File "/tiny-yolo-v3-python/.venv/bin/nbqa", line 11, in <module>
    sys.exit(main())
  File "/tiny-yolo-v3-python/.venv/lib/python3.6/site-packages/nbqa/__main__.py", 
line 708, in main
    return _main(cli_args, configs)
  File "/tiny-yolo-v3-python/.venv/lib/python3.6/site-packages/nbqa/__main__.py", 
line 614, in _main
    for key, i in nb_to_tmp_mapping.items()
  File "/tiny-yolo-v3-python/.venv/lib/python3.6/site-packages/nbqa/__main__.py", 
line 267, in _run_command
    env=my_env,
  File "/usr/local/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'

And my black version was:

(.venv) root@347d11468761:~//tiny-yolo-v3-python# black --version
black, 22.6.0 (compiled: no)
Python (CPython) 3.6.15
(.venv)

~I will try to install black 22.3.0 and run again~ Same error with black==22.3.0

UPDATE: my bad, this error is related to Python 3.6. https://stackoverflow.com/a/53209196 explains the reason.

Using a python:3.7 as the container image, got the thing working:

nbqa black tiny_yolo_v3.ipynb
reformatted tiny_yolo_v3.ipynb

All done! ✨ 🍰 ✨
1 file reformatted
2reactions
s-weigandcommented, Apr 5, 2022

@chamilad black fixed this issue by now. The hook from nbqa does not pin the back version https://github.com/nbQA-dev/nbQA/blob/b77ee1424b4ef11878c99ebd8a701ed442fa0aa8/.pre-commit-hooks.yaml#L8-L15 But pre-commit caches the venvs it uses to run the hooks based on the values in your config. Your problem most likely is that the cached venv uses a broken combination of back and click (also had this issue lately). You could just pin the version of black==22.3.0 in the additional_dependencies section of your pre-commit-config.yaml, which would create a new venv due to the changed config. Alternatively, if black isn’t pinned in your config you can run pre-commit clean which will delete all cached venvs.

@MarcoGorelli The possibility to create such a broken venv with the default nbqa hook was less than 1 day (breaking click release, fixing black release). The only possibility to end up with a broken pre-commit config now is if users pin an older black version in their additional_dependencies, in which case there is nothing that could be done from the side of nbqa since the hooks additional_dependencies section will be overwritten. Maybe just rename this issue and pin it for a month or so?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recurring Crash to Black Screen - Microsoft Community
Symptoms : I have crash that occurs pretty frequently on my machine. When it occurs the screen goes almost completely black, filling with ......
Read more >
[Solved] Kernel Power 41 Critical Error on Windows 11/10
Mostly, the Kernel-Power 41 error is caused by the wrong device drivers on your computer, especially an old or corrupted sound card driver....
Read more >
5700 xt black screen crash !!! - AMD Community
First, the screens goes black , then keyboard and mouse goes off , but pc still running but freezed , i have to...
Read more >
Here's Why Windows 10 Crashes On Lenovo Laptops
Microsoft has discovered the source of a mysterious bug that is causing Windows 10 to hang on Lenovo laptops.
Read more >
Latest Troubleshooting FAQ (1.0.8.3) :: Distant Worlds 2 Tech ...
If you cannot get the game working with the latest version, there is the option of going back to the previous Legacy branches...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found