60 lines
3.5 KiB
Markdown
60 lines
3.5 KiB
Markdown
# Quality Criteria: Python Source Code
|
|
|
|
## Metadata
|
|
| Key | Value |
|
|
| --- | --- |
|
|
| ID | QC-PY-001 |
|
|
| CrossReference | [QC-DCD-001], [QC-ADR-001] |
|
|
| DomainLanguages | IT Professional English |
|
|
|
|
## Version History
|
|
| Date | Status | Author | Reviewer | Change | Commit |
|
|
| --- | --- | --- | --- | --- | --- |
|
|
| 2026-10-01 | Accepted | Jens Tirsvad Nielsen | S07 | First public release (1.0.0) | — |
|
|
|
|
---
|
|
|
|
## Purpose
|
|
|
|
Python source code is the implementation of the design. This checklist confirms that code follows the Python coding conventions (PEP 8 naming and layout, type hints, error handling), so that it is readable, maintainable and consistent with the design it implements.
|
|
|
|
## Quality Criteria Checklist
|
|
|
|
Level: **Mandatory** criteria are the baseline every instance must meet; **Optional** criteria are advanced and may be deferred.
|
|
|
|
| # | Criterion | Level | ISO/IEC 25010 Characteristic(s) | Notes |
|
|
| --- | --- | --- | --- | --- |
|
|
| 1 | Packages, modules, functions, variables, classes and constants follow PEP 8 casing (`snake_case`, `PascalCase`, `UPPER_SNAKE`) | Mandatory | Maintainability, Usability | |
|
|
| 2 | Names state purpose in the domain's language; no unexplained abbreviations, no single-letter names outside tiny scopes | Mandatory | Maintainability, Usability | |
|
|
| 3 | Code is produced by the project's formatter and passes its linter with no unexplained suppressions | Mandatory | Maintainability | |
|
|
| 4 | Every function and method signature is type-annotated, including `-> None` | Mandatory | Maintainability, Reliability | |
|
|
| 5 | No bare `except:`, no swallowed exceptions; specific exceptions are raised and the cause is kept (`raise ... from`) | Mandatory | Reliability | |
|
|
| 6 | No mutable default arguments and no shadowed builtins | Mandatory | Reliability, Maintainability | |
|
|
| 7 | Files, locks and connections are managed with context managers | Mandatory | Reliability, Performance Efficiency | |
|
|
| 8 | Public modules, classes and functions have docstrings that say what, not how | Optional | Usability, Maintainability | |
|
|
| 9 | Logging uses `logging`, not `print`; no secrets or personal data in log output | Mandatory | Security, Maintainability | |
|
|
| 10 | Classes and operations trace to the Design Class Diagram they implement; deviations are recorded | Mandatory | Functional Suitability, Maintainability | |
|
|
| 11 | Tests exist for new behaviour, are named for the behaviour, and do not depend on order or the network | Mandatory | Reliability, Maintainability | |
|
|
| 12 | Type checker runs in strict mode without errors; `Any` is justified in a comment | Optional | Reliability, Maintainability | |
|
|
| 13 | Dependencies are declared and pinned in the project's dependency file, none unused | Optional | Portability, Security | |
|
|
|
|
## Common Defects
|
|
|
|
- Java- or C#-style casing (`getTotal`, `customerList` for functions and variables)
|
|
- Missing or partial type annotations
|
|
- Bare `except:` or `except Exception: pass`
|
|
- Mutable default arguments (`def f(x=[])`)
|
|
- `print` used for diagnostics; wildcard imports
|
|
- Code reformatted by hand, or an unrelated reformat mixed into a functional change
|
|
- Classes or methods that appear in no design artifact and have no stated reason
|
|
|
|
## Traceability Rule
|
|
|
|
- Backward: Design Class Diagram checklist ([QC-DCD-001]) for the classes and operations being implemented; Architecture Decision Record checklist ([QC-ADR-001]) for the decisions that constrain the implementation
|
|
- Forward: none — source code is the end of the QC checklist chain
|
|
|
|
---
|
|
|
|
[QC-DCD-001]: ./qc-dcd.md
|
|
[QC-ADR-001]: ./qc-adr.md
|