-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption).
- Linux Mint 20.1:
- Poetry version 1.1.8:
- Link of a Gist with the contents of your pyproject.toml file:
Issue
When specifying the dependencies tensorflow and black = "*", poetry doesn't install the correct version of typing_extensions for black which causes an error when running black.
To reproduce, type in terminal:
conda create python=3.9 --name poetry-demo
conda activate poetry-demo
poetry new poetry-demo
cd poetry-demo
Edit pyproject.toml's dependency section:
[tool.poetry.dependencies]
python = "^3.8"
black = "*"
tensorflow = "2.6.0"
Now type in terminal:
poetry install
poetry run black .
The last command results in the following error:
Traceback (most recent call last):
File "/home/lukas/anaconda3/envs/poetry-demo/bin/black", line 5, in <module>
from black import patched_main
File "/home/lukas/anaconda3/envs/poetry-demo/lib/python3.9/site-packages/black/__init__.py", line 48, in <module>
from black.files import find_project_root, find_pyproject_toml, parse_pyproject_toml
File "/home/lukas/anaconda3/envs/poetry-demo/lib/python3.9/site-packages/black/files.py", line 26, in <module>
from black.handle_ipynb_magics import jupyter_dependencies_are_installed
File "/home/lukas/anaconda3/envs/poetry-demo/lib/python3.9/site-packages/black/handle_ipynb_magics.py", line 15, in <module>
from typing_extensions import TypeGuard
ImportError: cannot import name 'TypeGuard' from 'typing_extensions' (/home/lukas/anaconda3/envs/poetry-demo/lib/python3.9/site-packages/typing_extensions.py)
This happens because poetry installs black 21.9b0 and typing_extensions 3.7.4.3 although black 21.9b0 requires typing_extensions 3.10.0.0.
Workaround
This issue doesn't occur when the black version is specified to e.g. 21.7b0.
Expected behaviour
The above command sequence should fail early in poetry install instead of the cryptic error when running black. If I change the dependency in pyproject.toml to black "21.9b0", I get the expected behaviour. poetry install fails with:
SolverProblemError
Because tensorflow (2.6.0) depends on typing-extensions (>=3.7.4,<3.8.0)
and black (21.9b0) depends on typing-extensions (>=3.10.0.0), tensorflow (2.6.0) is incompatible with black (21.9b0).
So, because poetry-demo depends on both black (21.9b0) and tensorflow (2.6.0), version solving failed.
This error should also be reported in the described issue above when I specifiy black = "*".
Or even better, poetry should simply install black 21.7b0 which is compatible with the tensorflow requirement.