caspian-utils 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,7 +95,7 @@ The packaged Caspian docs referenced by this index live here:
95
95
  - `metadata.md` - Static and dynamic metadata, SEO inheritance, and Open Graph or Twitter card tags
96
96
  - `routing.md` - Next.js App Router-style file-based routing with `src/app`, dynamic segments, dashboard and section layouts, route groups, nested layouts, shared-shell scroll-reset ownership, single-parent authored templates, and backend Python companions that do not own visible markup
97
97
  - `project-structure.md` - Default Caspian layout and where route files, reusable UI in `src/components/`, reusable non-UI code in `src/lib/`, and database files belong
98
- - `testing.md` - Recommended app-owned testing, type-checking, and linting gate over `main.py` and `src/**` (pyrefly + ruff + pytest behind one command), plus the auto-fix command and why ruff must not auto-delete component imports used as `<x-*>` tags (F401 unfixable); not a shipped feature and not gated by a `caspian.config.json` flag, so verify the actual command, tools, and config in the project
98
+ - `testing.md` - Recommended app-owned testing, type-checking, and linting gate over `main.py` and `src/**` (pyright + ruff + pytest behind one command, so the gate and Pylance in the editor report the same thing), plus the auto-fix command and why ruff must not auto-delete component imports used as `<x-*>` tags (F401 unfixable); not a shipped feature and not gated by a `caspian.config.json` flag, so verify the actual command, tools, and config in the project
99
99
 
100
100
  ## AI Retrieval Notes
101
101
 
@@ -68,9 +68,8 @@ If the project enables MCP, use `mcp.md` after scaffold to place the app-owned F
68
68
  For the best development experience, use these VS Code extensions:
69
69
 
