18
18
19
19
_logger = get_logger (__name__ )
20
20
21
+ _DEFAULT_FILTERS = ["!^_[^_]" ]
21
22
22
23
try :
23
24
# When Pydantic is available, use it to validate options (done automatically).
@@ -440,7 +441,7 @@ class PythonInputOptions:
440
441
to lower members in the hierarchy).
441
442
""" ,
442
443
),
443
- ] = field (default_factory = lambda : [ "!^_[^_]" ] )
444
+ ] = field (default_factory = lambda : _DEFAULT_FILTERS . copy () )
444
445
445
446
find_stubs_package : Annotated [
446
447
bool ,
@@ -914,7 +915,11 @@ def from_data(cls, **data: Any) -> Self:
914
915
class PythonOptions (PythonInputOptions ): # type: ignore[override,unused-ignore]
915
916
"""Final options passed as template context."""
916
917
917
- filters : list [tuple [re .Pattern , bool ]] = field (default_factory = list ) # type: ignore[assignment]
918
+ filters : list [tuple [re .Pattern , bool ]] = field ( # type: ignore[assignment]
919
+ default_factory = lambda : [
920
+ (re .compile (filtr .removeprefix ("!" )), filtr .startswith ("!" )) for filtr in _DEFAULT_FILTERS
921
+ ],
922
+ )
918
923
"""A list of filters applied to filter objects based on their name."""
919
924
920
925
summary : SummaryOption = field (default_factory = SummaryOption )
@@ -925,7 +930,7 @@ def coerce(cls, **data: Any) -> MutableMapping[str, Any]:
925
930
"""Create an instance from a dictionary."""
926
931
if "filters" in data :
927
932
data ["filters" ] = [
928
- (re .compile (filtr .lstrip ("!" )), filtr .startswith ("!" )) for filtr in data ["filters" ] or ()
933
+ (re .compile (filtr .removeprefix ("!" )), filtr .startswith ("!" )) for filtr in data ["filters" ] or ()
929
934
]
930
935
return super ().coerce (** data )
931
936
0 commit comments