Skip to content

Commit 543e4a4

Browse files
JacobCoffeeclaude
andcommitted
fix: use dependency-groups for dev deps, guard debug_toolbar import
Dev dependencies are defined under [dependency-groups] (PEP 735), not [project.optional-dependencies]. Use `pip install --group dev` instead of `pip install '.[dev]'` in CI and Dockerfile. Guard debug_toolbar imports in local.py and urls.py with scoped ModuleNotFoundError checks so missing transitive deps still surface. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1b9afc1 commit 543e4a4

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
restore-keys: ${{ runner.os }}-pip-
3333

3434
- name: Install dependencies
35-
run: pip install -e '.[dev]'
35+
run: pip install --group dev -e .
3636

3737
- name: Check for ungenerated migrations
3838
run: python manage.py makemigrations --check --dry-run
@@ -82,9 +82,7 @@ jobs:
8282
restore-keys: ${{ runner.os }}-pip-
8383

8484
- name: Install dependencies
85-
run: |
86-
pip install -U pip setuptools wheel
87-
pip install -e '.[dev]'
85+
run: pip install --group dev -e .
8886

8987
- name: Run tests
9088
run: python -Wd -m coverage run manage.py test -v2

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ COPY pyproject.toml /code/
3939
RUN --mount=type=cache,target=/root/.cache/pip \
4040
set -x \
4141
&& pip --disable-pip-version-check \
42-
install \
43-
'.[dev]'
42+
install --group dev \
43+
.
4444

4545
COPY . /code/
4646

pydotorg/settings/local.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@
2525
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
2626

2727

28-
INSTALLED_APPS += [
29-
"debug_toolbar",
30-
]
31-
32-
MIDDLEWARE += [
33-
"debug_toolbar.middleware.DebugToolbarMiddleware",
34-
]
28+
try:
29+
import debug_toolbar # noqa: F401
30+
31+
INSTALLED_APPS += [
32+
"debug_toolbar",
33+
]
34+
35+
MIDDLEWARE += [
36+
"debug_toolbar.middleware.DebugToolbarMiddleware",
37+
]
38+
except ModuleNotFoundError as exc:
39+
if exc.name != "debug_toolbar":
40+
raise
3541

3642
CACHES = {
3743
"default": {

pydotorg/urls.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373

7474
if settings.DEBUG:
7575
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
76-
import debug_toolbar
76+
try:
77+
import debug_toolbar
7778

78-
urlpatterns = [path("__debug__/", include(debug_toolbar.urls)), *urlpatterns]
79+
urlpatterns = [path("__debug__/", include(debug_toolbar.urls)), *urlpatterns]
80+
except ModuleNotFoundError as exc:
81+
if exc.name != "debug_toolbar":
82+
raise

0 commit comments

Comments
 (0)