From 726a275ab43d2da4628caa245eb6e69ffdca0c26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Hern=C3=A1ndez?= Date: Mon, 3 May 2021 21:08:34 +0200 Subject: [PATCH] Remove redundant character escape in some regexes (#2051) --- src/tox/config/__init__.py | 10 +++++----- src/tox/package/local.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index 63adb2bbd..b014d7751 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -61,9 +61,9 @@ INTERRUPT_TIMEOUT = 0.3 TERMINATE_TIMEOUT = 0.2 -_FACTOR_LINE_PATTERN = re.compile(r"^([\w{}\.!,-]+)\:\s+(.+)") -_ENVSTR_SPLIT_PATTERN = re.compile(r"((?:\{[^}]+\})+)|,") -_ENVSTR_EXPAND_PATTERN = re.compile(r"\{([^}]+)\}") +_FACTOR_LINE_PATTERN = re.compile(r"^([\w{}.!,-]+):\s+(.+)") +_ENVSTR_SPLIT_PATTERN = re.compile(r"((?:{[^}]+})+)|,") +_ENVSTR_EXPAND_PATTERN = re.compile(r"{([^}]+)}") _WHITESPACE_PATTERN = re.compile(r"\s+") @@ -1412,7 +1412,7 @@ def _list_section_factors(self, section): factors = set() if section in self._cfg: for _, value in self._cfg[section].items(): - exprs = re.findall(r"^([\w{}\.!,-]+)\:\s+", value, re.M) + exprs = re.findall(r"^([\w{}.!,-]+):\s+", value, re.M) factors.update(*mapcat(_split_factor_expr_all, exprs)) return factors @@ -1536,7 +1536,7 @@ def expand_section_names(config): The parser will see it as two different sections: [testenv:py36-cov], [testenv:py37-cov] """ - factor_re = re.compile(r"\{\s*([\w\s,-]+)\s*\}") + factor_re = re.compile(r"{\s*([\w\s,-]+)\s*}") split_re = re.compile(r"\s*,\s*") to_remove = set() for section in list(config.sections): diff --git a/src/tox/package/local.py b/src/tox/package/local.py index aa0751b9e..0ae86155a 100644 --- a/src/tox/package/local.py +++ b/src/tox/package/local.py @@ -49,7 +49,7 @@ def get_latest_version_of_package(package_spec): return candidates[0] -_REGEX_FILE_NAME_WITH_VERSION = re.compile(r"[\w_\-\+\.]+-(.*)\.(zip|tar\.gz)") +_REGEX_FILE_NAME_WITH_VERSION = re.compile(r"[\w_+.-]+-(.*)\.(zip|tar\.gz)") def get_version_from_filename(basename):