70
70
  - [Caspian Official Framework Support](https://marketplace.visualstudio.com/items?itemName=JeffersonAbrahamOmier.caspian)
71
- - [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
72
- - [Pyright](https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright)
73
- - [Pyrefly](https://marketplace.visualstudio.com/items?itemName=tamasfe.pyrefly)
71
+ - [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) — ships [Pylance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) as the default language server, which is Pyright under the hood and therefore agrees with the `npm run check` gate (recommended).
72
+ - [Pyright](https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright) — optional if you want the standalone Pyright server and CLI on top of Pylance; otherwise Pylance already covers editor parity.
74
73
  - [Prisma](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma)
75
74
  - [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)
76
75
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Testing And Quality Gate
3
- description: Use this page when the task mentions tests, pytest, type checking, pyrefly, linting, ruff, auto-fixing lint (ruff --fix / check:fix), unused-import (F401) removal, a quality gate, CI checks, or "make the code production-ready" for a Caspian app's own Python. Explains the recommended one-command gate over `main.py` and `src/**`, and why ruff must not auto-delete component imports used as `<x-*>` tags.
3
+ description: Use this page when the task mentions tests, pytest, type checking, pyright, linting, ruff, auto-fixing lint (ruff --fix / check:fix), unused-import (F401) removal, a quality gate, CI checks, or "make the code production-ready" for a Caspian app's own Python. Explains the recommended one-command gate over `main.py` and `src/**`, and why ruff must not auto-delete component imports used as `<x-*>` tags.
4
4
  related:
5
5
  title: Related docs
6
6
  description: Pair the quality gate with the runtime map when a failing check points into core files, and with the structure and command docs when deciding where tests and tooling belong.
@@ -26,11 +26,11 @@ Caspian does not ship a test runner, type checker, or linter. Quality tooling is
26
26
 
27
27
  Expose a single gate command so an agent or CI has exactly one thing to run. The recommended command runs three tools in one pass and reports every problem with its exact location:
28
28
 
29
- - **type check** — [pyrefly](https://pyrefly.org) over `main.py` and `src/**`
29
+ - **type check** — [pyright](https://github.com/microsoft/pyright) over `main.py` and `src/**` (Pylance, the default VS Code Python language server, is Pyright under the hood and reads the same `[tool.pyright]` config, so the editor and `npm run check` report the same thing)
30
30
  - **lint** — [ruff](https://docs.astral.sh/ruff/)
31
31
  - **tests** — [pytest](https://docs.pytest.org)
32
32
 
33
- The command should print each problem as `path:line:col [tool:code] message` and exit non-zero when any check fails, so the file and line to fix are always explicit. Prefer a single `npm run check` script (backed by an app-owned orchestrator such as `settings/check.py`) over separate `test` / `lint` / `typecheck` scripts, so the surface stays minimal. Keep a per-tool escape hatch (for example `--only pyrefly`) for debugging rather than as additional npm scripts.
33
+ The command should print each problem as `path:line:col [tool:code] message` and exit non-zero when any check fails, so the file and line to fix are always explicit. Prefer a single `npm run check` script (backed by an app-owned orchestrator such as `settings/check.py`) over separate `test` / `lint` / `typecheck` scripts, so the surface stays minimal. Keep a per-tool escape hatch (for example `--only pyright`) for debugging rather than as additional npm scripts.
34
34
 
35
35
  ## Source Of Truth
36
36
 
@@ -57,7 +57,7 @@ Keep the dev tooling in a dependency group and install it with `uv sync --group
57
57
  ```toml
58
58
  [dependency-groups]
59
59
  dev = [
60
- "pyrefly>=0.16",
60
+ "pyright>=1.1",
61
61
  "ruff>=0.6",
62
62
  "pytest>=8.0",
63
63
  ]
@@ -75,14 +75,27 @@ extend-exclude = [".venv", "node_modules"]
75
75
  select = ["E", "F", "W"]
76
76
  ignore = ["E501"]
77
77
 
78
- [tool.pyrefly]
79
- project-includes = ["main.py", "src/**"]
80
- search-path = [".", "src"]
78
+ [tool.pyright]
79
+ # Pylance (the VS Code Python extension) reads this same config, so the editor
80
+ # and `npm run check` report the same thing instead of disagreeing.
81
+ include = ["main.py", "src"]
82
+ exclude = [".venv", "node_modules", "**/__pycache__"]
83
+ # `basic` is Pylance's default mode. It catches reportArgumentType-style bugs
84
+ # (e.g. passing a dict[str, str | None] to a TypedDict whose field is `str`)
85
+ # without flooding the gate with strict-mode noise. Subject the generated Prisma
86
+ # Python ORM under `src/lib/prisma/**` to its own exclusion so its
87
+ # Optional-everywhere models do not dominate the gate.
88
+ pythonPlatform = "Windows" # or Linux/Darwin to match the deploy target
89
+ typeCheckingMode = "basic"
90
+ # Mirror suppressions from older pyrefly-based setups if you migrated; otherwise
91
+ # leave these out. Re-enable per-rule when tightening.
92
+ # reportReturnType = "none"
93
+ # reportAssignmentType = "none"
81
94
  ```
82
95
 
83
96
  ## Auto-Fixing, And Why Ruff Must Not Delete Component Imports
84
97
 
85
- The gate only **reports**. Ruff can also **fix** many lint findings in place, so a second command is worth exposing alongside the gate — recommended `npm run check:fix`, backed by a small orchestrator (for example `settings/fix.py`) that applies safe fixes and then re-runs the gate to print the authoritative report of what is left. Type errors (pyrefly) and failing tests (pytest) are never auto-fixed.
98
+ The gate only **reports**. Ruff can also **fix** many lint findings in place, so a second command is worth exposing alongside the gate — recommended `npm run check:fix`, backed by a small orchestrator (for example `settings/fix.py`) that applies safe fixes and then re-runs the gate to print the authoritative report of what is left. Type errors (pyright) and failing tests (pytest) are never auto-fixed.
86
99
 
87
100
  **Hazard — unused-import autofix (`F401`) breaks single-file components.** A single-file component imports its children and then uses them **only** as `<x-*>` tags inside an `html(...)` / `render_html(...)` template string, for example `from .Dialog import DialogContent` used as `<x-dialog-content>`. Ruff parses Python, not the template string, so it reports the import as unused (`F401`) and `--fix` would delete it. That import is load-bearing: Caspian resolves the tag from the **module's globals at render time** (see `component_decorator._attach_caller_scope`, which scans the caller module for `Component` instances). Deleting it breaks rendering at runtime, silently. This affects any component file, so it cannot be scoped by path — but it also must not disable dead-import cleanup for ordinary Python.
88
101
 
@@ -107,7 +120,7 @@ Handle it in three layers, all generic:
107
120
 
108
121
  - Confirm the gate command name and orchestrator path in `package.json` and `settings/`, since they are app-owned and may differ per project.
109
122
  - Confirm the dev tools are actually installed (`[dependency-groups]` in `pyproject.toml`, resolved in `uv.lock`) before telling a user to run the gate.
110
- - Check `[tool.pyrefly.errors]` in `pyproject.toml`. A project may suppress specific error kinds (commonly `bad-return` and `bad-assignment`); those are then not reported by the gate, so do not assume every annotation mismatch is caught.
123
+ - Check `[tool.pyright]` in `pyproject.toml`. A project may set `typeCheckingMode = "basic"` (Pylance's default, recommended) and individually silence rules with `reportReturnType = "none"` / `reportAssignmentType = "none"` (commonly done to mirror older pyrefly-based setups). Any rule silenced there is then not reported by the gate, so do not assume every annotation mismatch is caught. Pylance in the editor reads this same config, so the IDE and `npm run check` agree.
111
124
  - Keep the scope on app code. If a check points into `.venv/Lib/site-packages/casp/**`, use [core-runtime-map.md](./core-runtime-map.md) to understand the runtime, but do not add framework files to the app's test, lint, or type-check scope.
112
125
 
113
126
  ## Working Rule For Agents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caspian-utils",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Caspian tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {