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-commitpip install pre-commitpip install pre-commit
Enter fullscreen mode Exit fullscreen mode
Add this to .pre-commit-config.yaml:
- repo: http://gitlab.com/krash/python-checkerrev: v0.0.7hooks:- id: python-check- repo: http://gitlab.com/krash/python-checker rev: v0.0.7 hooks: - id: python-check- 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 installpre-commit installpre-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
原文链接: Tired of Fixing Comment Style in Code Reviews? Automate It!
暂无评论内容