avoid unreachable code

Metadata

ID: python-best-practices/unreachable-code

Language: Python

Severity: Notice

Category: Best Practices

Description

Avoid unreachable code. If the code cannot be reached because of a coding mistake, fix the business logic. If the code should not be used, remove it.

Learn More

Non-Compliant Code Examples

def foo():
  return 3
  foo()  # unreachable code
  pass  # unreachable code

Compliant Code Examples

def foo():
	foo()
	pass
	return 3