Python docstring style checker for PEP 257 compliance
npx @tessl/cli install tessl/pypi-pep257@0.7.0A Python static analysis tool for checking docstring conventions and style compliance with PEP 257. The tool analyzes Python source code to identify missing or improperly formatted docstrings and provides configurable checking frameworks that can be extended with custom validation rules.
pip install pep257import pep257Common usage patterns:
from pep257 import check, PEP257Checkerimport pep257
# Check files for PEP 257 compliance
errors = list(pep257.check(['my_module.py']))
for error in errors:
print(error)
# Check with specific error code selection
errors = list(pep257.check(['my_module.py'], select=['D100', 'D101']))
# Check while ignoring specific error codes
errors = list(pep257.check(['my_module.py'], ignore=['D203']))Command-line usage:
# Basic usage
pep257 my_module.py
# With options
pep257 --explain --source my_module.py
pep257 --select=D100,D101 my_module.py
pep257 --ignore=D203 my_project/pep257 follows a modular architecture with distinct responsibilities:
Main API for checking Python files against PEP 257 docstring standards. Provides the primary check() function and PEP257Checker class for programmatic validation.
def check(filenames, select=None, ignore=None):
"""Generate PEP 257 errors that exist in filenames iterable."""
class PEP257Checker:
def check_source(self, source, filename):
"""Check source code string for docstring violations."""Comprehensive configuration parsing system supporting CLI arguments and configuration files with inheritance. Handles error code selection, file matching patterns, and runtime options.
class ConfigurationParser:
def parse(self):
"""Parse configuration from CLI and files."""
def get_files_to_check(self):
"""Generate files and error codes to check."""
class RunConfiguration:
"""Configuration for runtime behavior."""
class CheckConfiguration:
"""Configuration for error checking."""Parser system that converts Python source code into structured Definition objects representing modules, classes, functions, and methods with docstring extraction.
class Parser:
def __call__(self, filelike, filename):
"""Parse Python source into Definition tree."""
class Definition:
"""Base class for all code definitions."""
class Module(Definition):
"""Represents a Python module."""
class Function(Definition):
"""Represents a function definition."""
class Class(Definition):
"""Represents a class definition."""__version__ = "0.7.0"
__all__ = ("check", "collect") # Note: 'collect' function not implemented
# Return codes
NO_VIOLATIONS_RETURN_CODE = 0
VIOLATIONS_RETURN_CODE = 1
INVALID_OPTIONS_RETURN_CODE = 2class AllError(Exception):
"""Exception for __all__ parsing errors."""
class IllegalConfiguration(Exception):
"""Exception for illegal configuration options."""