Skip to content

Commit

Permalink
Merge pull request #184 from reventlov/re_fullmatch
Browse files Browse the repository at this point in the history
Use `re.fullmatch` instead of `re.match`.
  • Loading branch information
robrussell authored Sep 20, 2024
2 parents 800bd4a + 467c678 commit 6faad3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions compiler/back_end/cpp/header_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1761,8 +1761,8 @@ def _verify_namespace_attribute(attr, source_file_name, errors):
if attr.name.text != attributes.Attribute.NAMESPACE:
return
namespace_value = ir_data_utils.reader(attr).value.string_constant
if not re.match(_NS_RE, namespace_value.text):
if re.match(_NS_EMPTY_RE, namespace_value.text):
if not re.fullmatch(_NS_RE, namespace_value.text):
if re.fullmatch(_NS_EMPTY_RE, namespace_value.text):
errors.append(
[
error.error(
Expand All @@ -1772,7 +1772,7 @@ def _verify_namespace_attribute(attr, source_file_name, errors):
)
]
)
elif re.match(_NS_GLOBAL_RE, namespace_value.text):
elif re.fullmatch(_NS_GLOBAL_RE, namespace_value.text):
errors.append(
[
error.error(
Expand Down
4 changes: 2 additions & 2 deletions compiler/front_end/attribute_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

def _valid_back_ends(attr, module_source_file):
"""Checks that `attr` holds a valid list of back end specifiers."""
if not re.match(
r"^(?:\s*[a-z][a-z0-9_]*\s*(?:,\s*[a-z][a-z0-9_]*\s*)*,?)?\s*$",
if not re.fullmatch(
r"(?:\s*[a-z][a-z0-9_]*\s*(?:,\s*[a-z][a-z0-9_]*\s*)*,?)?\s*",
attr.value.string_constant.text,
):
return [
Expand Down

0 comments on commit 6faad3e

Please sign in to comment.