Skip to content

Commit

Permalink
Properly handle python variable. (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcenacp authored Dec 2, 2024
1 parent b11924c commit cf15278
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/mlcroissant/mlcroissant/_src/core/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any


def regex_to_glob(regex: str | list[str]) -> list[str]:
def regex_to_glob(regexes: str | list[str]) -> list[str]:
"""Converts a regular expression to several glob patterns.
The function applies several transformations to achieve this:
Expand All @@ -16,11 +16,11 @@ def regex_to_glob(regex: str | list[str]) -> list[str]:
- Convert to a glob pattern using some heuristics.
"""
if isinstance(regex, str):
results = [regex]
if isinstance(regexes, str):
regexes = [regexes]
for fn in [_expand_non_capturing_groups, _regex_to_glob_for_str]:
results = list(itertools.chain.from_iterable(fn(result) for result in results))
return results
regexes = list(itertools.chain.from_iterable(fn(regex) for regex in regexes))
return regexes


def _expand_non_capturing_groups(regex: str) -> Iterable[str]:
Expand Down

0 comments on commit cf15278

Please sign in to comment.