4 ms·
To make this code clearer: def get_users(f) -> Tuple[List, List]: return (logged_in_users(f), logged_out_users(f)) def user_count(f) -> int:
by 4WIW 6y ago
To make this code clearer:
def get_users(f) -> Tuple[List, List]:
return (logged_in_users(f), logged_out_users(f))
def user_count(f) -> int:
return len(get_users())
Now it's clear this is just wrong code. To fix it:
def get_users(f) -> List:
return logged_in_users(f) + logged_out_users(f)
def user_count(f) -> int:
return len(get_users())
- wk_end 6y agoThat doesn't really "fix it". Even assuming there are no other callers of `get_users` that you might be breaking here (possibly silently, since lists and tuples in Python have overlapping interfaces), you're making `get_users` less useful by dropping structure that at least someone, at some point, thought was useful. Also, you should annotate the type of your lists :) def get_users(f) -> Tuple[List[User], List[User]]: return (logged_in_users(f), logged_out_users(f)) def user_count(f) -> int: logged_in_users, logged_out_users = get_users() return len(logged_in_users) + len(logged_out_users)