Profile Picture

Assorted tech

Hi, my name is Spencer. I'm a CS graduate focused on systems programming, Linux, and low-complexity design. Other interests: metal, hiking, guitar, rationality.

feed | contact

Useful Tools for Writing Python

Calendar icon February 3, 2021

Clock icon 3 min read

Folder icon #python #programming #software #poetry #django in tech

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

Comments