Indentation

  1. Indentation is done with spaces.

  2. Acceptable indentation size is 2, 4, in some niche cases an 8.

  3. Indentation size must be consistent across the code base.

  4. Indentation size must conform to community standards unless the standard postdates the codebase.

  5. Change in indentation level on next line is always either +1 or -1 indent. This is mostly de-facto standard except for some exotic languages and a phenomenon of line-splitting.

Lets take a look at some line-splitting indentation methods that exist{s,ed} in python.

Align with opening bracket:

result = self._call_chain(self.handle_open, protocol, protocol +
                          '_open', req)

Dreadful. Horrid. Tasteless.

Same but when your identifiers get out of hand:

foo_object_decompositor.some_very_long_method_name_because_i_cba(and, now, I,
                                                                 cant, fit,
                                                                 the, arguments,
                                                                 in, here, if,
                                                                 only, there,
                                                                 was, a, simple,
                                                                 solution, to,
                                                                 this, problem)

One might think this is argument ad absurdum. Unfortunately no. This exist. In the wild. Unironically. On purpose.