justinpenner / TalkingLeaves

A GlyphsApp plugin to help you explore the world’s languages and writing systems
MIT License
26 stars 2 forks source link

Add pre-commit git hooks (formatter and error checks) #17

Closed justinpenner closed 5 months ago

justinpenner commented 5 months ago

Consider adding git hooks to auto-format code upon each commit, and possibly check for other errors. This isn't something I'm very familiar with, so I'll investigate some tools like black, prettier, yapf, blue, codespell, isort, flake8.

justinpenner commented 5 months ago

Tested black, yapf, blue, codespell, isort, flake8, and more.

Result: I'm not going to implement any formatters right now. Makes sense when there are many contributors, but not for this project when it's mainly myself. The formatters make my code less readable in many instances, to the point where I have to perform many small refactors to fix it. They all use 4-space indentation, which leads to more breaks, which leads to more levels of indentation. Part of the issue is long variable names, which is Pythonic but also due to the verbosity of the pyobjc environment. I can see both sides of this, but it would take hours of customization to get a formatter to work with the current style of my code.

I'm also planning to break up TalkingLeaves.py into smaller modules soon, so we'll see how everything looks after that major refactoring. Maybe then, something like black might work better.

Some of the formatting techniques and error checks were helpful, though, and I will implement them in my own coding going forward. For example: