Skip to content

Commit 456e587

Browse files
committed
Code/dependency cleanup
1 parent 368497a commit 456e587

6 files changed

Lines changed: 16 additions & 30 deletions

File tree

Pipfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ cchardet = "*"
1515
zipcodes = "*"
1616

1717
[dev-packages]
18-
requests = "*"
1918
pytest = "*"
2019
pytest-mock = "*"
2120
pytest-asyncio = "*"

Pipfile.lock

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pybot/__main__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import os
22
import yaml
33
import logging.config
4-
from aiohttp.web_response import Response
54
from raven.conf import setup_logging
65
from raven.handlers.logging import SentryHandler
76
from raven.processors import SanitizePasswordsProcessor
87
from sirbot.plugins.slack import SlackPlugin
98
from sirbot import SirBot
109
import raven
1110

11+
from pybot.endpoints import handle_health_check
1212
from . import endpoints
1313
from .plugins import AirtablePlugin
1414
from pybot.endpoints.slack.utils import PORT, HOST
@@ -34,7 +34,9 @@ def make_sentry_logger():
3434
with open(
3535
os.path.join(os.path.dirname(os.path.realpath(__file__)), "../logging.yml")
3636
) as log_configfile:
37-
logging.config.dictConfig(yaml.load(log_configfile.read()))
37+
logging.config.dictConfig(
38+
yaml.load(log_configfile.read(), Loader=yaml.SafeLoader)
39+
)
3840
except Exception as e:
3941
logging.basicConfig(level=logging.DEBUG)
4042
logger.exception(e)
@@ -53,7 +55,7 @@ def make_sentry_logger():
5355
bot.load_plugin(airtable)
5456

5557
# Add route to respond to AWS health check
56-
bot.router.add_get("/health", lambda request: Response(status=200))
58+
bot.router.add_get("/health", handle_health_check)
5759
logging.getLogger("aiohttp.access").setLevel(logging.WARNING)
5860

5961
bot.start(host=HOST, port=PORT, print=logger.info)

pybot/endpoints/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
from aiohttp.web_response import Response
2+
13
from . import slack, airtable
4+
5+
6+
async def handle_health_check(request):
7+
return Response(status=200)

pybot/endpoints/slack/message_templates/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def mentor_request_attachments(services, mentors, skillsets):
6565
"text": "Specific Mentor",
6666
"name": "mentor",
6767
"options": [
68-
*[{"text": mentor, "value": mentor} for mentor in mentors],
68+
{"text": mentor, "value": mentor} for mentor in mentors
6969
],
7070
},
7171
{

pybot/plugins/airtable/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import functools
12
import logging
23
from collections import defaultdict
34

@@ -99,7 +100,7 @@ async def find_mentors_with_matching_skillsets(self, skillsets):
99100

100101
return complete_match or partial_match
101102

102-
async def find_records(self, table_name, field, value: str) -> list:
103+
async def find_records(self, table_name: str, field: str, value: str) -> list:
103104
url = self.table_url(table_name)
104105

105106
params = {"filterByFormula": f"FIND(LOWER('{value}'), LOWER({{{field}}}))"}
@@ -109,7 +110,7 @@ async def find_records(self, table_name, field, value: str) -> list:
109110
return response["records"]
110111
except Exception as ex:
111112
logger.exception(
112-
"Exception when attempting to get mentor id from slack email.", ex
113+
f"Exception when attempting to get {field} from {table_name}.", ex
113114
)
114115
return []
115116

0 commit comments

Comments
 (0)