Python docstring style checker for PEP 257 compliance
72
Create a lightweight docstring linting helper that focuses on selecting Python files by regex and enforcing missing-docstring rules based on public objects inferred from module names and __all__.
core_alpha.py and util_extra.py, running with file pattern ^core_.*\\.py$ reports issues only from core_alpha.py. @test__all__ for public API__all__ = ["public_fn"], a missing docstring on public_fn is reported while a missing docstring on hidden_fn is ignored. @test__init__.py sets __all__ = ["exposed"], the module exposed.py is treated as public and must have a module docstring when linted. @test@generates
from pathlib import Path
from typing import Iterable, List, Pattern, TypedDict, Union
class DocIssue(TypedDict):
file: str
line: int
code: str
message: str
def lint_docstrings(
targets: Iterable[Union[str, Path]],
file_regex: Union[str, Pattern[str]] = r".*\\.py",
include_source: bool = False,
) -> List[DocIssue]:
"""Return missing-docstring issues for regex-matched files under the given targets."""Docstring style checker with regex-based file selection and public/__all__-aware missing-docstring detection.
Install with Tessl CLI
npx tessl i tessl/pypi-pep257evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10