black: dependency_tree broken tomli<2.0.0,>=0.2.6, it should be using latest version 2.0.0

Describe the bug black 21.12b0 requires tomli<2.0.0,>=0.2.6, but you have tomli 2.0.0 which is incompatible.

To Reproduce

For example, take this code:

this = "code"

And run it with these arguments:

$ black file.py --target-version py39

The resulting error is:

cannot format file.py: INTERNAL ERROR: …

Expected behavior

Environment

  • Black’s version:
  • OS and Python version:

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 16 (7 by maintainers)

Most upvoted comments

The fact that it was fixed in main branch is not of much use for most users. This kind of issue is one of the few good reasons for fast-tracking a patch release.

We can probably allow tomli 2 (mypy did the same recently).

That’s great to hear, thank you ❤️!

Now that black is a required dependency of ipython I think it would be even more important to push a new release rather sooner than later.

BTW just out of curiosity: Do I deduce correctly from this issue that Black checks its dependency versions at runtime? Is that really necessary? Wouldn’t it be better to leave dependency checking to the installer (typically pip) and make Black use whatever versions are available? And consider issues like this an error on user/environment/installer side.

pretty sure the error here comes at installation, the $ black file.py --target-version py39 in the issue is part of the issue template

Black is fully compatible with Tomli v2 starting from this PR here https://github.com/psf/black/pull/2431/files

Also, now that I had my one (and hopefully only) chance to make breaking changes to the API, I don’t really object removing the upper pinning altogether. In case I find the need to break API in the future I’ll try to do at least a year long deprecation period before.

Note that PR https://github.com/psf/black/pull/2408 includes moving the upper pin if you are otherwise happy with the changes there.

You’ll have to downgrade your version of tomli, due to the upper bound on tomli in black