Skip to content
Draft
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
3 changes: 2 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>cucumber/renovate-config"
"github>cucumber/renovate-config",
":enablePreCommit"
]
}
26 changes: 12 additions & 14 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,25 @@ on:

jobs:
test-python-linting:
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
defaults:
run:
working-directory: python
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version: ["3.10"]
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:
python-version: ${{ matrix.python-version }}
enable-cache: true
python-version: "3.13"
version: "0.8.17"

- name: Linting
run: |
python -m pip install pre-commit
pre-commit run --all-files

run: uvx pre-commit run --all-files

test-python:
runs-on: ${{ matrix.os }}
defaults:
Expand Down
13 changes: 5 additions & 8 deletions python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args: ['--max-line-length=130','--ignore=E203,W503']
- id: ruff-check
args: [--fix]
- id: ruff-format
4 changes: 2 additions & 2 deletions python/cucumber_expressions/argument.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

from typing import Optional, List
from typing import List, Optional

from cucumber_expressions.errors import CucumberExpressionError
from cucumber_expressions.group import Group
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.tree_regexp import TreeRegexp
from cucumber_expressions.errors import CucumberExpressionError


class Argument:
Expand Down
2 changes: 1 addition & 1 deletion python/cucumber_expressions/ast.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from enum import Enum
from typing import Optional, List
from typing import List, Optional


class NodeType(Enum):
Expand Down
16 changes: 8 additions & 8 deletions python/cucumber_expressions/expression.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from typing import Optional, List
from typing import List, Optional

from cucumber_expressions.argument import Argument
from cucumber_expressions.ast import Node, NodeType
from cucumber_expressions.expression_parser import CucumberExpressionParser
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.tree_regexp import TreeRegexp
from cucumber_expressions.errors import (
UndefinedParameterTypeError,
ParameterIsNotAllowedInOptional,
OptionalIsNotAllowedInOptional,
OptionalMayNotBeEmpty,
AlternativeMayNotBeEmpty,
AlternativeMayNotExclusivelyContainOptionals,
OptionalIsNotAllowedInOptional,
OptionalMayNotBeEmpty,
ParameterIsNotAllowedInOptional,
UndefinedParameterTypeError,
)
from cucumber_expressions.expression_parser import CucumberExpressionParser
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.tree_regexp import TreeRegexp

ESCAPE_PATTERN = rb"([\\^\[({$.|?*+})\]])"

Expand Down
6 changes: 3 additions & 3 deletions python/cucumber_expressions/expression_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import re
from typing import List

from cucumber_expressions.generated_expression import GeneratedExpression
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.parameter_type_matcher import ParameterTypeMatcher
from cucumber_expressions.combinatorial_generated_expression_factory import (
CombinatorialGeneratedExpressionFactory,
)
from cucumber_expressions.generated_expression import GeneratedExpression
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.parameter_type_matcher import ParameterTypeMatcher


class CucumberExpressionGenerator:
Expand Down
5 changes: 2 additions & 3 deletions python/cucumber_expressions/expression_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

from typing import NamedTuple, Optional, Callable, List
from typing import Callable, List, NamedTuple, Optional

