Version: 1.1.0

Simple statements

Simple statements fit on one logical line: assignment, a call used for effect, return, raise, break, continue, and pass.

Essentials

  • Assignment can unpack tuples when the shapes match.
  • return ends the function. The value must match the declared type.
  • raise requires the function to be marked raises.
  • pass is an empty statement, useful in a stub.
  • Imports are also simple statements and usually sit at the top of the file.

Example

def clamp(n: Int) -> Int:
    if n < 0:
        return 0
    return n

Keep in mind

A line break ends the statement unless the line is inside parentheses or a similar grouping.