Skip to content

Commit 5fe2e17

Browse files
authored
chore: upgrade project boilerplate (#80)
I'm not expecting the full project to work. Just focusing on the Python boilerplate
1 parent d008d50 commit 5fe2e17

26 files changed

+1040
-940
lines changed

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "uv"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "npm"
10+
directory: "/"
11+
schedule:
12+
interval: "monthly"
13+
open-pull-requests-limit: 10
14+
15+
- package-ecosystem: "github-actions"
16+
directory: "/"
17+
schedule:
18+
interval: "monthly"
19+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ jobs:
1010
lint-py:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
15-
with:
16-
python-version: "3.10"
17-
- run: pip install black
18-
- run: black --check .
13+
- uses: actions/checkout@v6
14+
# https://github.com/astral-sh/setup-uv/releases
15+
- uses: astral-sh/setup-uv@v7
16+
- run: uv sync --all-extras
17+
- run: uv run ruff check .
18+
- run: uv run ruff format --check .
1919
lint-js:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v2
23-
- uses: actions/setup-node@v1
22+
- uses: actions/checkout@v6
23+
- uses: actions/setup-node@v6
2424
with:
2525
node-version: "16.x"
2626
- run: npm install eslint
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
services:
3131
db:
32-
image: postgis/postgis:12-3.0-alpine
32+
image: postgis/postgis:16-3.5-alpine
3333
env:
3434
POSTGRES_USER: postgres
3535
POSTGRES_PASSWORD: postgres
@@ -38,16 +38,11 @@ jobs:
3838
- 5432:5432
3939
options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
4040
steps:
41-
- uses: actions/checkout@v2
42-
- uses: actions/setup-python@v2
43-
with:
44-
python-version: "3.10"
41+
- uses: actions/checkout@v6
42+
# https://github.com/astral-sh/setup-uv/releases
43+
- uses: astral-sh/setup-uv@v7
4544
- run: sudo apt-get install -y libpq-dev libgeos-dev gdal-bin
46-
- run: |
47-
pip install poetry
48-
poetry install -v
49-
env:
50-
POETRY_VIRTUALENVS_IN_PROJECT: true
45+
- run: uv sync --all-extras
5146
- run: make test
5247
env:
5348
DATABASE_URL: postgis://postgres:[email protected]/github_actions

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
MANAGE=poetry run python manage.py
1+
MANAGE=uv run python manage.py
22

33
help: ## Shows this help
44
@echo "$$(grep -h '#\{2\}' $(MAKEFILE_LIST) | sed 's/: #\{2\} / /' | column -t -s ' ')"
55

66
install: ## Install requirements
7-
poetry install
7+
uv sync --upgrade --all-extras
88
npm install
99

1010
clean: ## Remove temporary files
@@ -23,12 +23,13 @@ tdd: ## Run tests with a watcher
2323
nodemon --ext py -x sh -c "$(MANAGE) test --failfast --keepdb || true"
2424

2525
lint: ## Run lint check
26-
black --check .
26+
uv run ruff check .
27+
uv run ruff format --check .
2728

2829
resetmigrations:
2930
find . -name "0001_initial.py" -delete
3031
$(MANAGE) makemigrations receipts lazy_geo
31-
black .
32+
uv run ruff format .
3233

3334
resetdb: ## Delete and recreate the database
3435
-phd dropdb

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.8'
2+
3+
services:
4+
db:
5+
image: postgis/postgis:16-3.4
6+
environment:
7+
POSTGRES_DB: mixed_beverages
8+
POSTGRES_USER: postgres
9+
POSTGRES_PASSWORD: postgres
10+
ports:
11+
- "5432:5432"
12+
volumes:
13+
- postgres_data:/var/lib/postgresql/data
14+
15+
volumes:
16+
postgres_data:

mixed_beverages/apps/lazy_geo/models.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
from django.conf import settings
21
from django.contrib.gis.db import models
3-
from django.contrib.gis.geos import Point
4-
from django.core.exceptions import SuspiciousOperation
5-
from django.urls import reverse
6-
from django.utils import timezone
72

83

94
class BaseTAMULocation(models.Model):
@@ -61,7 +56,9 @@ class BaseGeocodioLocation(models.Model):
6156
decimal_places=2,
6257
null=True,
6358
blank=True,
64-
help_text="1 is most accuracy, 0.8 is pretty close, anything less than 0.6 is bad",
59+
help_text=(
60+
"1 is most accuracy, 0.8 is pretty close, anything less than 0.6 is bad"
61+
),
6562
)
6663

