Skip to content

Commit d9607b1

Browse files
committed
refactor: SQLite REGEX function can be inline
1 parent 175ef25 commit d9607b1

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

coverage/sqldata.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ def _connect(self):
10641064
except sqlite3.Error as exc:
10651065
raise DataError(f"Couldn't use data file {self.filename!r}: {exc}") from exc
10661066

1067-
self.con.create_function("REGEXP", 2, _regexp)
1067+
self.con.create_function("REGEXP", 2, lambda txt, pat: re.search(txt, pat) is not None)
10681068

10691069
# This pragma makes writing faster. It disables rollbacks, but we never need them.
10701070
# PyPy needs the .close() calls here, or sqlite gets twisted up:
@@ -1181,8 +1181,3 @@ def executescript(self, script):
11811181
def dump(self):
11821182
"""Return a multi-line string, the SQL dump of the database."""
11831183
return "\n".join(self.con.iterdump())
1184-
1185-
1186-
def _regexp(text, pattern):
1187-
"""A regexp function for SQLite."""
1188-
return re.search(text, pattern) is not None

0 commit comments

Comments
 (0)