DEV Community

Aleksei Aleinikov
Aleksei Aleinikov

Posted on

πŸš€ Tired of Fixing Comment Style in Code Reviews? Automate It!

πŸ” Problem:
Comment style issues slow down code reviews. Missing spaces, bad capitalization, or empty # commentsβ€”why waste time on that?
πŸ’‘ Solution:
Use pre-commit to automate comment checks in Python! It ensures:
βœ… Correct spacing after #
βœ… Proper capitalization in comments
βœ… No empty or redundant comments
⚑ How to Set It Up?
πŸ“Œ Install pre-commit:

pip install pre-commit

Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Add this to .pre-commit-config.yaml:

- repo: http://gitlab.com/krash/python-checker
  rev: v0.0.7
  hooks:
    - id: python-check

Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Enable it:

pre-commit install

Enter fullscreen mode Exit fullscreen mode

Now, every commit automatically checks your comment style before pushing!
πŸ”— Read more + full guide πŸ‘‰ https://medium.com/pythoneers/automate-python-comment-checks-with-pre-commit-1373220e5286

Top comments (0)