Skip to content

Commit ffa7862

Browse files
committed
Modernize app
1 parent 2565db8 commit ffa7862

File tree

12 files changed

+808
-911
lines changed

12 files changed

+808
-911
lines changed

.gitignore

Lines changed: 51 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,3 @@
1-
.DS_Store
2-
3-
4-
# Created by https://www.gitignore.io/api/macos,linux,python,windows
5-
# Edit at https://www.gitignore.io/?templates=macos,linux,python,windows
6-
7-
### Linux ###
8-
*~
9-
10-
# temporary files which can be created if a process still has a handle open of a deleted file
11-
.fuse_hidden*
12-
13-
# KDE directory preferences
14-
.directory
15-
16-
# Linux trash folder which might appear on any partition or disk
17-
.Trash-*
18-
19-
# .nfs files are created when an open file is removed but is still being accessed
20-
.nfs*
21-
22-
### macOS ###
23-
# General
24-
.DS_Store
25-
.AppleDouble
26-
.LSOverride
27-
28-
# Icon must end with two \r
29-
Icon
30-
31-
# Thumbnails
32-
._*
33-
34-
# Files that might appear in the root of a volume
35-
.DocumentRevisions-V100
36-
.fseventsd
37-
.Spotlight-V100
38-
.TemporaryItems
39-
.Trashes
40-
.VolumeIcon.icns
41-
.com.apple.timemachine.donotpresent
42-
43-
# Directories potentially created on remote AFP share
44-
.AppleDB
45-
.AppleDesktop
46-
Network Trash Folder
47-
Temporary Items
48-
.apdisk
49-
50-
### Python ###
511
# Byte-compiled / optimized / DLL files
522
__pycache__/
533
*.py[cod]
@@ -70,7 +20,6 @@ parts/
7020
sdist/
7121
var/
7222
wheels/
73-
pip-wheel-metadata/
7423
share/python-wheels/
7524
*.egg-info/
7625
.installed.cfg
@@ -97,8 +46,10 @@ htmlcov/
9746
nosetests.xml
9847
coverage.xml
9948
*.cover
49+
*.py,cover
10050
.hypothesis/
10151
.pytest_cache/
52+
cover/
10253

10354
# Translations
10455
*.mo
@@ -108,6 +59,7 @@ coverage.xml
10859
*.log
10960
local_settings.py
11061
db.sqlite3
62+
db.sqlite3-journal
11163

11264
# Flask stuff:
11365
instance/
@@ -120,6 +72,7 @@ instance/
12072
docs/_build/
12173

12274
# PyBuilder
75+
.pybuilder/
12376
target/
12477

12578
# Jupyter Notebook
@@ -130,10 +83,40 @@ profile_default/
13083
ipython_config.py
13184

13285
# pyenv
133-
.python-version
134-
135-
# celery beat schedule file
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
.pdm-python
112+
.pdm-build/
113+
114+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115+
__pypackages__/
116+
117+
# Celery stuff
136118
celerybeat-schedule
119+
celerybeat.pid
137120

138121
# SageMath parsed files
139122
*.sage.py
@@ -154,6 +137,9 @@ venv.bak/
154137
# Rope project settings
155138
.ropeproject
156139

140+
# mkdocs documentation
141+
/site
142+
157143
# mypy
158144
.mypy_cache/
159145
.dmypy.json
@@ -162,35 +148,18 @@ dmypy.json
162148
# Pyre type checker
163149
.pyre/
164150

165-
### Python Patch ###
166-
.venv/
167-
168-
### Windows ###
169-
# Windows thumbnail cache files
170-
Thumbs.db
171-
ehthumbs.db
172-
ehthumbs_vista.db
173-
174-
# Dump file
175-
*.stackdump
176-
177-
# Folder config file
178-
[Dd]esktop.ini
179-
180-
# Recycle Bin used on file shares
181-
$RECYCLE.BIN/
182-
183-
# Windows Installer files
184-
*.cab
185-
*.msi
186-
*.msix
187-
*.msm
188-
*.msp
189-
190-
# Windows shortcuts
191-
*.lnk
151+
# pytype static type analyzer
152+
.pytype/
192153

193-
# End of https://www.gitignore.io/api/macos,linux,python,windows
154+
# Cython debug symbols
155+
cython_debug/
194156

157+
# PyCharm
158+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160+
# and can be added to the global gitignore or merged into this file. For a more nuclear
161+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162+
#.idea/
195163

164+
.ruff_cache/
196165
.vscode/

.pre-commit-config.yaml

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,25 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
2+
- repo: https://github.com/psf/black
3+
rev: 23.7.0
44
hooks:
5-
- id: trailing-whitespace
6-
- id: end-of-file-fixer
7-
- id: check-yaml
8-
- id: check-added-large-files
9-
- id: check-ast
5+
- id: black
106

11-
- repo: https://github.com/asottile/pyupgrade
12-
rev: v2.34.0
7+
- repo: https://github.com/astral-sh/ruff-pre-commit
8+
rev: v0.0.280
139
hooks:
14-
- id: pyupgrade
10+
- id: ruff
11+
args: [--fix]
1512

