Skip to content

Commit 50ebdd6

Browse files
authored
Add Ruff formatting and linting (#313)
* Ruff linter and formatter * Add pre-commit as dependency * Use Penn Clubs ruff settings * Add to CICD * Add linting to new changes
1 parent 8a224a1 commit 50ebdd6

29 files changed

+1641
-961
lines changed

.github/workflows/build-and-deploy.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ jobs:
1515
run: |-
1616
cd .
1717
uv sync --frozen
18+
- name: Lint
19+
run: |-
20+
cd .
21+
uv run ruff check .
22+
- name: Format
23+
run: |-
24+
cd .
25+
uv run ruff format .
1826
- name: Test (run in parallel)
1927
run: |-
2028
cd .

.pre-commit-config.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
repos:
2-
- repo: https://github.com/pennlabs/pre-commit-hooks
3-
rev: stable
2+
- repo: local
43
hooks:
5-
- id: black
6-
- id: isort
7-
- id: flake8
4+
- id: ruff-format
5+
name: Ruff Formatter
6+
entry: uv run ruff format .
7+
language: python
8+
types: [python]
9+
require_serial: true
10+
files: /
11+
pass_filenames: false
12+
- id: ruff-lint-fix
13+
name: Ruff Lint (Apply Fixes)
14+
entry: uv run ruff check . --fix
15+
language: python
16+
types: [python]
17+
require_serial: true
18+
files: /

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,33 @@
11
Common Funding Application
2-
=============================
2+
==========================
33

44
[![CircleCI](https://circleci.com/gh/pennlabs/common-funding-application.svg?style=shield)](https://circleci.com/gh/pennlabs/common-funding-application)
55
[![Coverage Status](https://codecov.io/gh/pennlabs/common-funding-application/branch/master/graph/badge.svg)](https://codecov.io/gh/pennlabs/common-funding-application)
66

77
The [Common Funding Application](https://penncfa.com) is an online application that allows student groups and organizations to request funding from various funding sources at the [University of Pennsylvania](http://www.upenn.edu).
88

99
## Local Backend Setup
10-
* Install [uv](https://docs.astral.sh/uv/getting-started/installation/)
1110

11+
* Install [uv](https://docs.astral.sh/uv/getting-started/installation/)
1212
* Install `mysql_config` (Ubuntu: `apt install libmysqlclient-dev` / MacOS: `brew install mysql-connector-c`)
13-
1413
* Install python dependencies (`uv sync`)
15-
14+
* Install pre-commit (`uv run pre-commit install`)
1615
* Migrate database (`uv run manage.py migrate`)
17-
1816
* Import dummy data (`uv run import_demo.py`)
19-
2017
* Run the server (`uv run manage.py runserver`)
21-
2218
* Navigate to the [app](http://localhost:8000/)
23-
2419
* Example login credntials: `philo / philo` for requester, `spectrum / spectrum` for funder
2520

2621
## Front-End Setup
2722

2823
* Install [Bun](https://bun.sh/docs/installation)
29-
3024
* Install [Mocha](https://mochajs.org/#installation) (`bun install -g mocha`)
31-
3225
* Run tests (`mocha app/static/test/`)
3326

3427
## DB migrations
3528

3629
* Edit models.py
37-
3830
* `uv run manage.py makemigrations`
39-
4031
* `uv run manage.py migrate`
4132

4233
## Environment Variables

app/admin.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
from django.contrib import admin
2-
3-
from .models import (CFAUser, CommonFreeResponseQuestion, EligibilityQuestion,
4-
FreeResponseQuestion, FunderConstraint, Event,
5-
CommonFollowupQuestion, FollowupQuestion, CCEmail)
6-
7-
from django.contrib.sites.models import Site
82
from django.contrib.auth.models import Group
3+
from django.contrib.sites.models import Site
4+
5+
from .models import (
6+
CCEmail,
7+
CFAUser,
8+
CommonFollowupQuestion,
9+
CommonFreeResponseQuestion,
10+
EligibilityQuestion,
11+
Event,
12+
FollowupQuestion,
13+
FreeResponseQuestion,
14+
FunderConstraint,
15+
)
916

1017

1118
class CFAUserAdmin(admin.ModelAdmin):
12-
filter_horizontal = ('cc_emails',)
13-
search_fields = ('user__username',)
14-
list_display = ('user', 'user_type', 'osa_email')
15-
list_filter = ('user_type',)
19+
filter_horizontal = ("cc_emails",)
20+
search_fields = ("user__username",)
21+
list_display = ("user", "user_type", "osa_email")
22+
list_filter = ("user_type",)
1623

1724

1825
class EventAdmin(admin.ModelAdmin):
19-
search_fields = ('name', 'requester__user__username')
20-
list_filter = ('status', 'created_at')
26+
search_fields = ("name", "requester__user__username")
27+
list_filter = ("status", "created_at")
2128

2229

2330
admin.site.unregister(Group)

app/forms.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
from django import forms
2-
from django.contrib.auth.forms import (PasswordChangeForm as BasePasswordChangeForm,
3-
PasswordResetForm as BasePasswordResetForm,
4-
SetPasswordForm as BaseSetPasswordForm)
5-
from django.core.validators import RegexValidator, EmailValidator
2+
from django.contrib.auth.forms import (
3+
PasswordChangeForm as BasePasswordChangeForm,
4+
)
5+
from django.contrib.auth.forms import (
6+
PasswordResetForm as BasePasswordResetForm,
7+
)
8+
from django.contrib.auth.forms import (
9+
SetPasswordForm as BaseSetPasswordForm,
10+
)
11+
from django.core.validators import EmailValidator
612
from django_registration.forms import RegistrationForm as BaseRegistrationForm
713

814
from .models import Event
@@ -75,8 +81,19 @@ def save(self, commit=True):
7581

7682
class Meta:
7783
model = Event
78-
fields = ["name", "date", "time", "location", "contact_name", "contact_email", "contact_phone", "anticipated_attendance",
79-
"advisor_email", "advisor_phone", "organizations"]
84+
fields = [
85+
"name",
86+
"date",
87+
"time",
88+
"location",
89+
"contact_name",
90+
"contact_email",
91+
"contact_phone",
92+
"anticipated_attendance",
93+
"advisor_email",
94+
"advisor_phone",
95+
"organizations",
96+
]
8097
labels = {
8198
"name": "Event Name",
8299
"date": "Event Date",
@@ -91,8 +108,10 @@ class Meta:
91108
"contact_name": "Primary contact's name",
92109
"contact_email": "Primary contact's email address",
93110
"contact_phone": "Primary contact's phone number",
94-
"anticipated_attendance": "Anticipated number of people attending the event",
111+
"anticipated_attendance": (
112+
"Anticipated number of people attending the event"
113+
),
95114
"advisor_email": "Advisor's email address",
96115
"advisor_phone": "Advisor's phone number",
97-
"organizations": "Organization(s) involved with the event"
116+
"organizations": "Organization(s) involved with the event",
98117
}

0 commit comments

Comments
 (0)