6764
class Meta:

mixed_beverages/apps/lazy_geo/views.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
import json
2-
3-
from django.contrib.admin.views.decorators import staff_member_required
4-
from django.urls import reverse
51
from django.db.models import Q
62
from django.http import (
7-
HttpResponseBadRequest,
83
JsonResponse,
9-
HttpResponseRedirect,
10-
HttpResponseForbidden,
114
)
125
from django.shortcuts import get_object_or_404
13-
from django.utils.decorators import method_decorator
14-
from django.views.generic import DetailView
156
from djgeojson.views import GeoJSONLayerView
7+
168
from mixed_beverages.apps.receipts import models
179

1810

mixed_beverages/apps/receipts/admin.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from django.contrib import admin
2-
from django.contrib.gis.admin import GeoModelAdmin
32
from django.urls import reverse
43
from django.utils.safestring import mark_safe
54

@@ -29,7 +28,7 @@ class BusinessAdmin(admin.ModelAdmin):
2928

3029

3130
@admin.register(models.Location)
32-
class LocationAdmin(GeoModelAdmin):
31+
class LocationAdmin(admin.ModelAdmin):
3332
list_display = ("name", "street_address", "city", "state", "zip")
3433
list_filter = ("coordinate_quality",)
3534
search_fields = ("name",)
@@ -90,10 +89,9 @@ class ReceiptAdmin(admin.ModelAdmin):
9089
"location_link",
9190
)
9291

92+
@admin.display(description="location")
9393
def location_link(self, obj):
9494
url = reverse("admin:receipts_location_change", args=(obj.location.pk,))
9595
return mark_safe(
9696
f'<a href="{url}">{obj.location}<br>{obj.location.address}</a>'
9797
)
98-
99-
location_link.short_description = "location" # type: ignore

mixed_beverages/apps/receipts/factories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from datetime import date
21
import string
2+
from datetime import date
33

44
import factory
55
from factory.fuzzy import FuzzyDate, FuzzyDecimal, FuzzyText

mixed_beverages/apps/receipts/management/commands/geo_export.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from django.core.management.base import BaseCommand
21
from csv import DictWriter
32

3+
from django.core.management.base import BaseCommand
4+
45
from mixed_beverages.apps.receipts.models import Location
56

67

mixed_beverages/apps/receipts/management/commands/geo_import.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import os.path
2-
32
from csv import DictReader
3+
44
from django.contrib.gis.geos import Point
55
from django.core.management.base import BaseCommand
6-
from obj_update import obj_update_or_create
76
from tqdm import tqdm
87

98
from mixed_beverages.apps.receipts.models import Location
@@ -23,7 +22,7 @@ def add_arguments(self, parser):
2322
def handle(self, csv: str, ignore_pk: bool, *args, **options):
2423
assert os.path.isfile(csv)
2524

26-
with open(csv, "r") as fh:
25+
with open(csv) as fh:
2726
row_count = sum(1 for row in fh)
2827
fh.seek(0)
2928
reader = DictReader(fh)
@@ -38,7 +37,7 @@ def handle(self, csv: str, ignore_pk: bool, *args, **options):
3837
)
3938
else:
4039
location = Location.objects.get(pk=row["pk"])
41-
except:
40+
except Exception:
4241
continue
4342
location.coordinate = Point(
4443
x=float(row["Longitude"]), y=float(row["Latitude"])

0 commit comments

Comments
 (0)