pysxLearn by building

Build and operate · Lesson 25 of 28

Development workflow and editor tools

Practice editor diagnostics, live bindings and compatible hot reload in your own project.

Fast feedback helps you reason about live templates before opening a browser. The checker and editor understand markup alongside Python, but template diagnostics remain advisory. A successful editor check is not a runtime proof.

Static analysis reads source without running it. For example, replacing an eager count() hole with a live count reference fixes a frozen display. Watch mode then lets you observe compatible edits in your own running application.

Understand the moving parts

Watching requires a server you control, so this lesson's exercise uses a development playground rather than the course you are reading. Run it with pysx --app playgrounds.development --watch and edit playgrounds/development.py while it serves. Compatible saved edits preserve supported UI state while a broken candidate leaves the previous worker available. The documented CLI uses the same application entry as ordinary serving.

Install the language-server extra and select that environment in the editor. Keep Python/Pylance ownership of Python expressions and use the framework's template-aware tooling for markup. The final installed qualification uses the real editor host, not a mock completion provider.

Walk through the code

from pysx import Fragment, derived, pysx, signal


def app() -> Fragment:
    count = signal(0)
    draft = signal("")
    doubled = derived(lambda: count() * 2)

    def increment(_event: object) -> None:
        count.set(count() + 1)

    return pysx(t"""
        main:
            h1: "Development playground"
            p: "Edit playgrounds/development.py while serving with --watch."
            label(htmlFor="draft"): "Draft to retain across compatible edits"
            input(id="draft" bindValue={draft} maxlength="200")
            p(id="draft-echo"): {draft}
            p:
                "Count: "
                span(id="count"): {count}
            p:
                "Doubled: "
                span(id="doubled" title="A derived value"): {doubled}
            button(id="increment" type="button" onClick={increment}): "Increment"
            h2: "Try it"
            ol:
                li: "Increment the count and enter a draft."
                li: "Change the h1 text in your editor and save. The state stays in this tab."
                li: "Change the count span's live hole from count to count(). Inspect the warning."
                li: "Increment again to see the frozen count, then restore the live count hole."
                li:
                    "Misspell title as tittle on the doubled span, "
                    "inspect the warning, then fix it."
                li: "Save a Python syntax error. The working page remains until you fix the file."
            p: "Use the pysx editor extension with the environment containing pysx-framework[lsp]."
    """)

count and draft retain delivered edits during compatible reloads. doubled derives twice the count. Both number displays use live holes. Changing the count span to count() freezes that display and produces an advisory warning; the derived display remains live. The doubled span's title attribute gives you a concrete markup diagnostic to try. All edits happen in the file you actually run.

Try it locally

Use Python 3.14 or newer. In your project's activated virtual environment, run:

pip install 'pysx-framework[lsp]'
pysx-playground development
pysx --app playgrounds.development --watch

Open the local URL printed in the terminal. Keep that terminal open while you try the playground.

Scaffold once. To restart, repeat only the pysx --app command; scaffolding again resets the playground's saved state.

What you'll do

  1. Increment the count and enter a draft. Change the heading in playgrounds/development.py and save while keeping the tab open.
  2. Change the count span's hole from count to count(). Inspect the editor warning, increment again, then restore count.
  3. Misspell title as tittle on the doubled span, inspect the attribute warning, then correct it.
  4. Introduce a Python syntax error and save, then correct it and save again.

What you'll see

A compatible heading edit preserves the count and draft. An eager hole freezes one display while the derived value still updates. The editor flags the eager hole and misspelled attribute; correcting them clears those findings. A syntax error is reported in the terminal; the previous working page remains available until you save a valid correction.

Take this with you

Combine static feedback, a real watch journey and runtime verification.