1818
1919_logger = get_logger (__name__ )
2020
21+ _DEFAULT_FILTERS = ["!^_[^_]" ]
2122
2223try :
2324 # When Pydantic is available, use it to validate options (done automatically).
@@ -440,7 +441,7 @@ class PythonInputOptions:
440441 to lower members in the hierarchy).
441442 """ ,
442443 ),
443- ] = field (default_factory = lambda : [ "!^_[^_]" ] )
444+ ] = field (default_factory = lambda : _DEFAULT_FILTERS . copy () )
444445
445446 find_stubs_package : Annotated [
446447 bool ,
@@ -914,7 +915,11 @@ def from_data(cls, **data: Any) -> Self:
914915class PythonOptions (PythonInputOptions ): # type: ignore[override,unused-ignore]
915916 """Final options passed as template context."""
916917
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+ )
918923 """A list of filters applied to filter objects based on their name."""
919924
920925 summary : SummaryOption = field (default_factory = SummaryOption )
@@ -925,7 +930,7 @@ def coerce(cls, **data: Any) -> MutableMapping[str, Any]:
925930 """Create an instance from a dictionary."""
926931 if "filters" in data :
927932 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 ()
929934 ]
930935 return super ().coerce (** data )
931936
0 commit comments