Skip to content

Show single underscore attributes before double underscore ones #528 #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change doc string and fix variable name
  • Loading branch information
wevial committed Sep 10, 2015
commit e9f17967a39f9f2e58b175075516f158c530983c
5 changes: 3 additions & 2 deletions bpython/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ def get_completer(completers, cursor_offset, line, **kwargs):
return [], None

def sort_by_underscore(matches):
"""Sort single underscore attributes before double underscore ones.
"""Returns a sorted list with single underscore attributes before double
underscore ones.
"""
matches = sorted(matches)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really matter, but I'd prefer matches.sort() instead of reassigning to the variables - I guess this keeps the matches list being passed in safe from modifications, but if we're doing this we should change the docstring from "sort asdfasdf" to "Returns a sorted list" because sort implies mutating the list imo.

if len(matches) == 0 or len(matches) == 1:
Expand All @@ -565,7 +566,7 @@ def sort_by_underscore(matches):
one_underscore = i
else:
break
if one_underscore_i != None:
if one_underscore != None:
return matches[one_underscore:] + matches[:one_underscore]
return matches

Expand Down