Ryder5227
Ryder5227

Reputation: 17

What is the PEP:expected 2 blank lines found 1 in this code in pycharm

I tried redoing the spaccing but it still shows the error.

  return moves

def available_actions(self):
    """Returns all of the available actions in this room."""
    moves = self.adjacent_moves()
    moves.append(Actions.ViewInventory())

    assert isinstance(moves, object)
    return moves

Upvotes: 2

Views: 2040

Answers (1)

Ofer Sadan
Ofer Sadan

Reputation: 11922

From the PEP 8 relevant portion:

Surround top-level function and class definitions with two blank lines.

Method definitions inside a class are surrounded by a single blank line.

Extra blank lines may be used (sparingly) to separate groups of related functions. Blank lines may be omitted between a bunch of related one-liners (e.g. a set of dummy implementations).

Use blank lines in functions, sparingly, to indicate logical sections.

Python accepts the control-L (i.e. ^L) form feed character as whitespace; Many tools treat these characters as page separators, so you may use them to separate pages of related sections of your file. Note, some editors and web-based code viewers may not recognize control-L as a form feed and will show another glyph in its place.

Upvotes: 1

Related Questions