Skip to content

Commit b32a3e5

Browse files
committed
cleanliness
1 parent 9c94b5a commit b32a3e5

File tree

10 files changed

+57
-50
lines changed

10 files changed

+57
-50
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 99

cla/comments.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
from cla.constants import NOT_SIGNED_BADGE, SENTINEL_MARKER, SIGNED_BADGE
44

55

6-
async def post_or_update_comment(
7-
gh, message, target_repository_full_name, pull_request_number
8-
):
6+
async def post_or_update_comment(gh, message, target_repository_full_name, pull_request_number):
97
# Check for existing comment
108
existing_comment = None
119
async for comment in gh.getiter(
@@ -40,19 +38,13 @@ async def post_or_update_fail_comment(
4038
f"[![CLA signed]({NOT_SIGNED_BADGE})]({settings.SITE_URL})"
4139
f"{SENTINEL_MARKER}"
4240
)
43-
await post_or_update_comment(
44-
gh, message, target_repository_full_name, pull_request_number
45-
)
41+
await post_or_update_comment(gh, message, target_repository_full_name, pull_request_number)
4642

4743

48-
async def post_or_update_success_comment(
49-
gh, target_repository_full_name, pull_request_number
50-
):
44+
async def post_or_update_success_comment(gh, target_repository_full_name, pull_request_number):
5145
message = (
5246
"All commit authors signed the Contributor License Agreement.\n\n"
5347
f"[![CLA signed]({SIGNED_BADGE})]({settings.SITE_URL})"
5448
f"{SENTINEL_MARKER}"
5549
)
56-
await post_or_update_comment(
57-
gh, message, target_repository_full_name, pull_request_number
58-
)
50+
await post_or_update_comment(gh, message, target_repository_full_name, pull_request_number)

cla/constants.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
SIGNED_BADGE = (
2-
"https://img.shields.io/badge/"
3-
"CLA%20Signed-FAE085"
4-
"?style=flat-square"
5-
"&logo=Python"
6-
)
1+
SIGNED_BADGE = "https://img.shields.io/badge/CLA%20Signed-FAE085?style=flat-square&logo=Python"
72
NOT_SIGNED_BADGE = (
83
"https://img.shields.io/badge/"
9-
"CLA%20Not%20Signed-fa858b"
10-
"?style=flat-square"
11-
"&logo=Python"
12-
"&logoColor=ffffff"
4+
"CLA%20Not%20Signed-fa858b?style=flat-square&logo=Python&logoColor=ffffff"
135
)
146
SENTINEL_MARKER = "<!-- CLA BOT SIGNING COMMENT DO NOT EDIT -->"

cla/events.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ async def handle_pull_request(event, gh, *args, **kwargs):
2727
github_user_id = event.data.get("pull_request").get("user", {}).get("id")
2828
pull_request_id = event.data.get("pull_request", {}).get("id")
2929
pull_request_number = event.data.get("pull_request", {}).get("number")
30-
pull_request_head_sha = (
31-
event.data.get("pull_request", {}).get("head", {}).get("sha")
32-
)
30+
pull_request_head_sha = event.data.get("pull_request", {}).get("head", {}).get("sha")
3331
pull_request_url = event.data.get("pull_request", {}).get("html_url")
3432
target_repository_id = event.data.get("repository", {}).get("id")
3533
target_repository_full_name = event.data.get("repository", {}).get("full_name")
@@ -99,8 +97,7 @@ async def handle_pull_request(event, gh, *args, **kwargs):
9997
for author in authors:
10098
normalized_email = re.sub(r"\+[^)]*@", "@", author.email)
10199
signature = await Signature.objects.filter(
102-
Q(email_address__iexact=author.email)
103-
| Q(normalized_email__iexact=normalized_email)
100+
Q(email_address__iexact=author.email) | Q(normalized_email__iexact=normalized_email)
104101
).afirst()
105102
if signature is None:
106103
await PendingSignature.objects.aupdate_or_create(
@@ -119,9 +116,7 @@ async def handle_pull_request(event, gh, *args, **kwargs):
119116
if needs_signing:
120117
await fail_status_check(gh, target_repository_full_name, pull_request_head_sha)
121118
else:
122-
await succeed_status_check(
123-
gh, target_repository_full_name, pull_request_head_sha
124-
)
119+
await succeed_status_check(gh, target_repository_full_name, pull_request_head_sha)
125120

126121
# Send/Update comments
127122
if needs_signing:
@@ -130,6 +125,4 @@ async def handle_pull_request(event, gh, *args, **kwargs):
130125
gh, email_addresses, target_repository_full_name, pull_request_number
131126
)
132127
else:
133-
await post_or_update_success_comment(
134-
gh, target_repository_full_name, pull_request_number
135-
)
128+
await post_or_update_success_comment(gh, target_repository_full_name, pull_request_number)

cla/migrations/0001_initial.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
class Migration(migrations.Migration):
11-
1211
initial = True
1312

1413
dependencies = [
@@ -65,7 +64,11 @@ class Migration(migrations.Migration):
6564
(
6665
"document",
6766
markdownx.models.MarkdownxField(
68-
help_text="The document that contributors will sign <b>cannot</b> be edited or deleted after it has been created. You will have to draft, save, and assign a new document"
67+
help_text=(
68+
"The document that contributors will sign "
69+
"<b>cannot</b> be edited or deleted after it has been created. "
70+
"You will have to draft, save, and assign a new document"
71+
)
6972
),
7073
),
7174
("default", models.BooleanField(default=False)),

cla/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ class RepositoryMapping(models.Model):
8080
created_at = models.DateTimeField(auto_now_add=True)
8181
updated_at = models.DateTimeField(auto_now=True)
8282

83-
github_repository = models.ForeignKey(
84-
Repository, null=True, on_delete=models.SET_NULL
85-
)
83+
github_repository = models.ForeignKey(Repository, null=True, on_delete=models.SET_NULL)
8684
agreement = models.ForeignKey(Agreement, on_delete=models.PROTECT)
8785

8886
def __str__(self):

clabot/views.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def get_context_data(self, **kwargs):
2020
context = super().get_context_data(**kwargs)
2121
default_agreement = Agreement.objects.filter(default=True).first()
2222
if default_agreement:
23-
context["agreement"] = markdown.markdown(
24-
default_agreement.document
25-
)
23+
context["agreement"] = markdown.markdown(default_agreement.document)
2624
else:
2725
context["agreement"] = None
2826
return context
@@ -59,12 +57,8 @@ async def sign(request):
5957
return HttpResponseRedirect("/")
6058

6159
emails = await sync_to_async(request.session.get)("emails")
62-
if email_address.lower() not in [
63-
e["email"].lower() for e in emails if e["verified"]
64-
]:
65-
messages.info(
66-
request, "Cannot sign using an email that has not been verified on GitHub."
67-
)
60+
if email_address.lower() not in [e["email"].lower() for e in emails if e["verified"]]:
61+
messages.info(request, "Cannot sign using an email that has not been verified on GitHub.")
6862
return HttpResponseRedirect("/")
6963

7064
if request.method == "POST":
@@ -83,9 +77,7 @@ async def sign(request):
8377
agreement_id=agreement_id, email_address__iexact=email_address
8478
).all()
8579
):
86-
to_resolve[pending_signature.github_repository_id].add(
87-
pending_signature.ref
88-
)
80+
to_resolve[pending_signature.github_repository_id].add(pending_signature.ref)
8981
for repository_id, refs in to_resolve.items():
9082
repository = await Repository.objects.select_related("installation").aget(
9183
repository_id=repository_id

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[tool.black]
2+
exclude = "migrations"
3+
line-length = 99
4+
[tool.isort]
5+
profile = "black"
6+
skip_glob = ["*/migrations/*"]

requirements.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
# Dev
12
black
23
daphne
4+
flake8
5+
isort
6+
pip-tools
7+
8+
# Base
39
dj-database-url
410
django
511
django-github-app

requirements.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ automat==24.8.1
2020
# via twisted
2121
black==25.1.0
2222
# via -r requirements.in
23+
build==1.2.2.post1
24+
# via pip-tools
2325
cachetools==5.5.2
2426
# via django-github-app
2527
certifi==2025.1.31
@@ -36,6 +38,7 @@ click==8.1.8
3638
# via
3739
# black
3840
# django-typer
41+
# pip-tools
3942
# typer-slim
4043
# uvicorn
4144
constantly==23.10.4
@@ -65,6 +68,8 @@ django-typer[rich]==3.1.0
6568
# via django-github-app
6669
environs==14.1.1
6770
# via -r requirements.in
71+
flake8==7.2.0
72+
# via -r requirements.in
6873
gidgethub==5.3.0
6974
# via django-github-app
7075
gunicorn==23.0.0
@@ -90,12 +95,16 @@ idna==3.10
9095
# twisted
9196
incremental==24.7.2
9297
# via twisted
98+
isort==6.0.1
99+
# via -r requirements.in
93100
markdown==3.7
94101
# via django-markdownx
95102
markdown-it-py==3.0.0
96103
# via rich
97104
marshmallow==3.26.1
98105
# via environs
106+
mccabe==0.7.0
107+
# via flake8
99108
mdurl==0.1.2
100109
# via markdown-it-py
101110
mypy-extensions==1.0.0
@@ -105,12 +114,15 @@ oauthlib==3.2.2
105114
packaging==24.2
106115
# via
107116
# black
117+
# build
108118
# gunicorn
109119
# marshmallow
110120
pathspec==0.12.1
111121
# via black
112122
pillow==11.1.0
113123
# via django-markdownx
124+
pip-tools==7.4.1
125+
# via -r requirements.in
114126
platformdirs==4.3.7
115127
# via black
116128
psycopg2-binary==2.9.10
@@ -121,8 +133,12 @@ pyasn1==0.6.1
121133
# service-identity
122134
pyasn1-modules==0.4.2
123135
# via service-identity
136+
pycodestyle==2.13.0
137+
# via flake8
124138
pycparser==2.22
125139
# via cffi
140+
pyflakes==3.3.2
141+
# via flake8
126142
pygments==2.19.1
127143
# via rich
128144
pyjwt[crypto]==2.10.1
@@ -131,6 +147,10 @@ pyjwt[crypto]==2.10.1
131147
# pyjwt
132148
pyopenssl==25.0.0
133149
# via twisted
150+
pyproject-hooks==1.2.0
151+
# via
152+
# build
153+
# pip-tools
134154
python-dotenv==1.1.0
135155
# via environs
136156
requests==2.32.3
@@ -166,10 +186,13 @@ urllib3==2.3.0
166186
# sentry-sdk
167187
uvicorn==0.34.0
168188
# via -r requirements.in
189+
wheel==0.45.1
190+
# via pip-tools
169191
whitenoise==6.9.0
170192
# via -r requirements.in
171193
zope-interface==7.2
172194
# via twisted
173195

174196
# The following packages are considered to be unsafe in a requirements file:
197+
# pip
175198
# setuptools

0 commit comments

Comments
 (0)