Skip to content

Commit

Permalink
Simplify short-circuit conditionals.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Upton committed Jul 3, 2015
1 parent 1ca30e4 commit 6315ed3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions compact_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
from docopt import docopt

def compact_path(path, trigger=0):
if not path or len(path) == 0:
return

if len(path) <= trigger or path == os.sep:
if not path or len(path) == 0 or len(path) <= trigger or path == os.sep:
return path

parts = path.split(os.sep)
Expand Down
2 changes: 1 addition & 1 deletion test_compact_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import nose.tools as tools

def test_empty():
tools.eq_(None, compact_path(''))
tools.eq_('', compact_path(''))

tools.eq_(None, compact_path(None))

Expand Down

0 comments on commit 6315ed3

Please sign in to comment.