Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ author_email: noreply@quantco.com
author_name: QuantCo, Inc.
github_url: https://github.com/quantco/multiregex
github_user: pavelzw
minimal_python_version: py39
minimal_python_version: py311
project_short_description: Quickly match many regexes against a string. Provides 2-10x
speedups over naïve regex matching.
project_slug: multiregex
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
fail-fast: false
matrix:
environment:
- py39
- py310
- py311
- py312
- py313
Expand Down
15 changes: 4 additions & 11 deletions multiregex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@
import sre_parse
from collections.abc import Iterable
from re import Pattern
from typing import (
Optional,
TypeVar,
Union,
cast,
)
from typing import TypeVar, cast

import ahocorasick

Expand All @@ -49,7 +44,7 @@


V = TypeVar("V")
PatternOrStr = Union[Pattern, str]
PatternOrStr = Pattern | str
Prematchers = set[str]
FalsePositivesCounter = dict[str, int]

Expand All @@ -61,9 +56,7 @@ class AhocorasickError(Exception):
class RegexMatcher:
def __init__(
self,
patterns: Iterable[
Union[PatternOrStr, tuple[PatternOrStr, Optional[Iterable[str]]]]
],
patterns: Iterable[PatternOrStr | tuple[PatternOrStr, Iterable[str] | None]],
count_prematcher_false_positives=False,
):
"""
Expand Down Expand Up @@ -228,7 +221,7 @@ def get_prematcher_false_positives(
key=lambda x: -x[1]["false_positives"],
)

def format_prematcher_false_positives(self, worst_n: Optional[int] = None) -> str:
def format_prematcher_false_positives(self, worst_n: int | None = None) -> str:
output = [
"FP count | FP rate | Pattern / Prematchers",
"---------+---------+----------------------",
Expand Down
Loading
Loading