Skip to content

Commit 61395af

Browse files
committed
copilot feedback
1 parent 677ad33 commit 61395af

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

noxfile.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def test_re2(session):
6363
build_and_check_dists(session)
6464

6565
generated_files = os.listdir("dist/")
66-
generated_sdist = os.path.join("dist/", generated_files[1])
66+
sdists = sorted(f for f in generated_files if f.endswith(".tar.gz"))
67+
if not sdists:
68+
session.error("No sdist (.tar.gz) found in dist/")
69+
generated_sdist = os.path.join("dist/", sdists[0])
6770

6871
session.install(generated_sdist)
6972

src/jsonata/functions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,8 +2025,14 @@ def is_lambda(result: Optional[Any]) -> bool:
20252025
#
20262026
@staticmethod
20272027
def is_regex(value: Optional[Any]) -> bool:
2028-
return isinstance(value, re.Pattern) or (
2029-
hasattr(value, "search") and hasattr(value, "finditer") and hasattr(value, "sub")
2028+
if isinstance(value, re.Pattern):
2029+
return True
2030+
if value is None or inspect.ismodule(value) or inspect.isclass(value):
2031+
return False
2032+
return (
2033+
callable(getattr(value, "search", None))
2034+
and callable(getattr(value, "finditer", None))
2035+
and callable(getattr(value, "sub", None))
20302036
)
20312037

20322038
#

src/jsonata/jsonata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,8 +1887,9 @@ def _static_initializer() -> None:
18871887
# JSONata
18881888
# @param {Object} expr - JSONata expression
18891889
# @param {Object} regex_engine - module/object providing a `compile(pattern, flags)`
1890-
# function compatible with the stdlib `re` module (e.g. `re2`), used to compile
1891-
# JSONata regex literals. Defaults to the stdlib `re` module.
1890+
# function compatible with the stdlib `re` module (or an adapter that exposes
1891+
# this interface for engines like `google-re2`), used to compile JSONata regex
1892+
# literals. Defaults to the stdlib `re` module.
18921893
# @returns Evaluated expression
18931894
# @throws jexception.JException An exception if an error occured.
18941895
#

0 commit comments

Comments
 (0)