Skip to content

v0.3.0 - Quality & Formats Release

Choose a tag to compare

@tawounfouet tawounfouet released this 04 Sep 07:46
· 212 commits to main since this release

Technical Review — PyIngestKit V0.3.0 Quality Gate & Documentation Stabilization

Overview

This technical review documents the corrections made to PyIngestKit V0.3.0 to restore 100% functionality across all quality gates (make quality, make security, make test, make build, make verify, make release-check) and CLI documentation.


Identified Issues & Resolutions

1. Security Gate Fix — Elimination of assert in Production Code (Bandit B101)

  • Root Cause: bandit -q -r src/pyingestkit examples/plugin_package/src reported two low-severity/high-confidence security issues (B101:assert_used) in src/pyingestkit/contracts/dataset.py at lines 457 and 493:
    minimum = contract.min_length
    assert minimum is not None
    In Python, assert statements can be omitted at bytecode compilation when optimized (python -O), causing critical runtime contract validations to be silently bypassed.
  • Fix Applied: Replaced assertions with explicit None checks:
    minimum = contract.min_length
    if minimum is None:
        return True
    maximum = contract.max_length
    if maximum is None:
        return True
  • Outcome: bandit scan now reports 0 issues across 5,705 lines of scanned code.

2. Quality Gate Fix — Code Formatting & Mypy Type Narrowing

A. Code Formatting (ruff format)

  • Root Cause: ruff format --check reported 5 unformatted files across the repository:
    • examples/plugin_package/tests/test_quality_format_jobs.py
    • src/pyingestkit/contracts/dataset.py
    • src/pyingestkit/runtime/runner.py
    • tests/integration/test_quality_reports_runtime.py
    • tests/unit/contracts/test_dataset_contract_v2.py
  • Fix Applied: Executed ruff format across src, tests, and examples/plugin_package. All 168 source files are now compliant.

B. Mypy Strict Type Checking (mypy src/pyingestkit)

  • Root Cause: Mypy reported an argument type error in src/pyingestkit/contracts/dataset.py:305:
    src/pyingestkit/contracts/dataset.py:305: error: Argument 1 to "_type_label" of "DatasetContract" has incompatible type "type[Any] | tuple[type[Any], ...] | None"; expected "type[Any] | tuple[type[Any], ...]"
    
    Mypy could not narrow the type of the attribute contract.expected_type when evaluated inside the if not type_matches: condition.
  • Fix Applied: Bound contract.expected_type to a local variable expected and performed an explicit if expected is not None: guard before calling _type_label(expected):
    type_matches = True
    expected = contract.expected_type
    if expected is not None:
        type_matches = isinstance(value, expected)
        if not type_matches:
            if not collector.add(
                ValidationIssue(
                    "field.type",
                    (
                        f"Field {contract.name!r} has type {type(value).__name__}; "
                        f"expected {self._type_label(expected)}"
                    ),
                    ValidationSeverity.ERROR,
                    field=contract.name,
                    row_index=row_index,
                    value_preview=_safe_preview(contract.name, value),
                    constraint="expected_type",
                )
            ):
                return
  • Outcome: mypy src/pyingestkit passes with 0 errors across 91 source files.

3. Documentation & CLI Configuration Fix — README.md

  • Root Cause: Running the CLI quality demo jobs as documented in README.md failed with:
    Error: Invalid value for '--config' / '-c': File 'examples/plugin_package/demo-excel.yml' does not exist.
    
    The documentation in lines 132–134 erroneously specified demo-excel.yml, demo-ndjson.yml, and demo-parquet.yml instead of the actual config file demo-quality.yml.
  • Fix Applied: Corrected README.md lines 132–134:
    pyingest run demo.excel_quality --config examples/plugin_package/demo-quality.yml
    pyingest run demo.ndjson_quality --config examples/plugin_package/demo-quality.yml
    pyingest run demo.parquet_quality --config examples/plugin_package/demo-quality.yml
  • Outcome: All CLI commands in README.md execute successfully out-of-the-box.

Verification Matrix

Target Gate Tool / Command Status Details
Functional Unit & Integration Tests make test PASS 152 passed in 1.70s
Lint & Formatting Check ruff check && ruff format --check PASS 168 files compliant
Static Type Analysis mypy src/pyingestkit PASS 91 files checked, 0 errors
Security Static Analysis bandit -q -r src ... PASS 0 issues detected
Vulnerability Audit pip-audit PASS 0 vulnerabilities found
Package Build make build PASS SDist & Wheel generated
Full Source Gate make verify PASS End-to-end clean run
Release Wheel Smoke Test make release-check PASS Fresh virtualenv run over all 6 reference jobs

Summary of Reference Jobs Status

All six reference slices are 100% operational:

  1. demo.local_file: Ingests local files into immutable RAW storage.
  2. demo.http_csv: HTTP source -> Retry policy -> RAW provenance -> CSV parser -> Dataset validation.
  3. demo.http_json: HTTP source -> Retry policy -> RAW provenance -> JSON parser -> Dataset validation.
  4. demo.ndjson_quality: NDJSON parser -> Dataset -> Contract V2 -> Profile -> Quality reports.
  5. demo.excel_quality: OpenPyXL parser -> Dataset -> Contract V2 -> Profile -> Quality reports.
  6. demo.parquet_quality: PyArrow parser -> Dataset -> Contract V2 -> Profile -> Quality reports.