Skip to content

Commit 43ba554

Browse files
chore: fix merge commit
2 parents 899cb27 + bc05636 commit 43ba554

File tree

12 files changed

+49
-57
lines changed

12 files changed

+49
-57
lines changed

.github/workflows/hooks/pre-commit.py

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/usr/bin/env python3
2-
"""Helper script to be used as a pre-commit hook."""
1+
#!/usr/bin/env python
2+
33
import os
44
import sys
55
import subprocess

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ repos:
1717
- id: check-yaml
1818
- id: check-added-large-files
1919
args: ['--maxkb=1024']
20-
- id: check-docstring-first
21-
exclude: |
22-
(?x)^(
23-
hello.py
24-
)$
2520
- id: check-executables-have-shebangs
2621
- id: check-merge-conflict
2722
- id: check-shebang-scripts-are-executable

Dockerfile.web

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ WORKDIR /app
3030
COPY ./app .
3131
COPY ./requirements.txt .
3232

33-
RUN python -m venv $VENV
33+
RUN python -m venv $VENV \
34+
&& python -m pip install -r requirements.txt
3435

35-
RUN --mount=type=cache,target=/root/.cache/pip \
36-
--mount=type=bind,source=./requirements.txt,target=/app/requirements.txt \
37-
python -m pip install -r requirements.txt
36+
# ! heroku doesn't use buildkit
37+
# RUN --mount=type=cache,target=/root/.cache/pip \
38+
# --mount=type=bind,source=./requirements.txt,target=/app/requirements.txt \
39+
# python -m pip install -r requirements.txt
3840

3941
FROM python:${PYTHON_VERSION}-slim-bullseye AS runner
4042

Makefile

100644100755
File mode changed.

app/gunicorn.conf.py

100755100644
File mode changed.

app/main.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def load_user(username: str):
279279
Startup
280280
"""
281281

282+
# TODO: https://fastapi.tiangolo.com/advanced/events/
282283
@app.on_event('startup')
283284
def startup_event():
284285
"""
@@ -327,6 +328,7 @@ def generate_token(current_user: User = Depends(get_current_active_user)):
327328
access_token = tokens['access_token']
328329
refresh_token = tokens['refresh_token']
329330
except KeyError as e:
331+
print(f"{Fore.RED}{error:<10}{Fore.RESET}KeyError: {e}")
330332
raise HTTPException(status_code=500, detail="Internal Server Error")
331333

332334
return access_token, refresh_token
@@ -421,7 +423,12 @@ def main():
421423
import uvicorn
422424

423425
try:
424-
uvicorn.run("main:app", host="0.0.0.0", port=PORT, limit_max_requests=10000, log_level="warning", reload=True)
426+
uvicorn.run("main:app",
427+
host="0.0.0.0",
428+
port=PORT,
429+
limit_max_requests=10000,
430+
log_level="warning",
431+
reload=True)
425432
except KeyboardInterrupt:
426433
print("\nExiting...")
427434
sys.exit(0)

app/sign_jwt.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from colorama import Fore
1010
from cryptography.hazmat.primitives import serialization
1111
from cryptography.hazmat.backends import default_backend
12-
from decouple import Config, RepositoryEnv
12+
from decouple import config
1313
from icecream import ic
1414
from pathlib import Path
1515
from urllib.parse import urlencode
@@ -22,15 +22,6 @@
2222
error = "ERROR:"
2323
warning = "WARNING:"
2424

25-
# get .env file
26-
if not Path(".env").exists():
27-
env_file = Path(__file__).parent / '.env'
28-
else:
29-
env_file = Path(".env")
30-
31-
# decouple read .env file
32-
config = Config(RepositoryEnv(env_file))
33-
3425
# creds
3526
if Path('jwt_priv.pem').exists():
3627
priv_key = Path('jwt_priv.pem')

app/tests/test_meetup_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_send_request(datafiles, requests_mock):
5252
assert re.search(r'200', res)
5353

5454
# * spot check of raw response length is > 25000 chars
55-
assert (type(res) is str) and len(res) >= 1000
55+
assert isinstance(res, str) and len(res) >= 1000
5656
assert re.search(r'"name": "Techlahoma"', res)
5757
assert re.search(r'"memberUrl": "https://www.meetup.com/members/186454903"', res)
5858

app/tests/test_sign_jwt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ def test_sign_token():
4545
"""Test sign_token()"""
4646
token = sign_token()
4747

48-
assert (type(token) is str) and len(token) >= 1030
48+
assert isinstance(token, str) and len(token) >= 1030
4949

5050

5151
def test_verify_token():
5252
"""Test verify_token()"""
5353
token = sign_token()
5454

55-
assert verify_token(token) == True
55+
if verify_token(token):
56+
assert True
5657

5758

5859
# TODO: mock requests.post() to test get_access_token()
@@ -66,4 +67,3 @@ def test_get_access_token():
6667
assert res.text.find('refresh_token') != -1
6768
assert res.text.find('token_type') != -1
6869
assert res.text.find('expires_in') != -1
69-

heroku.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setup:
1010
APP_NAME: meetup-bot-bot
1111
build:
1212
docker:
13-
web: ./app/Dockerfile.web
13+
web: ./Dockerfile.web
1414
# * Defaults to Dockerfile CMD if `run` isn't declared
1515
# run:
1616
# web: gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:${PORT:-3000} --log-file -

0 commit comments

Comments
 (0)