25.10.2023

Hooked on hooks

Nordic-RSE online unconference 2023

Sunniva Indrehus

25.10.2023

Hooked on hooks

🐍 + 🪝 = ✨

Nordic-RSE online unconference 2023

Sunniva Indrehus

25.10.2023
$ whoami
25.10.2023

Development speed vs. time


Figure credit: Radovan Bast

25.10.2023

Development speed vs. time


Figure credit: Radovan Bast


Figure Credit: http://memegenerator.net/

25.10.2023

Git-Hooks

  • Automate actions linked to change
  • Language independent
  • Enforce standard(s) in repository
    • Commit messages
    • Format

~/hooked-on-magic(main)$ ls -la .git/
total 56
...
drwxr-xr-x  2 sunnivin sunnivin 4096 Oct 25 11:06 hooks
...
25.10.2023

Python

  • High level programming language
  • Dynamically typed
    • Easy to use and misuse
  • Current version (25.10.23): 3.12.0


Figure credit: xkcd

25.10.2023

Our (PEP) best friends

PEP 484

  • Type annotation
    • Released 2015-09-13
  • Tool(s)

PEP 8

25.10.2023

Demo

25.10.2023

🐍 + PEPs + pre-commit = ✨

~/hooked-on-hooks$ ls -la .git/hooks
...
-rwxr-xr-x 1 sunnivin sunnivin  661 Oct 25 11:06 pre-commit
-rwxr-xr-x 1 sunnivin sunnivin 1643 Oct 25 08:24 pre-commit.sample
...
~/hooked-on-hooks/demo/$ cat pyproject.toml
...
[tool.poetry.dependencies]
python = "^3.12"


[tool.poetry.group.dev.dependencies]
pre-commit = "^3.5.0"
...

![w:450 h:325](figures/illustrations/automate-all.png) *Figure Credit: [http://memegenerator.net/](http://memegenerator.net/)*