Skip to content

Commit 46dffc3

Browse files
committed
updates docstrings for functions that handle filtering
1 parent 66504db commit 46dffc3

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

scripts/microgenerator/generate.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,31 @@ def process_structure(
381381

382382

383383
def _should_include_class(class_name: str, class_filters: Dict[str, Any]) -> bool:
384-
"""Checks if a class should be included based on filter criteria."""
384+
"""Determines if a class should be included based on name filters.
385+
386+
Filters are defined in the configuration file and passed in the
387+
`class_filters` dictionary.
388+
389+
Args:
390+
class_name: The name of the class to check.
391+
class_filters: A dictionary containing filter rules:
392+
"include_suffixes": List of suffixes. If provided, the class name
393+
MUST end with one of these suffixes.
394+
"exclude_suffixes": List of suffixes. If provided, the class name
395+
MUST NOT end with any of these suffixes.
396+
397+
Returns:
398+
bool: True if the class should be included, False otherwise.
399+
400+
Example:
401+
>>> filters = {"include_suffixes": ["Client"], "exclude_suffixes": ["BaseClient"]}
402+
>>> _should_include_class("DatasetClient", filters)
403+
True
404+
>>> _should_include_class("BaseClient", filters)
405+
False
406+
>>> _should_include_class("SomeOtherClass", filters)
407+
False
408+
"""
385409
if class_filters.get("include_suffixes"):
386410
if not class_name.endswith(tuple(class_filters["include_suffixes"])):
387411
return False
@@ -392,7 +416,31 @@ def _should_include_class(class_name: str, class_filters: Dict[str, Any]) -> boo
392416

393417

394418
def _should_include_method(method_name: str, method_filters: Dict[str, Any]) -> bool:
395-
"""Checks if a method should be included based on filter criteria."""
419+
"""Determines if a method should be included based on name filters.
420+
421+
Filters are defined in the configuration file and passed in the
422+
`method_filters` dictionary.
423+
424+
Args:
425+
method_name: The name of the method to check.
426+
method_filters: A dictionary containing filter rules:
427+
"include_prefixes": List of prefixes. If provided, the method name
428+
MUST start with one of these prefixes.
429+
"exclude_prefixes": List of prefixes. If provided, the method name
430+
MUST NOT start with any of these prefixes.
431+
432+
Returns:
433+
bool: True if the method should be included, False otherwise.
434+
435+
Example:
436+
>>> filters = {"include_prefixes": ["get_", "list_"], "exclude_prefixes": ["_internal_"]}
437+
>>> _should_include_method("get_dataset", filters)
438+
True
439+
>>> _should_include_method("create_dataset", filters)
440+
False
441+
>>> _should_include_method("_internal_get_dataset", filters)
442+
False
443+
"""
396444
if method_filters.get("include_prefixes"):
397445
if not any(
398446
method_name.startswith(p) for p in method_filters["include_prefixes"]

0 commit comments

Comments
 (0)