Python Code Review Checklist

Always follow best practices and run a checklist for python code review. It helps companies save time and get the most out of their code review process.

Digital Quality
-
5 min
Digital Quality
/
Python Code Review Checklist

Code reviews are a crucial part of development. During reviews, developers often identify issues and inefficiencies that otherwise would've slipped right by the team. Given how informative a code review can be, it's one of the most crucial aspects of development, but time is always a factor.

To save time and get the most out of your code review process, always adhere to established best practices.

Here is our list of Python code review checklist that we consider it should be followed and not only;

1. Backtrack on Requirements

It's critical that you always confirm the need for a new feature before you begin building it, but sometimes requirements are overlooked.

Therefore, the best way to kick off a Python code review is by comparing it to the original scope.

Get to know:

  • What problem did you try to solve, and is this the best way to solve it?
  • Is implementing this code the only way to solve the problem, or is there a simpler solution?
  • Have you missed requirements that may not have been disclosed?

There's always a trade-off, but if you don't solve the problem you set out to solve, you need to evaluate whether moving forward is a viable option.

You also need to consider if implementing the code is the best way forward. Sometimes coding a solution is unnecessarily complicated, and the problem could be more easily resolved by a third-party provider or by addressing the issue from another angle.

Lastly, you should always test the code in multiple scenarios, especially those that haven't been thought of at first.

This will help you address any bugs or missing features.

Following up with the author of the original requirements is also a good idea to ensure everything was appropriately interpreted and addressed.

2. Confirm Your Implementation Plan

The next step in your Python code review process is evaluating how well the implementation fits into your existing system.

Review your plan for implementation and ask:

  • Is this being implemented in the right way?
  • Is this being implemented in the right place?
  • Are there any existing classes or methods that you can reuse?

Think about the approach taken (manual trigger, cron job, job queue) along with where it's being implemented before you move forward.

Making adjustments to your implementation plan is far easier now than it will be later.

Remember always to follow the golden rule of avoiding duplicate code by looking for opportunities to reuse what's already there.

3. Examine The Code

Once you've addressed your preliminary questions, it's time to dive into the most comprehensive phase of the code review process.

During this phase, you want to ask:

  • Have your requirements been met with this implementation?
  • Have you considered all user experience scenarios?
  • Is the user experience acceptable across devices?
  • Does the implementation perform reasonably well?
  • Does everything have a logical name?
  • Have you been sufficiently concise with classes and methods?
  • Have you designed a logical hierarchy?
  • Have you used constants, config values, and parameters in the right places?
  • Are there any unused methods, variables, or constants you can remove?

If you discover problems with any of these checks, you'll need to discuss them with your team to determine their severity.

For instance, you might move forward even if there are performance issues and plan to make the code lighter down the road.

On the other hand, if you've left out key user scenarios, like what happens with "no data" or when someone isn't logged in, those are likely more pressing issues.

Decide what is of the highest priority to address so that you have an efficient plan moving forward.

4. Prepare for Production

If you've made it to this phase, you're now ready to prepare the code for production by checking testing, monitoring, and security tools.

Ask:

  • Have you tested this implementation sufficiently?
  • Have our tests covered all reasonable scenarios?
  • Will all errors be adequately logged?
  • Will the team get alerts for important errors?
  • Are you protected from malicious user input?
  • Are you exposing any vulnerabilities?
  • Have you encrypted config values, access tokens, and other data correctly?
  • What other steps are needed to deploy this implementation?

If your implementation checks all these boxes, you'll probably be able to move forward with deployment swiftly since most deployment steps tend to be automated.

However, never forget about documentation updates and any notices that you need to send out to users or partners.

Enlist The Help of Adservio

Enhancing performance, improving resiliency, and moving away from technical debt and legacy applications is just a small slice of what we do at Adservio.

If you're in the process of reviewing Python code and you need help making sure that it "checks all of these boxes", our team can take your processes to the next level.

We are quality enablers for your software applications, no matter how complex or coupled they may be.

Interested in learning more about how Adservio can help your business succeed with its digital experiences? Contact us today!

Published on
November 30, 2021

Industry insights you won’t delete. Delivered to your inbox weekly.

Other posts