hugetim / empathy.chat

A place to exchange NVC empathy.

Home Page:https://empathy.chat

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sweep: Standardize indentation and import sort order (like 'isort') in all files

hugetim opened this issue · comments

Details

No response

Checklist
  • client_code/glob.py ⚠️ No Changes Made
  • client_code/MenuForm/NetworkMenu/Connections/__init__.py ✅ Commit 7897cfc
  • client_code/groups.py ✅ Commit 16f8c92
  • client_code/MenuForm/__init__.py ✅ Commit c7c961e
  • client_code/helper.py ✅ Commit 3b5a924
  • client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py ✅ Commit 06a65ab
  • client_code/portable.py
  • client_code/MenuForm/UserMenu/Profile/__init__.py
  • client_code/network_controller.py
Sweeping

50%

⚡ Sweep Free Trial: I'm creating this ticket using GPT-3.5. You have 1 GPT-4 tickets left for the month and 0 for the day. For more GPT-4 tickets, visit our payment portal.

Actions (click)

  • ↻ Restart Sweep

Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description.

def get_connections(user_id):
profiles = (_get_their_connections(user_id) if not_me(user_id)
else _get_my_connections(glob.logged_in_user_id))
return sorted(profiles, key=lambda u: (u.distance_str_or_groups, h.reverse_compare(u.last_active)))
def get_create_group_items():
items = []
for g in glob.my_groups:
items.append(_group_item(g, my_group=True))
for g in glob.their_groups.values():
items.append(_group_item(g))
return sorted(items, key=lambda item:(item['subtext'] + item['key']))
def _group_item(group, my_group=False):
if my_group:
subtext = "(host: me)"
else:
host_id = group['hosts'][0]
subtext = f"(host: {glob.users[host_id].name})"
return dict(key=group['name'], value=groups.Group(group['name'], group.group_id), subtext=subtext)
def get_group_names_hosted_by(user_id):
"""Returns list of group names (assuming single host per group)"""
if user_id == glob.logged_in_user_id:
return [g['name'] for g in glob.my_groups]
else:
return [g['name'] for g in glob.their_groups.values() if user_id in g['hosts']]
def get_group_by_id(group_id):
for g in glob.my_groups:
if group_id == g.group_id:
return _group_item(g, my_group=True)['value']
for g in glob.their_groups.values():
if group_id == g.group_id:
return _group_item(g)['value']
def get_create_user_items():
"""Return list with 1st---2nd""" # add pending connections to front
user_id = glob.logged_in_user_id
up_to_degree = 3 if glob.trust_level >= 3 else 1
name_items = _get_sorted_name_items(user_id, up_to_degree)
starred_name_list = [item['key'] for item in name_items if item['value'].starred] # ensures sort order
return name_items, starred_name_list
def _get_sorted_name_items(user_id, up_to_degree):
user_profiles = _get_my_connections(user_id, up_to_degree)
name_items = [u.name_item() for u in user_profiles]
name_items.sort(key=operator.itemgetter('subtext', 'key'))
return name_items
def get_relationships(user2_id):
"""Returns ordered list of dictionaries"""
user1_id = glob.logged_in_user_id
degree = glob.users[user2_id].degree
if degree in [0, port.UNLINKED]:
return []
elif degree == 1:
return [_direct_relationship_dict(user1_id, user2_id, with_their=True)]
else:
return _indirect_relationship_dicts(user1_id, user2_id, degree)
def _direct_relationship_dict(user1_id, user2_id, with_their=False):
conn = _get_connection(user1_id, user2_id)
out = {"via": False,
"whose": "my",
"desc": conn['relationship2to1'],
"date": conn['date_described'],
"child": None,
}
if with_their:
out.update(_direct_relationship_their_dict(user1_id, user2_id))
return out


Step 2: ⌨️ Coding

  • client_code/glob.py ⚠️ No Changes Made
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
  • client_code/MenuForm/NetworkMenu/Connections/__init__.py ✅ Commit 7897cfc
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
Sandbox Execution Logs
trunk fmt `client_code/MenuForm/NetworkMenu/Connections/__init__.py` 1/4 ✓







































































































 ✔ Formatted client_code/MenuForm/NetworkMenu/Connections/__init__.py
Re-checking autofixed files...



 ✔ Formatted client_code/MenuForm/NetworkMenu/Connections/__init__.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures `client_code/MenuForm/NetworkMenu/Connections/__init__.py` 2/4 ✓

  ISSUES  
client_code/MenuForm/NetworkMenu/Connections/__init__.py:1:1
 1:1  high  `from anvil import *` used; unable to detect undefined names  ruff/F403
Checked 1 file
1 existing issue
trunk fmt `client_code/MenuForm/NetworkMenu/Connections/__init__.py` 3/4 ✓
 ✔ Formatted client_code/MenuForm/NetworkMenu/Connections/__init__.py
Re-checking autofixed files...



 ✔ Formatted client_code/MenuForm/NetworkMenu/Connections/__init__.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
trunk check --fix --print-failures `client_code/MenuForm/NetworkMenu/Connections/__init__.py` 4/4 ✓
  ISSUES  
client_code/MenuForm/NetworkMenu/Connections/__init__.py:1:1
 1:1  high  `from anvil import *` used; unable to detect undefined names  ruff/F403
