Introduction
I’ve been writing Python for a long time now. Here are some tools I’ve found to be more productive along the way.
Poetry
If you use Pipenv, Pip, or Virtualenv to manage your projects, I highly recommend you switch to Python Poetry. Poetry manages your virtual environments and dependencies on a per-project basis that yield reproducible builds. It is similar to Pipenv but has a few advantages:
Poetry is a great way to install some of the other tools on this list as development dependencies with poetry add -D [name]
.
Mypy
Since I’ve been writing Rust, I have missed static type-checking in Python. It can catch a lot of errors before they happen. Mypy is a way to actually do something useful with the type annotations in Python.
Flake8
Unlike many languages, Python has an official style guide (please use it).
Flake8 is your guide to achieving PEP-8 compliance.
When you run flake8
, it will point out where there are style issues.
If you don’t agree with some rules or find them a hinderance like I do, you can put a file called .flake8
in your project root to disable them:
[flake8]
ignore = E402, E501
isort
Organized import statements can also make your code look better.
I use isort in pretty much all of my Python projects.
Just run isort .
and it’ll sort your imports, it’s easy.
Bandit
Bandit is made by the same group as isort. It checks your codebase for common security issues. Bandit checks for many types of security errors, including this made using Django and Flask. Running a single command is a small price for some peace of mind.
Gitignore.io
This one is a website, not a program.
It’s an easy way to generate .gitignore
files so that you don’t commit files that no one else cares about (or maybe too much about, such as private keys and passwords).
Just type in the languages, frameworks, libraries, editors you use and it will generate a nice .gitignore
for you.
Other Things Your Project Should Have
- A
README.md
with project info, installation instructions, setup notes, etc. - A
LICENSE.md
, lack of a license means that users do not have permission to use, share, or modify your code (I like ISC). - A
.gitignore
, some things should not be commited. Check out gitignore.io to generate one.
Comments