Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 860 Bytes

mixed-indentation.md

File metadata and controls

31 lines (21 loc) · 860 Bytes

Pattern: Mixed indentation

Issue: -

Description

Python interprets tabs and spaces differently, so consistent indentation is critical to the correct interpretation of blocks in Python syntax.

This warning is raised when a mix of both spaces and tabs is used in indentation or more precisely, when an indent is detected that is not consistent with the Pylint's indent-string option. By default, indent-string is set to four spaces.

Example of incorrect code:

def tab_func():
    # Using tabs (non-default) for indentation
  """hi""" # [mixed-indentation]
  print("hi") # [mixed-indentation]

Example of correct code:

def spaces_func():
    # Using 4 spaces (default) for indentation
    """hi"""
    print("hi")

Further Reading