Skip to content

Commit 2d83900

Browse files
committed
fix: Add back default compiled filters (regression)
Issue-264: mkdocstrings#264
1 parent 93a68d0 commit 2d83900

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/mkdocstrings_handlers/python/_internal/config.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
_logger = get_logger(__name__)
2020

21+
_DEFAULT_FILTERS = ["!^_[^_]"]
2122

2223
try:
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:
914915
class 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

tests/test_end_to_end.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def _signature_package() -> Iterator[TmpPackage]:
6666
def module_function(a: int, b: str) -> None:
6767
'''Docstring for `module_function`.'''
6868
69+
def _private_function(a: int, b: str) -> None:
70+
'''Docstring for `_private_function`.'''
71+
6972
class Class:
7073
'''Docstring for `Class`.'''
7174

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy