Keep Your Code Clean Using pre-commit with Anthony Sottile - Episode 178

Summary

Maintaining the health and well-being of your software is a never-ending responsibility. Automating away as much of it as possible makes that challenge more achievable. In this episode Anthony Sottile describes his work on the pre-commit framework to simplify the process of writing and distributing functions to make sure that you only commit code that meets your definition of clean. He explains how it supports tools and repositories written in multiple languages, enforces team standards, and how you can start using it today to ship better software.

linode-banner-sponsor-largeDo you want to try out some of the tools and applications that you heard about on Podcast.__init__? Do you have a side project that you want to share with the world? Check out Linode at linode.com/podcastinit or use the code podcastinit2018 and get a $20 credit to try out their fast and reliable Linux virtual servers. They’ve got lightning fast networking and SSD servers with plenty of power and storage to run whatever you want to experiment on.


Preface

  • Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great.
  • When you’re ready to launch your next app you’ll need somewhere to deploy it, so check out Linode. With private networking, shared block storage, node balancers, and a 40Gbit network, all controlled by a brand new API you’ve got everything you need to scale up. Go to podcastinit.com/linode to get a $20 credit and launch a new server in under a minute.
  • Visit the site to subscribe to the show, sign up for the newsletter, and read the show notes. And if you have any questions, comments, or suggestions I would love to hear them. You can reach me on Twitter at @Podcast__init__ or email [email protected])
  • To help other people find the show please leave a review on iTunes, or Google Play Music, tell your friends and co-workers, and share it on social media.
  • Join the community in the new Zulip chat workspace at podcastinit.com/chat
  • Your host as usual is Tobias Macey and today I’m interviewing Anthony Sottile about pre-commit, a framework for managing and maintaining hooks for multiple languages

Interview

  • Introductions
  • How did you get introduced to Python?
  • Can you start by describing what a pre-commit hook is and some of the ways that they are useful for developers?
  • What was you motivation for creating a framework to manage your pre-commit hooks?
    • How does it differ from other projects built to manage these hooks?
  • What are the steps for getting someone started with pre-commit in a new project?
  • Which other event hooks would be most useful to implement for maintaining the health of a repository?
  • What types of operations are most useful for ensuring the health of a project?
  • What types of routines should be avoided as a pre-commit step?
  • Installing the hooks into a user’s local environment is a manual step, so how do you ensure that all of your developers are using the configured hooks?
    • What factors have you found that lead to developers skipping or disabling hooks?
  • How is pre-commit implemented and how has that design evolved from when you first started?
    • What have been the most difficult aspects of supporting multiple languages and package managers?
    • What would you do differently if you started over today?
    • Would you still use Python?
  • For someone who wants to write a plugin for pre-commit, what are the steps involved?
  • What are some of the strangest or most unusual uses of pre-commit hooks that you have seen?
  • What are your plans for the future of pre-commit?

Keep In Touch

Picks

Links

The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA

Start the discussion at https://discourse.pythonpodcast.com