Welcome to Orbital's Ground Station Onboarding Challenge! Please visit this Notion doc for the challenge instructions. Remember to follow our style guide which is written below.
- We will be following the Python language style guide PEP8
- If there are any discrepancies between this style guide and PEP8, this style guide takes precedence.
All function and method parameters (except for the self and cls parameters) and return signatures should be type hinted.
def my_add(num1: int, num2: int) -> int:
"""
Adds two numbers together
:param num1: The first number to add.
:param num2: The second number to add.
:return: Returns the sum of the two numbers.
"""
return num1 + num2-
variable_names,field_namesandfunction_constantsin snake_case -
_private_field_names, and_private_method_names()in _snake_case -
function_names()andmethod_names()in snake_case -
CONSTANT_NAMES: FinalandENUM_OPTIONSin CAPITAL_SNAKE_CASE for module and class constants (not for local constant) -
file_namesin snake_case -
ClassNamein PascalCase# For brevity, the class comments were removed but they should be in real code import dataclasses @dataclasses.dataclass class PointTwoDimension: x: int y: int class PointTwoDimension: def __init__(x: int, y: int): self.x = x self.y = y
-
EnumNamein PascalCaseimport enum class ErrorCode(enum.Enum): SUCCESS = 0 INVALID_ARG = 1 # Accessing: ErrorCode.SUCCESS # <ErrorCode.SUCCESS: 0> ErrorCode.INVALID_ARG # <ErrorCode.INVALID_ARG: 1>
Variable and function names should be descriptive enough to understand even without comments. Comments are needed to describe any complicated logic. Use # for single-line comments.
Function and method comments using """ """ should exist below the function declaration. For methods, the self or cls parameter does not require a description.
def my_add(num1: int, num2: int) -> int:
"""
Adds two numbers together
:param num1: The first number to add.
:param num2: The second number to add.
:return: Returns the sum of the two numbers.
"""
return num1 + num2def increase_x(self, count: int) -> None:
"""
Increases the x attribute by the count.
:param count: Count to increase the x attribute by.
"""
self.x += countFile comments are not required
- Class comments should exist after the class definition
- Provide a brief description given class purpose
- Provide a section in the class comment listing the attributes, their type and purpose
- Enum class comments do not require listing the attributes
class PointTwoDimension:
"""
Class for storing a 2D point
:param x: x coordinate of the point
:type x: int
:param y: y coordinate of the point
:type y: int
"""
def __init__(x: int, y: int):
self.x = x
self.y = y
@dataclasses.dataclass
class PointTwoDimension:
"""
Class for storing a 2D point
:param x: x coordinate of the point
:type x: int
:param y: y coordinate of the point
:type y: int
"""
x: int
y: intimport enum
# No comments required
class ErrorCode(enum.Enum):
"""
@brief Enum for the error codes
"""
SUCCESS = 0
INVALID_ARG = 1- Imports should only be used at the top of the file (no function or scoped imports)
- Only variables, classes and functions (i.e. the code that runs directly) should be imported
# module1 contains very_long_module_name and function foo and variable var.
# very_long_module_name contains bar
# Yes:
from module1.very_long_module_name import bar
from module1 import foo, var
foo()
var
bar()
# No:
from module1 import very_long_module_name as module2 # Casting to shorter name
import module1
module1.foo()
module1.var
module2.bar()- Only imports, function, class, and constants declarations and the
if __name__ == '__main__'should be in module scope - Entry point to a script or program should be through the
mainfunction - Add a trailing comma after elements of a list, if you wish to make/preserve each element on a separate line
Variable and function names should be descriptive enough to understand even without comments. Comments are needed to describe any complicated logic. You may use // or /* */ for single line comments.
Function comments should follow the format shown below:
/**
* @brief Adds two numbers together
*
* @param num1 - The first number to add.
* @param num2 - The second number to add.
* @return Returns the sum of the two numbers.
*/
function addNumbers(num1: number, num2: number): number {
return num1 + num2;
}- File comments are not required
variableNamesin camelCasefunctionNames()in camelCaseCONSTANT_NAMEin CAPITAL_SNAKE_CASEfile_namesin snake_caseClassNameandComponentNamein PascalCase