Search code examples
pythonpython-3.xmypypython-poetry

Poetry forces use of old version of Mypy


Poetry yields the following error on request to upgrade mypy:

<your-project> depends on both mypy (^0.812) and mypy (^0.761), version solving failed

mypy v0.761 considers type specification with bracket arguments (e.g., Callable[[],Any]) to be a syntax error.

This is problematic.


How does one force poetry to use the latest version of a package, or remove poetry's belief that the old version of a package is necessary? (by comparison, pip installs the latest version)


Solution

  • I also ran into this strange issue in a Poetry project.

    What ended up resolving it for me:

    1. Delete my poetry.lock file
    2. Remove both black and mypy from my pyproject.toml
    3. Run poetry update
    4. Run poetry add mypy
    5. Run poetry add black

    Now it's successfully running the latest versions of mypy and black that were "incompatible" before.