Skip to content

fix(examples): check starters against the module that mounts Citry; start Django before importing the app - #236

Merged
JuroOravec merged 3 commits into
mainfrom
fix/starters-mount-check
Oct 21, 2026
Merged

JuroOravec merged 3 commits into
mainfrom
fix/starters-mount-check

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Stacked on #234; merge that first. It follows up #233's link check (rule_unknown_url). A link checker is registered only when the module given to --app mounts Citry, so this PR points each starter's check at that module, and makes the Django target work.

Starter check commands

Project --app target
FastAPI starter, project_board demo, htmx demo app.main:citry_app
Django starter config.urls:citry_app
Flask starter app.wsgi:citry_app, from a new app/wsgi.py that calls create_app() and re-exports citry_app, as the docs describe
Bare ASGI, bare WSGI, standalone unchanged: app.citry_app:citry_app

Each changed project's catalog entry, README, AGENTS.md, .github/workflows/check.yml and .vscode/settings.json use the new target. The bare ASGI and WSGI starters have no integration that can register a checker, so they keep the "links not checked" note; their READMEs say it's expected and that the check still passes. Clean-copy qualification now fails a FastAPI, Django or Flask project whose check prints that note.

Django: start Django before importing the app

With --app config.urls:citry_app, citry check failed with AppRegistryNotReady as soon as urls.py imported a model. The editor's app worker failed the same way. The old target failed the same way once a component imported a model.

  • When DJANGO_SETTINGS_MODULE is set, the CLI and the app worker now call django.setup() before importing the --app module, as manage.py does.
  • The link checker from feat(check): typed slot data and prop expressions in the editor; check links against the app (#207) #233 shares the same step, so Django starts once.
  • If Django isn't installed, the variable is ignored, so a leftover value from another shell doesn't break a non-Django project.
  • If Django is installed and its settings fail to start, the check reports Django's own error, with a hint to unset the variable.

Evidence

  • Each changed starter, in a scratch copy: the new target runs with no note and no false findings, and a deliberately broken link is reported.
  • Django: a fresh-process test project whose urls.py imports a model through views.py passes in both the CLI and the app worker, and starts Django exactly once. Without the fix it fails with AppRegistryNotReady.
  • Checks: the examples tests, the starters' own tests and scripts/validate.py pass. ruff is clean, and mypy is clean, including with --platform linux.
  • Reviews: an independent technical review and separate prose passes.

Known limit

The starters' lockfiles pin Citry 0.6.0, which has no link check. Until those locks are refreshed at the next release, a copied starter shows neither link findings nor the note.

🤖 Generated with Claude Code

@JuroOravec
JuroOravec added this pull request to stack #237 October 21, 2026 16:05
@JuroOravec
JuroOravec removed this pull request from stack #237 October 21, 2026 16:06
@JuroOravec
JuroOravec added this pull request to stack #219 October 21, 2026 16:07
Base automatically changed from fix/static-checks-207-vue-compile to main October 21, 2026 16:36
JuroOravec and others added 3 commits October 21, 2026 18:36
…itry

`citry check` checks template links only when a framework integration
told Citry which paths the app serves while the app loaded. The FastAPI,
Django, and Flask starters and the project board demo pointed `--app` at
the module that only creates the Citry instance, so their checks printed
a "links not checked" note.

- FastAPI starter and both FastAPI demos: `app.main:citry_app`. The htmx
  demo has no literal links in its templates today, so it printed no
  note, but it follows the same rule.
- Django starter: `config.urls:citry_app`.
- Flask starter: new `app/wsgi.py` builds the app with `create_app()`;
  the check uses `app.wsgi:citry_app`.
- Bare ASGI and WSGI starters keep `app.citry_app:citry_app`: they route
  requests in their own code, and no public API lets them tell Citry
  their paths. Their READMEs say the note is expected.

The catalog, READMEs, AGENTS.md files, project workflows, and VS Code
settings are updated to match. Clean-copy qualification now fails a
FastAPI, Django, or Flask project whose check prints either note that
says links were skipped. The template-linting page links to the
starters, the IDE pages point to it, and the example-projects design doc
records the rule.

The starters' lockfiles still pin Citry 0.6.0, which has no link check,
so a copied starter prints neither the findings nor the note until the
locks are refreshed at the next release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dule

`citry --app config.urls:citry_app check` failed with
AppRegistryNotReady as soon as the URL configuration imported a model,
usually through its views: the CLI and the editor's app worker imported
the module before Django had loaded its apps.

When DJANGO_SETTINGS_MODULE is set, `load_app()` (every `citry --app`
command) and the citry-lsp app worker now call django.setup() first, as
manage.py does. The new `citry._django_startup` module holds that step.
The Django link checker calls the module's `start_django()`, which returns at once
when the apps are loaded or loading, so Django starts once per process.
The app worker carries a small copy of the step for an app that runs on
an older Citry without the new module.

If the variable is set but Django is not installed, the message names
the variable and says how to fix it. If the settings module fails to
import, raises, or exits, the message carries Django's own error and
suggests unsetting the variable for a project that does not use Django.

Fresh-process tests cover the CLI and the app worker with a project
whose urls.py imports a model through views.py. The CLI, VS Code,
PyCharm, and template-linting docs, the url-checker-missing fix text,
the extension-commands design note, and both changelogs describe it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A variable left over from another shell made every `citry --app` command
fail in a project that does not use Django. Without Django installed the
project cannot be a Django one, so the CLI step and the app worker's copy
of it now skip starting Django. An installed Django that fails to start
still reports Django's own error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec force-pushed the fix/starters-mount-check branch from 94a2a86 to 74ccf4c Compare October 21, 2026 16:36
@JuroOravec
JuroOravec merged commit aa6f313 into main Oct 21, 2026
26 checks passed
@JuroOravec
JuroOravec deleted the fix/starters-mount-check branch October 21, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant