fix(smpy): unblock the scaffolded-app quickstart + harden the file-size lint gate - #207
Merged
Conversation
git ls-files lists only tracked paths, so a new oversized file passed make lint while untracked and failed only after being committed. Switch the default scan to 'git ls-files --cached --others --exclude-standard' so the working tree (minus gitignored paths) is checked, catching violations before commit. Fixes#204
Four interlocking quickstart bugs in `smpy new` / `create-*` scaffolds, all touching the same shared templates, so they ship together. #194 main.py chdir broke `from routes import`: the generated host/main.py chdir'd to the repo root before importing the sibling `routes` module, but uvicorn launches `main:app` with sys.path[0] == '' (the cwd, resolved lazily) — after the chdir that points at the wrong dir and the import fails (and the --reload subprocess re-imports the same way). Pin the host dir on sys.path as an absolute path *before* the chdir. #195 create-module pins were unsatisfiable: the module template ships `simple_module_*>=1.0,<2.0` (the framework's future API line) but the published dists are 0.0.x, so `uv add ./modules/<name>` couldn't resolve. Add scaffolding.pin_framework_deps() + a framework_version arg on create_module(); the `smpy create-module` command now pins to the installed framework version. Dedupes app_project's sample-module pinning. #201 scaffold couldn't run its own quality gates: generated Makefiles had no test/lint/doctor targets and `migrate` used `alembic upgrade head` (singular — errors once a second module adds a branch label). Add test/test-py/test-js/lint/doctor targets and the backing dev tooling (ruff, ty, pytest-asyncio, pytest-playwright) + pytest/ruff/ty config to the workspace root (and flat host), switch migrate to `upgrade heads`, and make the generated code lint-clean (noqa: E402 on the deliberate post-chdir imports, drop a RET504 in migrations/env.py). A new test runs the scaffold's own ruff gate end to end so template edits can't regress it. #202 module edits didn't hot-reload: dev-api only watched the launch cwd (host/). Add `--reload-dir . --reload-dir ../modules` so edits to in-repo module packages reload too. Fixes#194Fixes#195Fixes#201Fixes#202
Deploying simple-module-python with |
| Latest commit: | c421ced |
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f4e576aa.simple-module-python.pages.dev |
| Branch Preview URL: | https://fix-smpy-scaffold-quickstart.simple-module-python.pages.dev |
Adding the #201/#202 regression tests pushed test_cli_new.py from 300 to 374 lines, tripping the 300-line file-size CI gate. Split the workspace/flat layout and quality-gate tests into test_cli_new_scaffold_layout.py (by responsibility, not by squeezing). Both files now well under the cap; all 22 tests still pass.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the scaffold/CLI quickstart papercuts that block a freshly-generated app, plus a CI gap in the file-size check. Pure backend/CLI/CI — no docs (the doc issues #196/#197/#198 were handled separately by #205; only the #196 residual ships as its own small PR).
Issues closed
make devfailed on a fresh app withModuleNotFoundError: No module named 'routes'. The generatedhost/main.pychdir'd to the repo root before importing the siblingroutesmodule, invalidating the cwd-relative entry uvicorn put onsys.path. Now the host dir is pinned onsys.pathas an absolute path before the chdir (the three post-chdir framework imports carry# noqa: E402, mirroring the framework's own lintedhost/main.py).smpy create-modulegenerated a module pinningsimple_module_* >=1.0,<2.0, unsatisfiable on PyPI (framework is at0.0.x), souv add ./modules/<name>failed. A sharedresolve_framework_version()/pin_framework_deps()now pins the generated module to the installed framework version; wired into bothcreate-moduleand thenewsample-module path.migrateusesalembic upgrade head(singular) #201 — the generated Makefile gained thetest/test-py/test-js/lint/doctortargets the docs reference, plus backing[tool.pytest.ini_options]/[tool.ruff]/[tool.ty.rules]config in the scaffold pyproject;migratenow usesalembic upgrade heads(plural, multi-branch-safe).cd host && uvicorn main:app --reloadonly watches host/, so edits to modules/ don't hot-reload #202 — the dev-api target now passes--reload-dir . --reload-dir ../modules, so edits undermodules/hot-reload.make lintuntil it's committed #204 —scripts/check_file_size.pyscanned only git-tracked files, so an oversized untracked-not-ignored file passedmake lintuntil committed. It now scansgit ls-files --cached --others --exclude-standard(tracked + untracked, gitignore-respecting), keeping the--no-gitfilesystem fallback.Tests
New regression coverage in
framework/cli/tests/andscripts/tests/:host/main.pypins the host dir onsys.pathbefore chdir;create-modulepins (and, without a version, keeps ranges); dev-api watchesmodules/; the Makefile has the quality-gate targets andupgrade heads; the root pyproject ships the dev tooling/config.test_sm_new_generated_app_passes_its_own_ruff) scaffolds a real app and runs its ownruffgate end-to-end.check_file_sizecatches an untracked-not-ignored oversized file and passes when the only violation is gitignored.Out of scope
smpy create-hostpath still ships unpinned>=1.0,<2.0host deps — tracked separately in [smpy][create-host] standalone create-host pins simple_module_* at >=1.0,<2.0 — unsatisfiable on PyPI (same class as #126), so 'uv sync' fails #206 (the same defect class as sm new sample module pins simple_module_core/db/hosting>=1.0,<2.0 — uv sync fails because framework is at 0.0.x #126, in a code path that earlier fix never covered).