I recently had an opportunity to review some tooling for Python, and I thought I'd share some of my learnings.
pyproject.toml
This fancy new file is the replacement for setup.py
and setup.cfg
originally specified in PEP 518 (https://www.python.org/dev/peps/pep-0518/).
Simple and clean explanation, right? Well, no, not really.
Since its release, it's now the exclusive way to configure black
for a project. Additional tools like poetry
(somewhat of a pipenv
competitor) and flit
(a tool to make packaging and publishing to PyPI easier) have come out to also exclusively use pyproject.toml
as their configuration file.
It's clear from the PEP that this was the intended consequence for other tools to use pyproject.toml
. However, it seems to only have really touched brand new projects. Older, mature packages seem to still primarily be using setup.cfg
for their tooling configs in their CI process.
I generally tend to adopt new trends like these in my projects, but in my existing packages I admit not seeing a whole lot of value presently in ripping out my setup.py
and setup.cfg
just for fun.
flake8
I used pylint for a very long time while at Worthwhile and began using flake8 at Peerfit. I really had no opinion of one over the other.
However, I can say now that holy crap does flake8 have so much stuff.
It wraps pyflakes, pycodestyle, and mccabe. Additionally, it's just got so many plugins: flake8-bugbear, flake8-import-order, flake8-print, etc (https://github.com/DmytroLitvinov/awesome-flake8-extensions).This rich ecosystem simply doesn't seem to exist for pylint.
Finally, a lot of major projects seems to use flake8, so the user base is consistent and mature:
- Django (https://github.com/django/django/blob/master/setup.cfg#L5)
- flask (https://github.com/pallets/flask/blob/master/setup.cfg#L22)
- even freaking youtube-dl (https://github.com/ytdl-org/youtube-dl/blob/master/setup.cfg)
So this has sold me on using flake8 for the foreseeable future.
Top comments (5)
You might also like wemake-python-styleguide which is the strictest python linter ever.
wemake-services / wemake-python-styleguide
The strictest and most opinionated python linter ever!
wemake-python-styleguide
Welcome to the strictest and most opinionated python linter ever.
wemake-python-styleguide
is actually a flake8 plugin with some other plugins as dependencies.Quickstart
You will also need to create a
setup.cfg
file with the configuration.We highly recommend to also use:
Running
This app is still just good old
flake8
And it won't change your existing workflow.See "Usage" section in the docs for examples and integrations.
What we are about
The ultimate goal of this project is to make all people write exactly the same
python
code.@sobolevn , sweet! Always interested in tooling!
Sadly, flake8 does not support pyproject.toml yet
I have recently grown familiar with FlakeHell, a wrapper around Flake8 that, among other things, allows configuration of Flake8 through
pyproject.toml
.@raiderrobert , I love your article; it provided me a basic intro to flake8 when I needed it. Thank you!
@laike9m , relevant to that point, here's the Gitlab ticket where that feature is being tracked: gitlab.com/pycqa/flake8/issues/428