Skip to content

Files

Latest commit

 

History

History
31 lines (20 loc) · 1.08 KB

bad-whitespace.md

File metadata and controls

31 lines (20 loc) · 1.08 KB

Pattern: Irregular whitespace

Issue: -

Description

This rule enforces whitespace usage around an operator, bracket or block opener based on PEP 8 style guide. Warning is raised when any of the following rules is violated:

  • Any of the following operators is surrounded by one space: ==, !=, <>, <=, >=, <, >, =, +=, -=, *=, **=, /=, //=, &=, |=, ^=, %=, >>=, <<=
  • Any opening bracket ( (, [, { ) is not followed by any space.
  • Any closing bracket ( ), ], } ) is not preceded by any space.
  • Any comma is not preceded by any space, and is followed by one space.
  • Any block opener colon is not preceded by any space.

Example of incorrect code:

if x == 4 : print x , y ; x , y = y , x

Example of correct code:

if x == 4: print x, y; x, y = y, x

The guidelines provided by PEP 8 are intended to improve the readability of code and make it consistent across the wide spectrum of Python code.

Further Reading