Skip to content

Linter: shutdown_template_status() for programmatic template checks - #56

Merged
mmmarinho merged 1 commit into
mainfrom
linter-shutdown-status-api
Oct 26, 2026
Merged

mmmarinho merged 1 commit into
mainfrom
linter-shutdown-status-api

Conversation

@mmmarinho

@mmmarinho mmmarinho commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Purely additive public API: shutdown_template_status(source, path) returns one dict per spin call site — guarded, keyboard/shutdown caught (explicit/broad/None=escapes), has_broad_handler (non-reraising except Exception/bare in the enclosing tries), handlers_pass, callback_form, plus parsed/reason — so scripts can check the shutdown template of a source programmatically instead of reading the findings as text.

Conformant is exactly the two styles the tutorial teaches:

  • except (KeyboardInterrupt, ExternalShutdownException): pass + except Exception;
  • old style except KeyboardInterrupt: pass + except Exception (ESE caught by the broad handler).

Also reworded the lint_package docstring while here. No behaviour change to lint_source/lint_package. 11 new status test cases (template, old style, bare except, no-broad, unguarded, callback form, syntax error, logging handlers with/without broad); all cases pass, workspace 0/0.

@mmmarinho mmmarinho changed the title Linter: shutdown_template_status() so marking programs can grade the shutdown template from source Linter: shutdown_template_status() for programmatic template checks Oct 26, 2026
@mmmarinho
mmmarinho force-pushed the linter-shutdown-status-api branch from df45e4d to 302200a Compare October 26, 2026 19:36
lint_source's messages say what is wrong but not what the template
consists of. shutdown_template_status(source, path) returns, per spin
call site, whether it is guarded, whether KeyboardInterrupt and
ExternalShutdownException are caught explicitly or by a broad handler,
whether a non-reraising except Exception/bare handler exists in the
enclosing tries, and whether the operative handlers are just pass.

Conformant is exactly the two styles the tutorial teaches:
except (KeyboardInterrupt, ExternalShutdownException) + except Exception,
or the old except KeyboardInterrupt + except Exception (ESE swallowed by
the broad handler); no_broad (explicit handlers only) and unguarded or
escaping sites are not. 11 status cases added.
@mmmarinho
mmmarinho force-pushed the linter-shutdown-status-api branch from 302200a to dedbeab Compare October 26, 2026 19:37
@mmmarinho
mmmarinho merged commit 04931d1 into main Oct 26, 2026
4 checks passed
@mmmarinho
mmmarinho deleted the linter-shutdown-status-api branch October 26, 2026 19:40
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