Coding Guidelines - PichapopRo/project-pantry GitHub Wiki

Naming Convention

  • Using Pascal case in Class naming.
  • Using Kebab case in branch naming.
  • Using Snake case in Variable and function naming.
# Using Snake case
api_key = 'fake API KEY'

def strip_html(html_formatt):
    pass

# Using Pascal case
class GetData:
   def __init__(data):
       self.data = data

Run Flake8 and Flake8-docstring

Flake8-Flak8-Docstring-Test

  • We will use GitHub workflow to keep up the code quality
  • We have a flake8 configuration file .flake8

Using sphinx style docstrings

def some_function(text:str) -> str:
    """
    Description of the function. (The next line must be left blank.)
    
    :param text: Description of the parameter text.
    :return: Description of the return data.
    """

Run the tests by PyTest and UnitTest

Django CI

  • Tested by using GitHub Workflow

Coverage

codecov

  • Code coverage must be >= 80%
  • Tested by using GitHub Workflow

Test directory

|- tests/
    |- test_classname.py
  • The test must be in a separate file for each class

Additional Guidelines

  • Each function must have <= 100 lines.
  • No useless commented code.
  • The function must only do 1 thing at a time (which is what the name or docstring suggests).