How to detect desynchronized pyproject.toml with poetry.lock?

Poetry installs the dependencies from the lock file. If it's not synchronized with the pyproject.toml, the poetry install can use out-of-dated dependencies. To ensure both files are synchronized, you can run the poetry check --lock. In case of an inconsistency, it will return a failure and a message similar to:

$ poetry check --lock

Error: pyproject.toml changed significantly since poetry.lock was last generated. Run `poetry lock` to fix the lock file.