Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2d83900

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

File tree

2 files changed

+11
-3
lines changed
Filter options

2 files changed

+11
-3
lines changed

‎src/mkdocstrings_handlers/python/_internal/config.py

Copy file name to clipboardExpand all lines: src/mkdocstrings_handlers/python/_internal/config.py
+8-3Lines 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

Copy file name to clipboardExpand all lines: tests/test_end_to_end.py
+3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.