Skip to content

Commit

Permalink
Fix formatting for new flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Jun 26, 2020
1 parent d63fa17 commit 193fcea
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 41 deletions.
12 changes: 0 additions & 12 deletions .coveragerc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
python -m pip install ".[tests]"
- name: Lint with flake8
run: |
pip install flake8
pip install flake8==3.8.3
flake8 --show-source src/ tests/
- name: Check Manifest
run: |
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black
language_version: python3.7
Expand All @@ -9,7 +9,7 @@ repos:
types: []

- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
rev: 3.8.3
hooks:
- id: flake8
language_version: python3.7
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
[tool.coverage.run]
branch = true
parallel = true
source = ["radish"]

[tool.coverage.paths]
source = ["src", ".tox/*/site-packages"]

[tool.coverage.report]
show_missing = true

[tool.black]
target_version = ["py37"]
include = "(setup.py|src|tests)"
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"coverage": ["coverage"],
# extras for contributors
"docs": ["sphinx", "towncrier"],
"tests": ["freezegun", "coverage", "pytest", "pytest-mock"] + ["lxml", "PyYAML"],
"tests": ["freezegun", "coverage[toml]", "pytest", "pytest-mock"]
+ ["lxml", "PyYAML"],
}
EXTRAS_REQUIRES["dev"] = (
EXTRAS_REQUIRES["tests"] + EXTRAS_REQUIRES["docs"] + ["pre-commit"]
Expand Down
6 changes: 3 additions & 3 deletions src/radish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
each_rule,
each_scenario,
each_step,
for_all
for_all,
)
from radish.models import ( # noqa
Background,
Expand All @@ -40,13 +40,13 @@
ScenarioLoop,
ScenarioOutline,
Step,
Tag
Tag,
)
from radish.parser import FeatureFileParser # noqa
from radish.parsetyperegistry import ( # noqa
TypeBuilder,
custom_type,
register_custom_type
register_custom_type,
)
from radish.stepregistry import given, step, then, when # noqa
from radish.terrain import world # noqa
4 changes: 3 additions & 1 deletion src/radish/formatters/gherkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def write_feature_header(feature):

# write Feature description if available
if feature.description:
feature_description = "\n".join(INDENT_STEP + l for l in feature.description)
feature_description = "\n".join(
INDENT_STEP + line for line in feature.description
)
print(feature_description + "\n", flush=True)

# write Background if available
Expand Down
24 changes: 17 additions & 7 deletions src/radish/hookregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ class GeneratorHookImpl(HookImpl):
A Generator Hook uses a yield statement to separate
the `before` and `after` part of a Hook.
"""
def __init__(
self, what, func, on_tags, order, is_formatter=False, always=False
):

def __init__(self, what, func, on_tags, order, is_formatter=False, always=False):
super().__init__(what, None, func, on_tags, order, is_formatter, always)

self.generator = None
Expand All @@ -114,7 +113,11 @@ class HookRegistry:
DEFAULT_HOOK_ORDER = 100

GENERATOR_HOOK_NAMES = {
"for_all", "each_feature", "each_rule", "each_scenario", "each_step"
"for_all",
"each_feature",
"each_rule",
"each_scenario",
"each_step",
}

def __init__(self):
Expand Down Expand Up @@ -142,9 +145,14 @@ def register(
"""Register the given Hook for later execution"""
if inspect.isgeneratorfunction(func):
# the registered function is a generator hook
hook_impl = GeneratorHookImpl(what, func, on_tags, order, is_formatter, always)
hook_impl = GeneratorHookImpl(
what, func, on_tags, order, is_formatter, always
)

if hook_impl in self._hooks["before"][what] and hook_impl in self._hooks["after"][what]:
if (
hook_impl in self._hooks["before"][what]
and hook_impl in self._hooks["after"][what]
):
# NOTE: allow a Hook Implementation to be registered multiple times.
# This can happend when one hook module imports another in the same
# RADISH_BASEDIR.
Expand Down Expand Up @@ -328,4 +336,6 @@ def call(self, what, when, only_formatters, tagged_model, *args, **kwargs):
#: Holds a global instance of the HookRegistry which shall be used
# by all modules implementing Hooks.
registry = HookRegistry()
__all__ = registry.create_hook_decorators() + registry.create_generator_hook_decorators()
__all__ = (
registry.create_hook_decorators() + registry.create_generator_hook_decorators()
)
8 changes: 2 additions & 6 deletions src/radish/models/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ class State(IntEnum):

PASSED = 0 #: State which is set for a :class:`Step` if it ran successfully
UNTESTED = 1 #: Default State for all :class:`Step`
SKIPPED = (
2
) #: State which is set for a :class:`Step` when it's skipped using :func:`Step.skip`
PENDING = (
3
) #: State which is set for a :class:`Step` when it's marked pending using :func:`Step.pending`
SKIPPED = 2 #: State which is set for a :class:`Step` when it's skipped using :func:`Step.skip`
PENDING = 3 #: State which is set for a :class:`Step` when it's marked pending using :func:`Step.pending` # noqa
FAILED = 4 #: State which is set for a :class:`Step` when it failed to run it
RUNNING = 5 #: State which is set while a :class:`Step` is running

Expand Down
2 changes: 1 addition & 1 deletion src/radish/parser/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def rule(self, subtree):

def description(self, description_lines):
"""Transform the ``description``-subtree for the radish AST"""
return list((str(l) for l in description_lines))
return list((str(line) for line in description_lines))

def feature_body(self, subtree):
"""Transform the ``feature_body``-subtree for the radish AST"""
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/test_hookregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ def test_hookregistry_module_should_have_global_hook_decorators():

def test_hookregistry_module_should_have_global_generator_hook_decorators():
# given & when
from radish.hookregistry import for_all, each_feature, each_rule, each_scenario, each_step
from radish.hookregistry import (
for_all,
each_feature,
each_rule,
each_scenario,
each_step,
)

# then
assert callable(for_all)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ def test_parser_build_examples_for_scenario_outline(parser):


def test_parser_add_example_data_to_short_description_for_scenario_outline_examples(
parser
parser,
):
"""
The parser should build Examples for every Iteration of a Scenario Outline
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_step_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_parse_config_should_fail_if_should_match_keys_not_present(tmp_path):


def test_parse_config_should_fail_if_should_match_key_and_should_match_present(
tmp_path
tmp_path,
):
# GIVEN
matcher_config_path = create_matcher_config_file(
Expand All @@ -103,7 +103,7 @@ def test_parse_config_should_fail_if_should_match_key_and_should_match_present(


def test_parse_config_should_pass_if_should_match_key_not_and_should_not_match_present(
tmp_path
tmp_path,
):
# GIVEN
matcher_config_path = create_matcher_config_file(
Expand All @@ -122,7 +122,7 @@ def test_parse_config_should_pass_if_should_match_key_not_and_should_not_match_p


def test_parse_config_should_pass_if_should_not_match_key_not_and_should_match_present(
tmp_path
tmp_path,
):
# GIVEN
matcher_config_path = create_matcher_config_file(
Expand Down Expand Up @@ -454,7 +454,7 @@ def test_assert_step_not_match_should_pass_if_the_step_doesnt_match_any(mocker):


def test_assert_step_not_match_should_pass_if_the_step_doesnt_match_correct_step(
mocker
mocker,
):
# GIVEN
def some_step_impl(step):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ commands =
[testenv:coverage-report]
basepython = python3.8
skip_install = true
deps = coverage
deps = coverage[toml]
commands =
coverage combine
coverage report
Expand Down

0 comments on commit 193fcea

Please sign in to comment.