- Test:
hatch run test(all tests) or callpytestdirectly. - Lint:
hatch run lint --fix(check+fix) orhatch run format(auto-fix) - Typecheck:
hatch run typecheck(all) - Examples:
hatch run example(run example tests) - All checks:
hatch run all(format, lint, test, typecheck) - V2 tests:
hatch run v2-test:test(legacy v2 compatibility tests)
- Imports: Use generic types (
Iterable,Sequence,Mapping) over concrete (list,dict). Absolute imports only (no relative). - Types: All functions require type annotations. Use
typingmodule for generics. - Docstrings: Google-style with Markdown formatting. Link references:
[ClassName.method][pact.module.ClassName.method] - Formatting: Use
rufffor linting/formatting. - Naming: Follow PEP 8. Use descriptive names that indicate purpose.
- Error handling: Use built-in exceptions (
ValueError,TypeError) for standard errors. Custom exceptions inherit fromPactError. - Validation: Use early returns to reduce nesting.
- Comments: Explain design decisions, not what code does. No comments unless necessary.
- Framework:
pytestwith files prefixedtest_. Use@pytest.mark.parametrizefor multiple scenarios. - Coverage: Focus on critical paths, edge cases, error conditions.
- Fixtures: Use pytest fixtures for shared setup. Minimize mocking.
src/pact/: Main V3+ codebase (active development)src/pact/v2/: Legacy V2 code (maintenance only - no new features)pact-python-ffi/: Low-level FFI bindings (memory management, type conversion only)pact-python-cli/: CLI wrapper (bundled binaries with system fallback)