Conventions

Python

Parameters in the config.py (which are accessible via the Flask app.config dictionary) are assumed to always be defined and thus should be accessed directly via,

  1. blueprints = app.config["BLUEPRINTS"]

rather than,

  1. blueprints = app.config.get("BLUEPRINTS")

or similar as the later will cause typing issues. The former is of type List[Callable] whereas the later is of type Optional[List[Callable]].

Typing

Python

To ensure clarity, consistency, all readability, all new functions should use type hints and include a docstring.

Note per PEP-484 no syntax for listing explicitly raised exceptions is proposed and thus the recommendation is to put this information in a docstring, i.e.,

  1. import math
  2. from typing import Union
  3. def sqrt(x: Union[float, int]) -> Union[float, int]:
  4. """
  5. Return the square root of x.
  6. :param x: A number
  7. :returns: The square root of the given number
  8. :raises ValueError: If the number is negative
  9. """
  10. return math.sqrt(x)

TypeScript

TypeScript is fully supported and is the recommended language for writing all new frontend components. When modifying existing functions/components, migrating to TypeScript is appreciated, but not required. Examples of migrating functions/components to TypeScript can be found in #9162 and #9180.