Changelog¶
All notable changes to PyCodeCommenter are documented here.
v2.1.0¶
Current release
Added¶
- Rule-based parameter inference (
inference.py) — theinfer_descriptionfunction uses a priority chain (name patterns → type hints → default values → generic fallback) to produce concise, meaningful descriptions without any external calls. - Config loader (
config.py) —load_config()searches upward from the current directory for.pycodecommenter.yamland parses it withruamel.yaml.ConfigErroris raised on parse failure; a missing file returns an empty dict. --dry-runflag forpycodecommenter generate— prints a unified diff to stdout and exits with code 1 if changes exist, code 0 if none.--backupflag forpycodecommenter generate --inplace— copies the original file to<file>.bakbefore modifying it.--output/-oflag forpycodecommenter generate— writes the result to a specified output file instead of stdout.
v2.0.0 — Complete Rewrite¶
Released: 2026-01-25
Added¶
- Comprehensive validation system — six categories of documentation checks: signature matching, type consistency, exception documentation, return documentation, format compliance, and content quality.
- Coverage analysis —
CoverageAnalyzer,FileCoverage, andProjectCoverageclasses for per-file and project-wide documentation metrics. - Modern type support —
TypeAnalyzerhandles PEP 604 union types (int | str), PEP 585 generics (list[int]), subscripted types (Dict[str, Any]), and attribute types (typing.Optional). - Async function support —
async deffunctions are fully processed by both the generator and the validator. - Multiple export formats —
ValidationReportcan export to console (print_summary()), JSON (to_dict()), and Markdown (to_markdown()). - Smart docstring merging —
DocstringParserreads existing Google-style and Sphinx-style docstrings; existing text is preserved when regenerating. - Structured AST traversal —
DocstringVisitor(aNodeVisitorsubclass) replaces the previous ad-hoc walk, producing reliable results on nested classes and functions. - Severity enum —
Severity.ERROR,Severity.WARNING, andSeverity.INFOreplace plain strings. ValidationIssuedataclass — structured issue objects withseverity,category,location,message, andsuggestionfields.ValidationStatsdataclass — aggregated counters with acoverage_percentageproperty.- CI/CD-ready exit codes —
validateexits 1 on any ERROR;generate --dry-runexits 1 when changes are needed.
Changed¶
- Basic type inference replaced by comprehensive
TypeAnalyzerclass. - Docstring generation templates improved with a 60+ verb pattern dictionary (
templates.py). - Error handling unified under
loggingmodule throughout all modules. - All file reads use
encoding='utf-8'explicitly.
Fixed¶
- Duplicate
_infer_typemethods consolidated intoTypeAnalyzer. - Brittle line-based patching logic replaced with AST-aware position tracking.
- Import resolution errors when running modules directly (try/except import fallback pattern).
- Unicode/encoding issues when reading source files.
Breaking Changes¶
- Minimum Python version raised to 3.8.
- Some internal private APIs changed; the public API (
PyCodeCommenter,generate_docstrings,get_patched_code,validate,check_coverage) is backward compatible.
v1.0.0 — Initial Release¶
Earlier version
Added¶
- Basic docstring generation for functions and classes.
- Template-based descriptions using a verb-to-template dictionary.
- File input (
from_file) and string input (from_string). - Simple
generateCLI subcommand.
Related¶
- Getting Started — upgrade path and first steps
- FAQ — version-related questions