Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant character escape in some regexes #2051

Merged
merged 2 commits into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+")


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/tox/package/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down