I’ve chosen Poetry to manage the dependencies of my last project because it was new, powerful and had good feedback on it.
Still, with the early versions I’ve used, I faced some problems: link problems on Windows, bad memory management, and poor documentation…
Some were solved.
But here are some of the lessons and feedback I’ve from my first experience with Poetry.
It Doesn’t Remove Old Dependencies Automatically
When removing a dependency from the project, I need to run:
poetry remove <dependency>
That’s easy.
And in my virtual environment, it removes the library. But when sharing the poetry.lock and pyproject.toml with the rest of the team, a simple poetry install won’t remove the dependency.
They need to run:
poetry install --sync
to remove the missing dependency. What this isn’t done by default?
Upgrading Python May Break Poetry
To install poetry, it uses the current python version to create some links. I don’t know where.
I’m not talking about installing it from pip. This is a very bad practice.
But it can break those links when upgrading the Python version of my system.
I use pyenv to manage the Python versions. But some critical updates of my system update the root version of Python in my system.
Each time this occurs, I must reinstall poetry. Still, there is no impact on the projects.
The Plugin In PyCharm Doesn’t Work
As a PyCharm user, I tried the Poetry plugin.
But the plugin was unable to detect the virtual environment. It was unable to run the application, scripts or unit tests in the environment.
This makes the plugin useless.
Instead, I’ve used the virtualenv plugin which works fine. I have to link the Poetry environment folder of my project, and that’s all.
Not All The pre-commits Are Available In Poetry
I use some pre-commits with my Python projects: isort, black, mypy and flake8.
I can configure isort, black and mypy inside the pyproject.toml file. This way, I avoid having many configuration files. I only need the pyproject.toml file.
But flake8 isn’t yet aligned with Poetry. I still need an extra file to configure it.
If Something Doesn’t Work…
A missing library. Incorrect version of a library. Missing links…
The fastest solution: remove the virtual environment and start again.
It’s easy and quick. And most of the time it solved my problems.
Starting again from a clean environment is very easy.
Conclusion
What’s for sure, I will use Poetry for the following projects. I see new interesting features coming and new integrations.
If you want more details about the usage of Poetry, check my video here.
And if you want to learn more about good quality code, make sure to follow me on Youtube.



Leave a comment