Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/instructions/pact-v2.instructions.md

This file was deleted.

6 changes: 0 additions & 6 deletions .github/instructions/pact.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,3 @@ applyTo: "/src/pact/**"
- `match/` - Matching rules and matchers
- `generate/` - Value generators
- `interaction/` - Interaction building blocks

## V2 Legacy Code

- Files in `v2/` subdirectories implement the legacy version of Pact Python
- This version is in maintenance mode with only critical bug fixes being applied
- New features and active development should focus on the main codebase
4 changes: 0 additions & 4 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@
- name: area:ffi
description: Relating to the FFI
color: C2E0C6

- name: area:v2
description: Relating to v2 code
color: C2E0C6
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ jobs:
- name: Run tests
run: hatch run test.py${{ matrix.python-version }}:test --junit-xml=junit.xml --cov-report=xml:coverage-tests.xml

- name: Run tests (v2)
run: hatch run v2-test.py${{ matrix.python-version }}:test --junit-xml=v2-junit.xml --cov-report=xml:coverage-v2.xml

- name: Run tests (CLI)
working-directory: pact-python-cli
run: hatch run test.py${{ matrix.python-version }}:test --junit-xml=junit.xml --cov-report=xml:coverage-cli.xml
Expand All @@ -117,7 +114,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: tests
files: coverage-tests.xml,coverage-v2.xml,pact-python-cli/coverage-cli.xml,pact-python-ffi/coverage-ffi.xml
files: coverage-tests.xml,pact-python-cli/coverage-cli.xml,pact-python-ffi/coverage-ffi.xml

- name: Upload test results
if: ${{ !cancelled() }}
Expand Down
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"python.testing.pytestArgs": [
"--reruns=0",
"--no-cov",
"--ignore=examples/v2",
"--ignore=tests/v2",
"examples/",
"pact-python-cli/tests/",
"pact-python-ffi/tests/",
Expand Down
2 changes: 0 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
- **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)

## Code Style

Expand All @@ -29,6 +28,5 @@
## Project Structure

- `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)
42 changes: 13 additions & 29 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Migration Guide

<!-- markdownlint-disable no-duplicate-heading -->

> [!INFO]
>
> This document is best viewed on the [Pact Python docs site](https://pact-foundation.github.io/pact-python/MIGRATION/).

This document outlines the key changes and migration steps for users transitioning between major Pact Python versions. It focuses on breaking changes, new features, and best practices to ensure a smooth upgrade.

## Migrating from `3.x` to `4.x`

### Key Changes

- The `pact.v2` compatibility module and the `compat-v2` extra have been removed, along with the `pact-verifier` console script. Code still importing from `pact.v2` must move to the `3.x` API described in [Migrating from `2.x` to `3.x`](#migrating-from-2x-to-3x).
- Python 3.11 or newer is required.
- The `compat-v2` extra used to install [`pact-python-cli`](https://pypi.org/project/pact-python-cli/). Install it directly if you rely on the Pact CLI (for example, `pact broker` to publish contracts).

Projects that cannot migrate yet should pin `pact-python<4`, which still provides `pact.v2` through `pact-python[compat-v2]`.

## Migrating from `2.x` to `3.x`

### Key Changes
Expand All @@ -14,35 +26,7 @@ This document outlines the key changes and migration steps for users transitioni
- This will help ensure feature parity between different language implementations and improve performance and reliability. This also brings compatibility with the latest Pact Specification (v4).
- The bundled CLI is now a separate package: [`pact-python-cli`](https://pypi.org/project/pact-python-cli/).
- The programmatic API has been completely overhauled to be more Pythonic and easier to use. Legacy process calls and return code checks have been removed in favour of proper exception handling.
- The old programmatic interface is available in the `pact.v2` module for backwards compatibility. This is deprecated, will not receive new features, and will be removed in a future release.

### Using the `pact.v2` Compatibility Module

For teams with larger codebases that need time to fully migrate to the new v3 API, a backwards compatibility module is provided at `pact.v2`. This module contains the same API as Pact Python v2.x and serves as an interim measure to assist gradual migration.

To use the v2 compatibility module, you must install pact-python with the `compat-v2` feature enabled:

```bash
pip install pact-python[compat-v2]
```

All existing `pact.*` imports need to be updated to use `pact.v2.*` instead. Here are some common examples:

```python
# Old v2.x imports
from pact import Consumer, Provider
from pact.matchers import Like, EachLike
from pact.verifier import Verifier

# New v3.x imports using the v2 compatibility module
from pact.v2 import Consumer, Provider
from pact.v2.matchers import Like, EachLike
from pact.v2.verifier import Verifier
```

Please note that this compatibility module is intended as a temporary solution. A full migration to the new v3 API is strongly recommended as soon as feasible. The compatibility module will only receive critical bug fixes and no new features.

Pact, by default, updates existing Pact contracts in place, so migrating consumer tests incrementally should be feasible. However, newer features (e.g., message pacts) will likely require a full migration, and mixed usage of v2 and v3 APIs is not officially supported.
- The old programmatic interface was available in the `pact.v2` module during the `3.x` series. It was removed in `4.0.0`; see [Migrating from `3.x` to `4.x`](#migrating-from-3x-to-4x).

### Consumer Changes

Expand Down
6 changes: 1 addition & 5 deletions docs/scripts/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def process_python(
("src/pact", "api"),
],
python_mapping=[("src.pact", "pact")],
ignore=["src/pact/v2"],
)
process_python(
"pact-python-cli/src/pact_cli",
Expand All @@ -227,7 +226,4 @@ def process_python(
("pact-python-ffi/src/pact_ffi", "pact-python-ffi/api"),
],
)
process_python(
"examples",
ignore=["examples/v2"],
)
process_python("examples")
Empty file removed examples/v2/__init__.py
Empty file.
12 changes: 0 additions & 12 deletions examples/v2/src/__init__.py

This file was deleted.

155 changes: 0 additions & 155 deletions examples/v2/src/consumer.py

This file was deleted.

Loading
Loading