Plesty Documentation

Fixing Failures

How to read gate failure output, fix the most common issues, and re-run the check.

Reading failure output

When a gate fails, plesty check prints the error and stops (gates run sequentially — the first failure terminates the check):

[SDK]  Gate 2  Code Hygiene                  FAIL

plesty/power_meter/device.py:47:5: E501 Line too long (112 > 99)
plesty/power_meter/device.py:83:1: F401 `typing.Optional` imported but unused
mypy: plesty/power_meter/base_device.py:62: error: Return type of "_query_" incompatible

The format is always <file>:<line>:<col>: <code> <description>. Open the file at the indicated line and fix it.

Gate 2 — Code Hygiene

The most common first failure. Fix it in two steps:

Step 1: Auto-fix formatting and safe lint rules

# Format with SDK ruff config (line-length = 99)
uv run ruff format --config $(uv run python -c \
  "from importlib.resources import files; \
   print(files('plesty.sdk').joinpath('assets/ruff.toml'))") .

# Auto-fix safe lint rules
uv run ruff check --fix .

Warning: Do not use plain ruff format without --config — the default line length differs and will fail the pre-push hook.

Step 2: Fix remaining mypy errors manually

Mypy errors require reading the flagged file and adding or correcting type annotations. Example fix:

# Before (missing return type)
def check_errors(self):
    return []

# After
def check_errors(self) -> list[str]:
    return []

Gate 5 — Documentation

[SDK]  Gate 5  Documentation Completeness     FAIL
  docs/index.md not found

Create a minimal docs/index.md:

# plesty-power-meter

Python API for the Thorlabs PM100D power meter.

## Overview

Provides `WAVELENGTH`, `POWER`, `AVERAGES`, and related parameters.

Also ensure CHANGELOG.md exists and has an entry dated after the last git tag:

# Changelog

## [2026-06-26]

### Added
- Initial device implementation with wavelength and power measurement.

Gate 6 — Dependency Coexistence

[SDK]  Gate 6  Dependency Coexistence         FAIL
  Exact pin found: plesty-lib==0.2.6

Replace exact pins with compatible ranges in pyproject.toml:

# Before
dependencies = ["plesty-lib==0.2.6"]

# After
dependencies = ["plesty-lib>=0.2,<1"]

Gate 10 — Vulnerability Audit

[SDK+CI] Gate 10 Vulnerability Audit          FAIL
  CVE-2024-XXXXX in cryptography 42.0.4

Upgrade the affected package:

uv lock --upgrade-package cryptography && uv sync

Then re-run the check to confirm the CVE is resolved.

General pattern

  1. Read the failure — <file>:<line> tells you exactly where
  2. Fix the smallest thing that resolves it
  3. Re-run uv run plesty check (or --standard pixel for a faster iteration loop)
  4. Repeat until all gates pass