Boring Python: Code Quality

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • ruff

    An extremely fast Python linter and code formatter, written in Rust.

  • If you aren’t happy with Flake8, Pylint, and isort (or maybe if you are!), I recommend checking out Ruff:

    https://github.com/charliermarsh/ruff

    It’s literally 100 times faster, with comparable coverage to Flake8 plus dozens of plugins, automatic fixes, and very active development.

  • pre-commit

    A framework for managing and maintaining multi-language pre-commit hooks.

  • Install pre-commit: https://pre-commit.com/

    Set black up in the pre-commit with a specific version. When you make a commit it will black the files being committed using the specific version of black. As it's a subset, it's fast. As it's a specific version, it's not going back and forth.

    I hope this solves your issues.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • ccache

    ccache – a fast compiler cache

  • > All those big changes introduce commits that make git bisect generally slower.

    Bisection search is log2(n) so doubling the number of commits should only add one more bisection step, yes?

    > Which might be awful if you also have some C code to recompile at every step of bisecting.

    That reminds me, I've got to try out ccache (https://ccache.dev/ ) for my project. My full compile is one minute, but the three files that take longest to compiler rarely change.

  • reorder-python-imports

    Rewrites source to reorder python imports

  • Two developers on the same python project should also use the same version... with poetry it is straightforward to keep track of dev dependencies. Reorder python imports is an alternative for isort: https://github.com/asottile/reorder_python_imports

  • cookiecutter-hypermodern-python

    Hypermodern Python Cookiecutter

  • There is also a 'hypermodern' cookie cutter template for python projects - I've used it several times now and it works mostly out of the box:

    https://github.com/cjolowicz/cookiecutter-hypermodern-python

  • django-stubs

    PEP-484 stubs for Django

  • You can annotate the manager and get some typing help in the editor. And there’s django-stubs which helps a little when running mypy. It’s not as good as pycharm though.

    https://github.com/typeddjango/django-stubs/tree/master

  • mutmut

    Mutation testing system

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • Poetry

    Python packaging and dependency management made easy

  • I switched because it felt way to heavy for porting scripts and small applications to constrained devices like a Raspberry Pi.

    And then there are also Docker Images, which I use if I want to give an application to somebody that "just works".

    What's your method of choice?

    [0] https://python-poetry.org/

    [1] https://www.anaconda.com/

  • pyenv

    Simple Python version management

  • > So a project with 2 developers, one running arch and one running ubuntu, will get formatted back and forth.

    You should never develop using the system Python interpreter. I recommend pyenv [0] to manage the installed interpreters, with a virtual environment for the actual dependencies.

    [0] https://github.com/pyenv/pyenv

  • PDM

    A modern Python package and dependency manager supporting the latest PEP standards

  • I'm liking PDM for a while now. Quicker than Poetry and built according to the Python package spec in mind and not as an afterthought. While it was originally meant to work with PEP 582, it works with virtual environments too (now default).

    https://github.com/pdm-project/pdm

  • typeguard

    Run-time type checker for Python

  • I got good use of the run-time type checking of typeguard [0] when I recently invoked it via its pytest plugin [2]. For all code visited in the test suite, you get a failing test whenever an actual type differs from an annotated type.

    [0]: https://github.com/agronholm/typeguard/

    [1]: https://typeguard.readthedocs.io/en/latest/userguide.html#us...

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts