Contribution Guide for Pygame Widgets

If you want to contribute to this project, it would be greatly appreciated if you keep to the following code style guide as much as possible.

Note: If ever in doubt, check the existing code.

Naming

  • Variables, functions and keyword arguments should be in lowerCamelCase NOT lower_snake_case
  • Classes should be UpperCamelCase
  • Constants should be UPPERCASE_WITH_UNDERSCORES
  • Names should be concise but also descriptive
  • The names of properties and methods should be consistent across all widgets
  • Where possible, Australian English should be used
  • E.g. colour instead of color
  • Note: This is to ensure consistency across the project for users and does not matter as much for comments

Whitespace

  • Two lines before and after class and function declarations
  • A single line between separate blocks of logic
  • E.g. Between an if and elif statement
  • A single space between operators
  • E.g. n = (x + y) / 3 == (z ** 2)
  • Note: The only exception is if - is used for negatives
  • A single space after commas, not before
  • E.g. [1, 2, 3, 4]
  • No space when setting keyword arguments
  • E.g. function(param, x=1, y=2)

Other

  • SINGLE quotes for 'strings'
  • Double quotes for """docstrings""" only
  • Extracting keyword arguments should be done with kwargs.get('key', default)
  • Only use built-in exceptions if logical, otherwise create a custom exception in exceptions.py

Documentation

  • Docstrings should include a short description of the function or class followed by parameter descriptions and types
  • Single line comments should be placed whenever complex logic is used
  • If unclear, type hints should be used to clarify functions