-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update Dependencies - Feb 2024 #57
Merged
ThorntonMatthewD
merged 1 commit into
hackgvl:dev
from
ThorntonMatthewD:update-dependencies-feb-2024
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,37 +4,27 @@ description = "An automated Slack bot to syndicate local events into Slack chann | |
readme = "README.md" | ||
requires-python = ">=3.11" | ||
license = { text = "MIT" } | ||
version="0.1.0" | ||
authors = [ | ||
{ name = "Olivia Sculley", email = "[email protected]" }, | ||
] | ||
keywords = [ | ||
"automation", | ||
"black", | ||
"bolt", | ||
"bot", | ||
"pylint", | ||
"pytest", | ||
"slack" | ||
] | ||
version = "0.1.0" | ||
authors = [{ name = "Olivia Sculley", email = "[email protected]" }] | ||
keywords = ["automation", "black", "bolt", "bot", "pylint", "pytest", "slack"] | ||
dependencies = [ | ||
"aiohttp==3.9.1", | ||
"fastapi==0.103.2", | ||
"aiohttp==3.9.3", | ||
"fastapi==0.109.2", | ||
"python_dateutil==2.8.2", | ||
"pytz==2023.3", | ||
"slack_bolt==1.18.0", | ||
"uvicorn==0.23.2" | ||
"pytz==2024.1", | ||
"slack_bolt==1.18.1", | ||
"uvicorn==0.27.0.post1", | ||
] | ||
|
||
[project.optional-dependencies] | ||
test = [ | ||
"black==23.9.1", | ||
"httpx==0.25.0", | ||
"isort==5.12.0", | ||
"pylint==2.17.5", | ||
"pytest==7.4.2", | ||
"pytest-asyncio==0.21.1", | ||
"ssort==0.11.6" | ||
"black==24.1.1", | ||
"httpx==0.26.0", | ||
"isort==5.13.2", | ||
"pylint==3.0.3", | ||
"pytest==7.4.4", | ||
"pytest-asyncio==0.23.4", | ||
"ssort==0.11.6", | ||
] | ||
|
||
[project.urls] | ||
|
@@ -43,13 +33,8 @@ Documentation = "https://github.com/hackgvl/slack-events-bot/blob/dev/README.md" | |
Repository = "https://github.com/hackgvl/slack-events-bot.git" | ||
|
||
[tool.pytest.ini_options] | ||
pythonpath = [ | ||
".", | ||
"src" | ||
] | ||
norecursedirs = [ | ||
"tests/helpers" | ||
] | ||
pythonpath = [".", "src"] | ||
norecursedirs = ["tests/helpers"] | ||
|
||
[tool.isort] | ||
profile = "black" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
Visit the /docs route for more information on the routes contained within. | ||
""" | ||
|
||
import asyncio | ||
import datetime | ||
import logging | ||
|
@@ -16,7 +17,6 @@ | |
import uvicorn | ||
from fastapi import HTTPException, Request | ||
from fastapi.responses import PlainTextResponse | ||
from starlette.types import Message | ||
|
||
import database | ||
from auth import validate_slack_command_source | ||
|
@@ -84,39 +84,12 @@ async def update_check_api_cooldown(team_domain: str | None) -> None: | |
await database.create_cooldown(team_domain, "check_api", 15) | ||
|
||
|
||
async def set_body(req: Request, body: bytes): | ||
""" | ||
Overrides the Request class's __receive method as a workaround to an issue | ||
where accessing a request body in middleware causes it to become blocking. | ||
|
||
See https://github.com/tiangolo/fastapi/discussions/8187 for the discussion | ||
and this post (https://github.com/tiangolo/fastapi/discussions/8187#discussioncomment-5148049) | ||
for where this code originates. Thanks, https://github.com/liukelin! | ||
""" | ||
|
||
async def receive() -> Message: | ||
return {"type": "http.request", "body": body} | ||
|
||
# pylint: disable=protected-access | ||
req._receive = receive | ||
|
||
|
||
async def get_body(req: Request) -> bytes: | ||
""" | ||
Leans into the overriden Request.__receive method seen above in set_body | ||
to workaround 'await req.body()' causing the application to hang. | ||
""" | ||
body = await req.body() | ||
await set_body(req, body) | ||
return body | ||
|
||
|
||
@API.middleware("http") | ||
async def rate_limit_check_api( | ||
req: Request, call_next: Callable[[Request], Awaitable[None]] | ||
): | ||
"""Looks to see if /check_api has been run recently, and returns an error if so.""" | ||
req_body = await get_body(req) | ||
req_body = await req.body() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wish there was a chef's kiss emoji for this! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It felt so good to rip that out, oh my gosh! |
||
|
||
if await check_api_being_requested(req.scope["path"], req_body): | ||
team_domain = await identify_slack_team_domain(req_body) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean to reformat this entire file. I was fighting with my autolinter hard, and I think it won.