Code Review For Python Developers

You don't rise to your dreams, you fall to the level of your code-reviews

Photo by Claudia Bachinger on Unsplash

Python Guide 

General

  • The scope of PR should be simple, unique and well-defined. PR should not contain unrelated changes

  • Approve PR only if you are sure about the scope 

  • Be respectful and reply asap

  • Do not merge PR without approval

  • Avoid spending too much time on trivial changes

  • Avoid premature optimisation

  • Suggest changes and check back ASAP. Get PR merged soon

  • For new features, suggest adding appropriate documentation

  • Don’t forget to praise when PR is ready with something like LGTM

TLDR

  • Variables names need to be informative. No k, v or x.

  • Use standard import order

  • Define global variables in CAPS

  • Use appropriate underscore for variable naming (leading, lagging, single, double)

  • Add docstrings

  • Add type hints

  • Use codetags like #TODO in code wherever needed

  • Raise appropriate exceptions

  • Don’t rename functions & arguments exposed to the user unless necessary. Have appropriate depreciation strategy

  • Avoid global variables

Adding tests

  • Add a new unit & integration test if you add a new feature

  • Use pytest tmpdir fixture for temporary directories

  • Check test locally before pushing


Come join Maxpool - A Data Science community to discuss real ML problems!

I am also on MediumTwitter & LinkedIn.