Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Static type checking

All functions and global objects must be type annotated. Types must be checked statically using MyPy with the following (or stricter) settings (example shown is an excerpt from `setupsetup.cfg`cfg):

Code Block
languagetext
titleMyPy static type checking options
[mypy]
warn_return_any = True
warn_unused_configs = True
disallow_untyped_defs = True
check_untyped_defs = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True

...

Usage of tabs is not allowed. If you're porting an existing codebase, replace all tabs with 4 spaces. PEP8 recommends to retain tabs when working with an existing codebase.

Formatting

Always provide a blank line after the end of every indented block, unless the following code is related to the indented block. For example, there should be an empty space after the end of an if block, unless it is followed by its else block.

Code Block
languagepy
def foo():
    try:
        if a == b:
            bar()
        else:
            baz()
        
        if a == c:
            booz()
    except ValueError as ex:
        print(ex)
        return False
    else:
        return True

Lines

Every text file should contain exactly one empty line at the end.

...