diff --git a/radish/compat.py b/radish/compat.py index c8b34253..24157304 100644 --- a/radish/compat.py +++ b/radish/compat.py @@ -3,13 +3,6 @@ """ import sys -import re - -try: - re_pattern = re.Pattern # >= Python 3.7 -except AttributeError: - re_pattern = re._pattern_type - # RecursionError does not exist in Python < 3.5 RecursionError = RuntimeError if sys.version_info < (3, 5) else RecursionError diff --git a/radish/extensions/user_data.py b/radish/extensions/user_data.py index 17434a65..3f28a0ce 100644 --- a/radish/extensions/user_data.py +++ b/radish/extensions/user_data.py @@ -3,6 +3,7 @@ and provides this data as a dictionary attached to the world.config object as per Enhancement #124. """ + import re from radish.terrain import world diff --git a/radish/matcher.py b/radish/matcher.py index 8e7a7717..b88612d6 100644 --- a/radish/matcher.py +++ b/radish/matcher.py @@ -9,7 +9,6 @@ from .customtyperegistry import CustomTypeRegistry from .exceptions import StepDefinitionNotFoundError, StepPatternError -from .compat import re_pattern StepMatch = namedtuple("StepMatch", ["argument_match", "func"]) @@ -87,7 +86,7 @@ def match_step(sentence, steps): """ potentional_matches = [] for pattern, func in steps.items(): - if isinstance(pattern, re_pattern): # pylint: disable=protected-access + if isinstance(pattern, re.Pattern): # pylint: disable=protected-access match = pattern.search(sentence) argument_match = RegexStepArguments(match) if match: diff --git a/radish/stepregistry.py b/radish/stepregistry.py index 44102db4..cf24de15 100644 --- a/radish/stepregistry.py +++ b/radish/stepregistry.py @@ -7,7 +7,6 @@ from singleton import singleton from .exceptions import RadishError, SameStepError, StepRegexError -from .compat import re_pattern @singleton() @@ -139,7 +138,7 @@ def given(pattern): """ Step decorator prefixed with the Given-keyword. """ - if isinstance(pattern, re_pattern): # pylint: disable=protected-access + if isinstance(pattern, re.Pattern): # pylint: disable=protected-access return step(re.compile(r"Given {0}".format(pattern.pattern))) return step("Given {0}".format(pattern)) @@ -148,7 +147,7 @@ def when(pattern): """ Step decorator prefixed with the When-keyword. """ - if isinstance(pattern, re_pattern): # pylint: disable=protected-access + if isinstance(pattern, re.Pattern): # pylint: disable=protected-access return step(re.compile(r"When {0}".format(pattern.pattern))) return step("When {0}".format(pattern)) @@ -157,6 +156,6 @@ def then(pattern): """ Step decorator prefixed with the Then-keyword. """ - if isinstance(pattern, re_pattern): # pylint: disable=protected-access + if isinstance(pattern, re.Pattern): # pylint: disable=protected-access return step(re.compile(r"Then {0}".format(pattern.pattern))) return step("Then {0}".format(pattern)) diff --git a/tests/radish/steps_german.py b/tests/radish/steps_german.py index 43ae67d7..86914daf 100644 --- a/tests/radish/steps_german.py +++ b/tests/radish/steps_german.py @@ -7,7 +7,6 @@ Copyright: MIT, Timo Furrer """ - from radish import step diff --git a/tests/unit/test_background.py b/tests/unit/test_background.py index 737c3c68..82d42ddb 100644 --- a/tests/unit/test_background.py +++ b/tests/unit/test_background.py @@ -7,7 +7,6 @@ Copyright: MIT, Timo Furrer """ - from radish.background import Background from radish.stepmodel import Step diff --git a/tests/unit/test_stepregistry.py b/tests/unit/test_stepregistry.py index b8097d84..f11dc6e5 100644 --- a/tests/unit/test_stepregistry.py +++ b/tests/unit/test_stepregistry.py @@ -13,7 +13,6 @@ from radish.stepregistry import step, steps from radish.stepregistry import given, when, then -from radish.compat import re_pattern import radish.exceptions as errors @@ -173,7 +172,7 @@ def step_a(step): # then assert len(stepregistry.steps) == 1 - if not isinstance(pattern, re_pattern): # doesn't work for re_pattern. + if not isinstance(pattern, re.Pattern): # doesn't work for re.Pattern. assert stepregistry.steps[pattern] == step_a @@ -197,7 +196,7 @@ def step_a(step): # then assert len(stepregistry.steps) == 1 - if not isinstance(pattern, re_pattern): # doesn't work for re_pattern. + if not isinstance(pattern, re.Pattern): # doesn't work for re.Pattern. assert stepregistry.steps[expected_pattern] == step_a @@ -221,7 +220,7 @@ def step_a(step): # then assert len(stepregistry.steps) == 1 - if not isinstance(pattern, re_pattern): # doesn't work for re_pattern. + if not isinstance(pattern, re.Pattern): # doesn't work for re.Pattern. assert stepregistry.steps[expected_pattern] == step_a @@ -245,7 +244,7 @@ def step_a(step): # then assert len(stepregistry.steps) == 1 - if not isinstance(pattern, re_pattern): # doesn't work for re_pattern. + if not isinstance(pattern, re.Pattern): # doesn't work for re.Pattern. assert stepregistry.steps[expected_pattern] == step_a