Checked 1 file
1 existing issue
  • client_code/groups.py ✅ Commit 16f8c92
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
Sandbox Execution Logs
trunk fmt `client_code/groups.py` 1/4 ✓




















































































































































































































 ✔ Formatted client_code/groups.py
Re-checking autofixed files...




 ✔ Formatted client_code/groups.py
Re-checking autofixed files...



Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures `client_code/groups.py` 2/4 ✓



































  ISSUES  
client_code/groups.py:2:1
 2:1  high  `from anvil import *` used; unable to detect undefined names  ruff/F403
Checked 1 file
1 existing issue
trunk fmt `client_code/groups.py` 3/4 ✓
 ✔ Formatted client_code/groups.py
Re-checking autofixed files...



 ✔ Formatted client_code/groups.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
trunk check --fix --print-failures `client_code/groups.py` 4/4 ✓
  ISSUES  
client_code/groups.py:2:1
 2:1  high  `from anvil import *` used; unable to detect undefined names  ruff/F403
Checked 1 file
1 existing issue
  • client_code/MenuForm/__init__.py ✅ Commit c7c961e
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
Sandbox Execution Logs
trunk fmt `client_code/MenuForm/__init__.py` 1/2 ✓






















































































































































































































 ✔ Formatted client_code/MenuForm/__init__.py
Re-checking autofixed files...




 ✔ Formatted client_code/MenuForm/__init__.py
Re-checking autofixed files...




Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures `client_code/MenuForm/__init__.py` 2/2 ❌ (`1`)









  ISSUES  
client_code/MenuForm/__init__.py:4:1
   4:1   high  `from anvil import *` used; unable to detect undefined names                             ruff/F403  
   9:28  high  `..portable` imported but unused                                                         ruff/F401  
  27:13  high  `alert` may be undefined, or defined from star imports                                   ruff/F405  
 105:9   high  `open_form` may be undefined, or defined from star imports                               ruff/F405  
 204:0   low   Standard pseudo-random generators are not suitable for security/cryptographic purposes.  bandit/B311
 218:9   high  `open_form` may be undefined, or defined from star imports                               ruff/F405  
Checked 1 file
5 existing issues (1 auto-fixable)
✖ 1 new issue
  • client_code/helper.py ✅ Commit 3b5a924
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
Sandbox Execution Logs
trunk fmt `client_code/helper.py` 1/4 ✓

























































































































































































































































 ✔ Formatted client_code/helper.py
Re-checking autofixed files...




 ✔ Formatted client_code/helper.py
Re-checking autofixed files...




Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures `client_code/helper.py` 2/4 ✓








  ISSUES  
client_code/helper.py:142:12
 142:12  high  `datetime` imported but unused                                                                ruff/F401  
 189:37  high  `.helper` imported but unused                                                                 ruff/F401  
 207:0   low   Standard pseudo-random generators are not suitable for security/cryptographic purposes.       bandit/B311
 251:13  high  Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from      ruff/B904  
               None` to distinguish them from errors in exception handling                                              
Checked 1 file
4 existing issues (2 auto-fixable)
trunk fmt `client_code/helper.py` 3/4 ✓
 ✔ Formatted client_code/helper.py
Re-checking autofixed files...




 ✔ Formatted client_code/helper.py
Re-checking autofixed files...





Checked 1 file
✔ No issues
trunk check --fix --print-failures `client_code/helper.py` 4/4 ✓






  ISSUES  
client_code/helper.py:180:37
 180:37  high  `.helper` imported but unused                                                                 ruff/F401  
 196:0   low   Standard pseudo-random generators are not suitable for security/cryptographic purposes.       bandit/B311
 240:13  high  Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from      ruff/B904  
               None` to distinguish them from errors in exception handling                                              
Checked 1 file
3 existing issues (1 auto-fixable)
  • client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py ✅ Commit 06a65ab
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
Sandbox Execution Logs
trunk fmt `client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py` 1/4 ✓





















































































































































































































































































 ✔ Formatted client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py
Re-checking autofixed files...





 ✔ Formatted client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py
Re-checking autofixed files...




Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures `client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py` 2/4 ✓
















  ISSUES  
client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py:1:1
 1:1  high  `from anvil import *` used; unable to detect undefined names  ruff/F403
Checked 1 file
1 existing issue
trunk fmt `client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py` 3/4 ✓
 ✔ Formatted client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py
Re-checking autofixed files...





 ✔ Formatted client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py
Re-checking autofixed files...




Checked 1 file
✔ No issues
trunk check --fix --print-failures `client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py` 4/4 ✓
  ISSUES  
client_code/MenuForm/MyGroupsMenu/MyGroupMembers/__init__.py:1:1
 1:1  high  `from anvil import *` used; unable to detect undefined names  ruff/F403
Checked 1 file
1 existing issue
  • client_code/portable.py
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
  • client_code/MenuForm/UserMenu/Profile/__init__.py
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.
  • client_code/network_controller.py
• Ensure all indentation is consistent and uses 4 spaces per level.
• Sort all import statements alphabetically.

Step 3: 🔁 Code Review

Working on it...


🎉 Latest improvements to Sweep:

  • Sweep can now passively improve your repository! Check out Rules to learn more.

💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.
Join Our Discord