Stage 11 · L47
Separate formatting, lint, hooks, CI and merge requirements
Optional supplement · original Session 10
Source examples are supplied. Black/Pylint/pre-commit and hosted CI have not been run.
Download starter · Download solution
Use the starter for this stage's focused examples. The cumulative transfer and solution belong at the stage-end capstone. Baseline checks pass; transfer checks initially fail. Downloads contain the matching native starter and solution for this stage.
Formatting, static analysis, tests, local hooks and CI answer different questions. Black makes layout consistent. Pylint's error/fatal pass detects some static defects and has inference limits around dynamic ORM/Pydantic behavior. HTTP/PostgreSQL tests exercise selected runtime contracts. None alone establishes correctness or security.
The supplementary source fixes Black25.1.0, Pylint3.3.8 and pre-commit4.3.0 for its classroom examples. The snapshot preserves those explicit examples and sets the formatter target to this course's Python3.13. They are not claims of newest versions or a full transitive quality lock. Install only in your learner environment; do not modify the website environment.
The local system hooks check rather than silently rewriting source. If Black fails, run the formatter, inspect the diff and stage the intended result. If Pylint reports an inference issue, investigate the code and use the narrowest justified treatment; a blanket suppression can hide a real defect. These tools are absent from the cached runtime and have not been executed here.
The sample workflow defines checkout/interpreter, tool checks, a local teaching image and actual isolated PostgreSQL tests. Its YAML/TOML/source structure is reviewed, but no hosted job has run. A job name called checks does not prove its steps cover the intended behavior. The existing source's fast-CI example starts no database/provider; this sample explicitly includes the native fixture instead.
Local hooks can be bypassed; CI runs only its configured steps; merge protection requires separate repository settings. No hosted credentials, required-check settings or merge controls were configured. Coverage80% is a source example, not a measured passing claim or universal threshold. Reproducible dependencies, meaningful assertions and revision-specific evidence matter more than a green badge alone.
Inspect the sample configuration
Focused lesson example; see the end-of-stage capstone for the cumulative app · stage 09
python -m black --check equipment tests
python -m pylint --errors-only equipment
python -m pre_commit run --all-files
# Exact source tool pins must be installed in the learner environment first.Predict and observe this focused example using the concepts explained above. Its boundary is stated in the focused answer.
Guided lab
- Read the explanation and predict the focused example’s outcome.
- Introduce a formatting defect and an undefined name separately. Explain which local/hosted gate would detect each and what was actually run.
- Compare the observed outcome with the focused answer and state its boundary.
Expected: Black detects layout differences; Pylint can detect the undefined name within its inference limits; runtime tests check selected contracts. Repair narrowly and inspect the diff. Local hooks do not enforce a hosted merge. The source's fixed tool examples/configs are supplied; exact tool/coverage/hosted-CI/merge-setting execution remains unverified.
- A hook is not a hosted required check; fixed top-level versions do not lock every transitive dependency; coverage is not correctness.
Focused exercise and answer
Complete the manual exercise in your learner repository and record which checks actually ran.
Your transfer task: Introduce a formatting defect and an undefined name separately. Explain which local/hosted gate would detect each and what was actually run.
- Introduce a formatting defect and an undefined name separately. Explain which local/hosted gate would detect each and what was actually run.
Inspect the matching answer
This answer addresses the focused exercise above; the cumulative implementation is shown only after the stage prerequisites.
Black detects layout differences; Pylint can detect the undefined name within its inference limits; runtime tests check selected contracts. Repair narrowly and inspect the diff. Local hooks do not enforce a hosted merge. The source's fixed tool examples/configs are supplied; exact tool/coverage/hosted-CI/merge-setting execution remains unverified.Check your reasoning
Does adding checks.yml enforce a reviewed merge?
Show the explanation
No. The workflow must run and repository merge rules must be configured separately; neither action happened here.
Reading progress
54 lessons remain open to guests. Marking a lesson read records reading only; it does not award assessment credit or a certificate.
Device reading marks require browser storage. Reading is always available.
Sign in or create an account to save separate account progress. Your current page is kept.
Your earlier place on this device suggests these lessons. No new lesson is marked read.