From b84ccb1ad05f98ad60b398db0b2d7a330081f6a8 Mon Sep 17 00:00:00 2001 From: elliot-100 <3186037+elliot-100@users.noreply.github.com> Date: Mon, 17 Jul 2023 15:41:17 +0100 Subject: [PATCH 1/5] deps: drop separate `tool.poetry.group.test.dependencies`: unnecessary complication especially as `black` and `isort` will be explicitly required in `build` workflow --- .github/workflows/python-package.yml | 2 +- pyproject.toml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 636635d..ece417c 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -30,7 +30,7 @@ jobs: virtualenvs-create: true virtualenvs-in-project: true - name: Install project - run: poetry install --without dev + run: poetry install - name: Test with pytest run: | source $VENV diff --git a/pyproject.toml b/pyproject.toml index 986a82b..6b791eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,8 +14,6 @@ aiohttp = "^3.8.3" [tool.poetry.group.dev.dependencies] black = "^23.1.0" isort = "^5.11.4" - -[tool.poetry.group.test.dependencies] pytest = "^7.2.2" [tool.black] From 4fb59ac2c9dadb1ce3e503ed82f2e1a7814eb456 Mon Sep 17 00:00:00 2001 From: elliot-100 <3186037+elliot-100@users.noreply.github.com> Date: Mon, 17 Jul 2023 15:05:19 +0100 Subject: [PATCH 2/5] dev-deps: update `black` to 23.7 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6b791eb..328952e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ python = "^3.8" aiohttp = "^3.8.3" [tool.poetry.group.dev.dependencies] -black = "^23.1.0" +black = "^23.7.0" isort = "^5.11.4" pytest = "^7.2.2" From 62cfc1b1b7cb8a97212b8a8c07317bd38a2705fd Mon Sep 17 00:00:00 2001 From: elliot-100 <3186037+elliot-100@users.noreply.github.com> Date: Mon, 17 Jul 2023 16:13:50 +0100 Subject: [PATCH 3/5] fix: `black` config to cover all supported Python versions --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 328952e..ec5cadc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ pytest = "^7.2.2" [tool.black] line-length = 88 -target-version = ['py38'] +target-version = ['py38', 'py39', 'py310', 'py311'] [tool.isort] profile = "black" From ce94f37676584e1346fc925061d5805ef69c66f4 Mon Sep 17 00:00:00 2001 From: elliot-100 <3186037+elliot-100@users.noreply.github.com> Date: Mon, 17 Jul 2023 15:07:45 +0100 Subject: [PATCH 4/5] style: apply `black` to all files --- spond/spond.py | 87 ++++++++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/spond/spond.py b/spond/spond.py index 16dce1d..7533b7d 100644 --- a/spond/spond.py +++ b/spond/spond.py @@ -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() @@ -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): From eb463600ab8e5055e5f61831c3fad3bbf5d2f12e Mon Sep 17 00:00:00 2001 From: elliot-100 <3186037+elliot-100@users.noreply.github.com> Date: Mon, 17 Jul 2023 15:22:43 +0100 Subject: [PATCH 5/5] ci: add `black` to workflow --- .github/workflows/python-package.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index ece417c..6b3e472 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -31,6 +31,9 @@ jobs: virtualenvs-in-project: true - name: Install project 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