Skip to content

Commit

Permalink
Merge pull request #77 from Olen/74-enforce-black-in-ci
Browse files Browse the repository at this point in the history
Enforce black in CI
  • Loading branch information
Olen authored Jul 28, 2023
2 parents f4a19d6 + eb46360 commit 5db8fee
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 43 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ jobs:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install project
run: poetry install --without dev
run: poetry install
- name: Lint with black
# by default: exit with error if the code is not properly formatted; show diffs
uses: psf/black@stable
- name: Test with pytest
run: |
source $VENV
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ python = "^3.8"
aiohttp = "^3.8.3"

[tool.poetry.group.dev.dependencies]
black = "^23.1.0"
black = "^23.7.0"
isort = "^5.11.4"

[tool.poetry.group.test.dependencies]
pytest = "^7.2.2"

[tool.black]
line-length = 88
target-version = ['py38']
target-version = ['py38', 'py39', 'py310', 'py311']

[tool.isort]
profile = "black"
Expand Down
87 changes: 49 additions & 38 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,24 @@ async def send_message(self, text, user=None, group_uid=None, chat_id=None):
if chat_id is not None:
return self._continue_chat(chat_id, text)
elif group_uid is None or user is None:
return {'error': 'wrong usage, group_id and user_id needed or continue chat with chat_id'}
return {
"error": "wrong usage, group_id and user_id needed or continue chat with chat_id"
}

if not self.cookie:
await self.login()
user_obj = await self.get_person(user)
if user_obj:
user_uid = user_obj['profile']['id']
user_uid = user_obj["profile"]["id"]
else:
return False
url = self.chaturl + "/messages"
data = {"text": text, "type": "TEXT", "recipient": user_uid, "groupId": group_uid}
data = {
"text": text,
"type": "TEXT",
"recipient": user_uid,
"groupId": group_uid,
}
headers = {"auth": self.auth}
r = await self.clientsession.post(url, json=data, headers=headers)
return await r.json()
Expand Down Expand Up @@ -308,41 +315,45 @@ async def update_event(self, uid, updates: dict):
break

url = f"{self.apiurl}sponds/" + f"{uid}"

base_event = {"heading":None,
"description": None,
"spondType":"EVENT",
"startTimestamp":None,
"endTimestamp":None,
"commentsDisabled":False,
"maxAccepted":0,
"rsvpDate":None,
"location":{"id": None,
"feature":None,
"address":None,
"latitude":None,
"longitude":None},
"owners":[{"id":None}],
"visibility":"INVITEES",
"participantsHidden":False,
"autoReminderType":"DISABLED",
"autoAccept":False,
"payment":{},
"attachments":[],
"id":None,
"tasks":{"openTasks":[],
"assignedTasks":[{"name":None,
"description":"",
"type":"ASSIGNED",
"id":None,
"adultsOnly":True,
"assignments":{"memberIds":[],
"profiles":[],
"remove":[]}}
]
}
}


base_event = {
"heading": None,
"description": None,
"spondType": "EVENT",
"startTimestamp": None,
"endTimestamp": None,
"commentsDisabled": False,
"maxAccepted": 0,
"rsvpDate": None,
"location": {
"id": None,
"feature": None,
"address": None,
"latitude": None,
"longitude": None,
},
"owners": [{"id": None}],
"visibility": "INVITEES",
"participantsHidden": False,
"autoReminderType": "DISABLED",
"autoAccept": False,
"payment": {},
"attachments": [],
"id": None,
"tasks": {
"openTasks": [],
"assignedTasks": [
{
"name": None,
"description": "",
"type": "ASSIGNED",
"id": None,
"adultsOnly": True,
"assignments": {"memberIds": [], "profiles": [], "remove": []},
}
],
},
}

for key in base_event:
if event.get(key) != None and not updates.get(key):
Expand Down

0 comments on commit 5db8fee

Please sign in to comment.