reformat-gherkin
raw JSON → 3.0.1 verified Mon Apr 27 auth: no python
Formatter for Gherkin language. v3.0.1 supports Python >=3.7,<4.0. Releases are irregular.
pip install reformat-gherkin Common errors
error ModuleNotFoundError: No module named 'reformat_gherkin' ↓
cause The package is imported with hyphens in the module name.
fix
Use
from reformat_gherkin import ... (underscore) after installation. error TypeError: format_feature() got an unexpected keyword argument 'indent' ↓
cause In v2.0.0, the function signature changed. Old code used `indent` parameter but new signature accepts `indent` via `**kwargs` or config.
fix
Use
format_feature(feature_text, indent=2) works, but check version. In v2.0.0+ the parameter is available. error cattrs.errors.ClassValidationError: ... ↓
cause Breaking change in cattrs library. Known issue with reformat-gherkin <3.0.1.
fix
Upgrade reformat-gherkin to >=3.0.1 or revert cattrs to a compatible version (e.g., <23.2.0).
Warnings
breaking v3.0.0 upgraded gherkin-official to 24.0.0 which may change parsing behavior. Back up feature files before reformatting. ↓
fix Test reformatting on a subset of files first. Use v2.2.1 if compatibility is critical.
breaking v3.0.0 fixed escaping of triple backticks in docstrings. Previously triple backticks were not escaped; now they are escaped to \`\`\`. This may change output for docstrings containing backticks. ↓
fix Review feature files with triple backticks in docstrings; expected output now escapes them.
deprecated Python 3.6 support was dropped in v2.0.2. Python 3.7+ required. ↓
fix Upgrade Python to 3.7+.
gotcha The CLI option `--indent` accepts number of spaces, but the default is 2. Inconsistent indentation in input may be normalized unexpectedly. ↓
fix Explicitly pass `--indent` with desired value, e.g. `--indent 4`.
gotcha cattrs has breaking changes that affect reformat-gherkin (fixed in v3.0.1). Using older versions with newer cattrs may cause errors. ↓
fix Upgrade to reformat-gherkin >=3.0.1 or pin cattrs to compatible version.
Imports
- format_feature wrong
from reformat-gherkin import format_featurecorrectfrom reformat_gherkin import format_feature - main wrong
from reformat_gherkin import maincorrectfrom reformat_gherkin.cli import main
Quickstart
from reformat_gherkin import format_feature
feature_text = """Feature: Example
Scenario: Test
Given a step
"""
formatted = format_feature(feature_text)
print(formatted)
# Or using stdin: echo '...' | reformat-gherkin