Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
161875b
debt: pytest pyproject.toml configuration
kieran-ryan Sep 1, 2025
6db4370
debt: Lint pyupgrade via ruff
kieran-ryan Sep 1, 2025
1f69e75
debt: Run isort through ruff
kieran-ryan Sep 1, 2025
4c9e69b
Enable ruff default rules
kieran-ryan Sep 1, 2025
7af2d39
debt: Format Python through ruff
kieran-ryan Sep 1, 2025
7c9cd4e
debt: Build Python package with uv build backend
kieran-ryan Sep 1, 2025
e74f9ca
debt: redundant pytest configuration
kieran-ryan Sep 1, 2025
70b0907
refactor: Python package build and deploy with uv
kieran-ryan Sep 12, 2025
d9c68ae
Merge branch 'main' into debt/standardise-py-tooling
kieran-ryan Sep 12, 2025
25e843c
refactor: only run mypy through pre-commit
kieran-ryan Sep 12, 2025
570d4da
refactor: Trim tox configuration
kieran-ryan Sep 13, 2025
9487b3a
debt: Redundant mypy overrides configuration
kieran-ryan Sep 13, 2025
e4da46b
refactor: Language agnostic coverage action
kieran-ryan Sep 13, 2025
578f166
refactor: Install tox dependencies with uv
kieran-ryan Sep 13, 2025
8086993
chore: Bump to latest codecov action
kieran-ryan Sep 13, 2025
316f464
debt: Freeze pre-commit dependencies
kieran-ryan Sep 13, 2025
f390853
debt: test pypy311 and drop pypy39
kieran-ryan Sep 13, 2025
8ee4e32
refactor: Leverage tox py alias
kieran-ryan Sep 13, 2025
81568c3
debt: Run linting through latest Python only
kieran-ryan Sep 13, 2025
88f89f0
refactor: Serialise Python 3.13 lint and test jobs
kieran-ryan Sep 14, 2025
aa297d0
refactor: Extend Python linting rules
kieran-ryan Sep 14, 2025
b96119f
Merge branch 'main' into debt/standardise-py-tooling
kieran-ryan Sep 14, 2025
e35af24
chore: Changelog drop legacy Python dist metadata
kieran-ryan Sep 14, 2025
a2947a7
fix: Run Python workflow when pre-commit modified
kieran-ryan Sep 14, 2025
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
23 changes: 8 additions & 15 deletions .github/workflows/release-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,17 @@ jobs:
run:
working-directory: python
steps:
- name: Checkout code
uses: actions/checkout@v5
- uses: actions/checkout@v5

- name: Set up Python 3.13
uses: actions/setup-python@v6
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: "3.13"

- name: Show Python version
run: python --version
version: "0.8.17"

- name: Build package
run: |
python -m pip install build twine
python -m build
twine check --strict dist/*
run: uv build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist
- name: Publish package
run: uv publish --trusted-publishing=always
49 changes: 29 additions & 20 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,56 @@ on:
- main
- renovate/**
paths:
- .pre-commit-config.yaml
- python/**
- Makefile
- .github/**
pull_request:
branches:
- main
paths:
- .pre-commit-config.yaml
- python/**
- Makefile
- .github/**
workflow_call:

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Test latest python on Windows / macOS
- { os: 'windows-latest', python-version: '3.13' }
- { os: 'macos-latest', python-version: '3.13' }
- { os: 'windows-latest', python-version: '3.13', toxenv: 'py' }
- { os: 'macos-latest', python-version: '3.13', toxenv: 'py' }
# Running linting through latest Python
- { os: 'ubuntu-latest', python-version: '3.13', toxenv: 'lint,py' }
os: ['ubuntu-latest']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.9', 'pypy3.10']

python-version: ['3.9', '3.10', '3.11', '3.12', 'pypy3.10', 'pypy3.11']
toxenv: ['py']
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools
pip install tox tox-gh-actions codecov
- name: Test with tox
working-directory: ./python
run: |
tox
- name: Gather codecov report
working-directory: ./python
version: "0.8.17"

- name: Linting and testing
run: |
codecov
uv tool install tox --with tox-uv
tox -e ${{ matrix.toxenv }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: python/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build package
run: uv build
27 changes: 8 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,24 @@
files: ^python/
exclude: .*python/src/cucumber_messages/_messages\.py
repos:
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args:
- "python/src"
- "python/tests"
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
rev: 19b28a9f0a0102b30776f054bea4176e7af50dbe # frozen: v2.15.0
hooks:
- id: pretty-format-toml
args: [--autofix]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 13a6bda8ea7612b3aec844ded16569d424b9a1ab # frozen: v0.13.0
hooks:
- id: pyupgrade
args: ["--py39-plus"]
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: 30f435a17e4833cfc546d0c2bff4ec75d815f739 # frozen: v1.18.1
hooks:
- id: mypy
additional_dependencies: [types-setuptools, types-certifi]
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Removed
- [Python] Dropped legacy .egg-info metadata distribution artifacts ([#324](https://github.com/cucumber/messages/pull/324))

## [29.0.1] - 2025-09-08
### Fixed
Expand Down
5 changes: 5 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pip-log.txt

# Unit test / coverage reports
.coverage
coverage.xml
.tox
nosetests.xml

Expand All @@ -53,3 +54,7 @@ nosetests.xml
/include
/share
/local
.venv/

.mypy_cache/
.ruff_cache/
146 changes: 61 additions & 85 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61.0", "wheel"]
build-backend = "uv_build"
requires = ["uv_build>=0.8.4,<0.9.0"]

[dependency-groups]
dev = [
"coverage>=7.2",
"pytest>=6.1",
"GitPython",
"packaging",
"tox>=4.22"
]

[project]
authors = [
Expand All @@ -24,43 +33,25 @@ classifiers = [
]
dependencies = []
description = "Cucumber Messages is a message protocol for representing results and other information from Cucumber. "
license = {text = "MIT"}
keywords = ["gherkin", "cucumber", "bdd"]
license = "MIT"
license-files = [
"LICENSE"
]
maintainers = [
{name = "Konstantin Goloveshko", email = "kostya.goloveshko@gmail.com"}
]
name = "cucumber-messages"
readme = {file = "README.md", content-type = "text/markdown"}
readme = "README.md"
requires-python = ">=3.9"
urls = {Repository = "https://github.com/cucumber/messages"}
version = "29.0.1"

[project.optional-dependencies]
test = [
# local
"cucumber-messages[test-coverage]",
# external; Must be in sync with [tool.tox]
"mypy",
"pre-commit",
"tox>=4.2"
]
test-coverage = [
"coverage",
"GitPython",
"packaging",
"pytest"
]

[tool.black]
# Don't include autogenerated file
force-exclude = ".*\\/src\\/cucumber_messages\\/_messages\\.py"
line-length = 120
target-version = ["py39", "py310", "py311", "py312", "py313"]
verbose = true

[tool.isort]
line_length = 120
multi_line_output = 3
profile = "black"
[project.urls]
Changelog = "https://github.com/cucumber/messages/releases"
Download = "https://pypi.org/project/cucumber-messages"
Homepage = "https://github.com/cucumber/messages"
Issues = "https://github.com/cucumber/messages/issues"
Repository = "https://github.com/cucumber/messages.git"

[tool.mypy]
files = "src/**/*.py"
Expand All @@ -71,62 +62,47 @@ show_error_codes = true
warn_return_any = true
warn_unused_configs = true

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = [
]
[tool.ruff]
line-length = 120

