Repository navigation
Linter: shutdown_template_status() for programmatic template checks - #56
Merged
Merged
Conversation
mmmarinho
force-pushed
the
linter-shutdown-status-api
branch
from
October 26, 2026 19:36
df45e4d to
302200a
Compare
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
force-pushed
the
linter-shutdown-status-api
branch
from
October 26, 2026 19:37
302200a to
dedbeab
Compare
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 free
to 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.
Purely additive public API:
shutdown_template_status(source, path)returns one dict per spin call site —guarded,keyboard/shutdowncaught (explicit/broad/None=escapes),has_broad_handler(non-reraisingexcept Exception/bare in the enclosing tries),handlers_pass,callback_form, plusparsed/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;except KeyboardInterrupt: pass+except Exception(ESE caught by the broad handler).Also reworded the
lint_packagedocstring while here. No behaviour change tolint_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.