from cucumber_expressions.ast import Token, TokenType, Node, NodeType
from cucumber_expressions.ast import Node, NodeType, Token, TokenType
from cucumber_expressions.errors import (
AlternationNotAllowedInOptional,
InvalidParameterTypeNameInNode,
Expand All @@ -23,7 +23,6 @@ class Parser(NamedTuple):


class CucumberExpressionParser:

# text == whitespace | ')' | '}' | .
@staticmethod
def parse_text(parser: Parser):
Expand Down
4 changes: 2 additions & 2 deletions python/cucumber_expressions/expression_tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List

from cucumber_expressions.ast import TokenType, Token
from cucumber_expressions.ast import Token, TokenType
from cucumber_expressions.errors import (
TheEndOfLineCannotBeEscaped,
CantEscape,
TheEndOfLineCannotBeEscaped,
)


Expand Down
8 changes: 4 additions & 4 deletions python/cucumber_expressions/parameter_type_registry.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import functools
import re
from decimal import Decimal
from typing import Optional, List
from typing import List, Optional

from cucumber_expressions.expression_generator import CucumberExpressionGenerator
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.errors import (
CucumberExpressionError,
AmbiguousParameterTypeError,
CucumberExpressionError,
)
from cucumber_expressions.expression_generator import CucumberExpressionGenerator
from cucumber_expressions.parameter_type import ParameterType

INTEGER_REGEXPS = [re.compile(r"-?\d+"), re.compile(r"\d+")]
FLOAT_REGEXP = re.compile(r"(?=.*\d.*)[-+]?\d*(?:\.(?=\d.*))?\d*(?:\d+[E][+-]?\d+)?")
Expand Down
2 changes: 1 addition & 1 deletion python/cucumber_expressions/regular_expression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import Optional, List
from typing import List, Optional

from cucumber_expressions.argument import Argument
from cucumber_expressions.parameter_type import ParameterType
Expand Down
16 changes: 4 additions & 12 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@ PyYAML = "^6.0"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
py_version = 38
profile = "black"
force_single_line = true
combine_as_imports = true
lines_between_types = 1
lines_after_imports = 2
src_paths = ["cucumber_expressions", "tests"]


[tool.black]
target-version = ['py38']
[tool.ruff.lint]
extend-select = [
"I",
]
2 changes: 1 addition & 1 deletion python/tests/test_custom_parameter_type.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest

from cucumber_expressions.errors import CucumberExpressionError
from cucumber_expressions.expression import CucumberExpression
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.parameter_type_registry import ParameterTypeRegistry
from cucumber_expressions.regular_expression import RegularExpression
from cucumber_expressions.errors import CucumberExpressionError


class Color:
Expand Down
3 changes: 1 addition & 2 deletions python/tests/test_expression.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from decimal import Decimal
from pathlib import Path

from tests.definitions import TESTDATA_ROOT_DIR

import pytest

from cucumber_expressions.expression import CucumberExpression
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.parameter_type_registry import ParameterTypeRegistry
from tests.definitions import TESTDATA_ROOT_DIR


def get_expectation_yamls():
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_expression_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_documents_expression_generation(self):
generated_expression.source == "I have {int} cucumbers and {float} tomato"
)
assert generated_expression.parameter_names[0] == "int"
assert generated_expression.parameter_types[1].type == float
assert generated_expression.parameter_types[1].type is float

def test_generates_expression_for_no_args(self):
self._assert_expression("hello", [], "hello")
Expand Down
3 changes: 1 addition & 2 deletions python/tests/test_expression_parser.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from pathlib import Path

from tests.definitions import TESTDATA_ROOT_DIR

import pytest

from cucumber_expressions.expression_parser import (
CucumberExpressionParser,
)
from tests.definitions import TESTDATA_ROOT_DIR


def get_expectation_yamls():
Expand Down
9 changes: 4 additions & 5 deletions python/tests/test_expression_tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from pathlib import Path

from tests.definitions import TESTDATA_ROOT_DIR

import pytest

from cucumber_expressions.expression_tokenizer import (
CucumberExpressionTokenizer,
)
from cucumber_expressions.errors import (
CantEscape,
TheEndOfLineCannotBeEscaped,
)
from cucumber_expressions.expression_tokenizer import (
CucumberExpressionTokenizer,
)
from tests.definitions import TESTDATA_ROOT_DIR


def get_expectation_yamls():
Expand Down
3 changes: 1 addition & 2 deletions python/tests/test_expression_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import pytest

from tests.definitions import TESTDATA_ROOT_DIR

from cucumber_expressions.expression import CucumberExpression
from cucumber_expressions.parameter_type_registry import ParameterTypeRegistry
from tests.definitions import TESTDATA_ROOT_DIR


def get_expectation_yamls():
Expand Down
6 changes: 3 additions & 3 deletions python/tests/test_parameter_type_registry.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pytest

from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.parameter_type_registry import ParameterTypeRegistry
from cucumber_expressions.errors import (
CucumberExpressionError,
AmbiguousParameterTypeError,
CucumberExpressionError,
)
from cucumber_expressions.parameter_type import ParameterType
from cucumber_expressions.parameter_type_registry import ParameterTypeRegistry

CAPITALISED_WORD = r"[A-Z]+\w+"

Expand Down
5 changes: 2 additions & 3 deletions python/tests/test_regular_expression.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from pathlib import Path
from typing import Optional, List

from tests.definitions import TESTDATA_ROOT_DIR
from typing import List, Optional

import pytest

from cucumber_expressions.parameter_type_registry import ParameterTypeRegistry
from cucumber_expressions.regular_expression import RegularExpression
from tests.definitions import TESTDATA_ROOT_DIR


def get_expectation_yamls():
Expand Down
Loading