1111import functools
1212from collections import namedtuple
1313import bracex
14+ import copyreg
1415from . import _wcparse
1516from . import _wcmatch
1617from . import util
17- from ._wcmatch import WcRegexp
1818from typing import Iterator , Iterable , AnyStr , Generic , Pattern , Callable , Any , Sequence
1919
2020__all__ = (
@@ -898,14 +898,9 @@ def glob(
898898 return list (iglob (patterns , flags = flags , root_dir = root_dir , dir_fd = dir_fd , limit = limit , exclude = exclude ))
899899
900900
901- class WcMatcher (Generic [AnyStr ]):
901+ class WcMatcher (_wcmatch . WcMatcher [AnyStr ]):
902902 """Pre-compiled matcher object."""
903903
904- def __init__ (self , matcher : WcRegexp [AnyStr ]) -> None :
905- """Initialize."""
906-
907- self .matcher = matcher # type: WcRegexp[AnyStr]
908-
909904 def match (
910905 self ,
911906 filename : AnyStr | os .PathLike [AnyStr ],
@@ -915,7 +910,7 @@ def match(
915910 ) -> bool :
916911 """Match filename."""
917912
918- return self .matcher .match (filename , root_dir , dir_fd )
913+ return self ._matcher .match (filename , root_dir , dir_fd )
919914
920915 def filter (
921916 self ,
@@ -926,7 +921,10 @@ def filter(
926921 ) -> list [AnyStr | os .PathLike [AnyStr ]]:
927922 """Match filename."""
928923
929- return self .matcher .filter (filenames , root_dir , dir_fd )
924+ return self ._matcher .filter (filenames , root_dir , dir_fd )
925+
926+
927+ copyreg .pickle (WcMatcher , lambda p : (WcMatcher , (p ._matcher ,)))
930928
931929
932930def compile ( # noqa: A001
0 commit comments