# Once https://github.com/tox-dev/tox/issues/999 is released and available, migrate to the new tox approach
[tool.tox]
# language=INI
legacy_tox_ini = """
[tox]
requires =
tox>=4.2
env_list =
py313-pre-commit-lin
py{313, 312, 311, 310, 39}-mypy-lin
py{py310, py39, 313, 312, 311, 310, 39}-pytest-coverage-lin
py313-pytest-coverage-{win, mac}
distshare = {homedir}/.tox/distshare
[tool.ruff.format]
# Ignore generated module
exclude = ["src/cucumber_messages/_messages.py"]

[testenv]
platform =
lin: linux
mac: darwin
win: win32
[tool.ruff.lint]
extend-select = [
"B",
"C4",
"COM",
"FURB",
"I",
"ISC",
"N",
"PERF",
"PIE",
"RET",
"TID",
"UP"
]

[testenv:py313-pre-commit-lin]
skip_install = true
deps =
pre-commit
commands =
pre-commit run
[tool.ruff.lint.extend-per-file-ignores]
# TODO: Evaluate whether to use wildcard (removing need for updates) or explicit imports
"src/cucumber_messages/__init__.py" = ["F403"]

[testenv:py{313, 312, 311, 310, 39}-mypy-lin]
deps =
mypy
allowlist_externals =
mkdir
chmod
commands =
mkdir .mypy_cache
chmod 755 .mypy_cache
python -m mypy --cache-dir .mypy_cache
[tool.tox]
env_list = ["lint", "3.13", "3.12", "3.11", "3.10", "3.9", "pypy311", "pypy310"]
requires = ["tox>=4.22"]

[testenv:py{py310, py39, 313, 312, 311, 310, 39}-pytest-coverage-{lin, win, mac}]
deps =
.[test-coverage]
commands =
coverage run --append -m pytest -vvl
[tool.tox.env.lint]
commands = [["pre-commit", "run", "--all-files", "--show-diff-on-failure"]]
deps = ["pre-commit-uv>=4.1.1"]
description = "Run linting and formatting checks (and auto-fixes)"

[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313
pypy-3.9: pypy39
pypy-3.10: pypy310
"""
[tool.tox.env_run_base]
commands = [
["coverage", "run", "--append", "-m", "pytest", "-vvl"],
["coverage", "xml"]
]
dependency_groups = [
"dev"
]
2 changes: 0 additions & 2 deletions python/pytest.ini

This file was deleted.

5 changes: 2 additions & 3 deletions python/src/cucumber_messages/json_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _convert_value(self, value: Any, target_type: Any, field_name: Optional[str]
if value is None:
return None

converted = (
return (
self._convert_optional(value, target_type, field_name)
or self._convert_datetime(value, target_type)
or self._convert_enum(value, target_type)
Expand All @@ -188,7 +188,6 @@ def _convert_value(self, value: Any, target_type: Any, field_name: Optional[str]
or self._convert_dataclass(value, target_type)
or value
)
return converted

def from_dict(self, data: Any, target_class: type[Any]) -> Any:
"""Convert a dictionary to a dataclass instance."""
Expand All @@ -215,7 +214,7 @@ def from_dict(self, data: Any, target_class: type[Any]) -> Any:
try:
init_kwargs[field_name] = self._convert_value(value, field_type, field_name)
except Exception as e:
raise TypeError(f"Error converting field {key}: {str(e)}")
raise TypeError(f"Error converting field {key}: {str(e)}") from e

missing_required = [
name
Expand Down
Empty file removed python/tests/conftest.py
Empty file.
Loading
Loading