16-
- repo: local
13+
- repo: https://github.com/patrick91/pre-commit-alex
14+
rev: aa5da9e54b92ab7284feddeaf52edf14b1690de3
1715
hooks:
18-
- id: mypy
19-
name: run mypy
20-
language: system
21-
entry: bash -c 'poetry run mypy "${@/backend\//./}"' --
22-
types: [python]
23-
files: ^backend/
24-
25-
- id: flake8
26-
name: run flake8
27-
language: system
28-
entry: bash -c 'poetry run flake8 "${@/backend\//./}"' --
29-
types: [python]
30-
31-
- id: isort
32-
name: run isort
33-
language: system
34-
entry: bash -c 'poetry run isort "${@/backend\//./}"' --
35-
types: [python]
16+
- id: alex
3617

37-
- id: black
38-
name: run black
39-
language: system
40-
entry: bash -c 'poetry run black "${@/backend\//./}"' --
41-
types: [python]
18+
- repo: https://github.com/pre-commit/pre-commit-hooks
19+
rev: v4.4.0
20+
hooks:
21+
- id: trailing-whitespace
22+
- id: check-merge-conflict
23+
- id: end-of-file-fixer
24+
exclude: ^tests/relay/snapshots
25+
- id: check-toml

Dockerfile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
FROM tiangolo/uvicorn-gunicorn:python3.8
1+
FROM python:3.11-slim
22

3-
# Install Poetry
4-
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
5-
cd /usr/local/bin && \
6-
ln -s /opt/poetry/bin/poetry && \
7-
poetry config virtualenvs.create false
3+
RUN apt-get update && apt-get install postgresql-client cmake -y
84

9-
# Copy using poetry.lock* in case it doesn't exist yet
10-
COPY ./pyproject.toml ./poetry.lock* /app/
5+
# install PDM
6+
RUN pip install -U pip setuptools wheel
7+
RUN pip install pdm
118

12-
RUN poetry install --no-root --no-dev
9+
# copy files
10+
COPY pyproject.toml pdm.lock /project/
11+
COPY . /project
1312

14-
COPY . /app
13+
WORKDIR /project
14+
# TODO: improve caching
15+
16+
RUN pdm install --prod --no-lock --no-editable -v
17+
18+
RUN SECRET_KEY=secret pdm run python manage.py collectstatic --noinput
19+
20+
EXPOSE 8080
21+
22+
CMD ["pdm", "server"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ file checks (and more) on
77
## How to run
88

99
```shell
10-
poetry install
11-
poetry run task server
10+
pdm install
11+
pdm dev
1212
```

app/github.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,24 @@ def has_signature(comment: GithubComment, slug: str) -> bool:
3131
)
3232

3333

34-
def get_comments_link(pr_number: int, repo: typing.Optional[str] = None) -> str:
34+
def get_comments_link(pr_number: int, repo: str | None = None) -> str:
3535
url = (
3636
f"/repos/strawberry-graphql/{repo or 'strawberry'}/issues/{pr_number}/comments"
3737
)
3838

3939
return API_BASE + url
4040

4141

42-
def get_labels_link(pr_number: int, repo: typing.Optional[str] = None) -> str:
42+
def get_labels_link(pr_number: int, repo: str | None = None) -> str:
4343
url = f"/repos/strawberry-graphql/{repo or 'strawberry'}/issues/{pr_number}/labels"
4444

4545
return API_BASE + url
4646

4747

4848
def get_comments(
49-
pr_number: int, repo: typing.Optional[str] = None
50-
) -> typing.List[GithubComment]:
49+
pr_number: int,
50+
repo: str | None = None,
51+
) -> list[GithubComment]:
5152
comments_link = get_comments_link(pr_number, repo=repo)
5253

5354
response = httpx.get(comments_link)
@@ -56,8 +57,9 @@ def get_comments(
5657

5758

5859
def get_labels(
59-
pr_number: int, repo: typing.Optional[str] = None
60-
) -> typing.List[GithubLabel]:
60+
pr_number: int,
61+
repo: str | None = None,
62+
) -> list[GithubLabel]:
6163
labels_link = get_labels_link(pr_number, repo=repo)
6264

6365
response = httpx.get(labels_link)
@@ -66,8 +68,11 @@ def get_labels(
6668

6769

6870
def add_or_edit_comment(
69-
pr_number: int, comment_template: str, slug: str, repo: typing.Optional[str] = None
70-
):
71+
pr_number: int,
72+
comment_template: str,
73+
slug: str,
74+
repo: str | None = None,
75+
) -> None:
7176
current_comments = get_comments(pr_number, repo=repo)
7277

7378
previous_comment = next(
@@ -92,10 +97,12 @@ def add_or_edit_comment(
9297

9398

9499
def update_labels(
95-
pr_number: int, release_info: typing.Optional[ReleaseInfo], repo: str | None = None
96-
):
100+
pr_number: int,
101+
release_info: ReleaseInfo | None,
102+
repo: str | None = None,
103+
) -> None:
97104
labels_to_add = {"bot:has-release-file"}
98-
labels_to_remove: typing.Set[str] = set()
105+
labels_to_remove: set[str] = set()
99106

100107
new_release_label = None
101108

0 commit comments

Comments
 (0)