syntopica-codeality-py 0.2.5__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/.gitignore +3 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/CHANGELOG.md +27 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/PKG-INFO +48 -1
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/README.md +47 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/codeality-py.toml +3 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/pyproject.toml +4 -1
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/__init__.py +1 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/affected_config.py +13 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/affected_headline.py +13 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/affected_map_entry.py +11 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/affected_outcome.py +10 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/affected_plan.py +18 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/affected_pytest_args.py +20 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/changed_file.py +12 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/git_output.py +23 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/hook_git_variables.py +6 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/mapped_sources.py +24 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/plan_affected.py +26 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/read_changed_files.py +31 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/related_tests.py +21 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/relative_posix.py +9 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/repository_discovery_env.py +10 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/run_pytest.py +13 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/untested_message.py +11 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/widen_file_names.py +24 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/affected/widen_reason.py +30 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/assets/codeality-py-ci.yml +3 -3
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/__init__.py +1 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/format_upgrade_notice.py +23 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/parse_changelog.py +23 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/parse_version.py +13 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/read_own_changelog.py +11 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/read_version_stamp.py +13 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/release_section.py +11 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/split_action_required.py +21 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/upgrade_notice.py +42 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/version_stamp_path.py +10 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/changes/write_version_stamp.py +29 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/cli.py +4 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/commands/affected_command.py +79 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/gate_command.py +5 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/commands/test_audit_command.py +31 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/baseline_config.py +3 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/load_config.py +3 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/config/parse_affected.py +31 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/config/string_list.py +12 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/__init__.py +1 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/build_import_graph.py +35 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/dynamic_import_name.py +19 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/find_test_files.py +37 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/implicit_dependencies.py +16 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/import_reference.py +12 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/module_files.py +27 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/parse_imports.py +32 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/resolve_import.py +32 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/search_roots.py +11 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/imports/tests_reaching.py +22 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/pytest_config/__init__.py +1 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/pytest_config/default_norecursedirs.py +14 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/pytest_config/option_words.py +17 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/pytest_config/pytest_settings.py +16 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/pytest_config/read_ini_section.py +16 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/pytest_config/read_pytest_config.py +34 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/pytest_config/settings_from_options.py +20 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/__init__.py +1 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/audit_finding.py +12 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/audit_observation.py +12 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/audit_report.py +14 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/coverage_in_addopts.py +26 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/hook_runs_full_gate.py +43 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/literal_sleeps.py +41 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/missing_testpaths.py +37 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/real_sleep_in_tests.py +37 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/render_audit_report.py +37 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/run_test_audit.py +26 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/walked_directories.py +33 -0
- syntopica_codeality_py-0.3.0/src/codeality_py/test_audit/xdist_candidate.py +35 -0
- syntopica_codeality_py-0.3.0/tests/changes/test_upgrade_notice.py +118 -0
- syntopica_codeality_py-0.3.0/tests/commands/test_affected_command.py +149 -0
- syntopica_codeality_py-0.3.0/tests/commands/test_test_audit_command.py +116 -0
- syntopica_codeality_py-0.3.0/uv.lock +1166 -0
- syntopica_codeality_py-0.2.5/uv.lock +0 -1138
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/LICENSE +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/mypy.ini +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/ruff.toml +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/assets/codeality-py.toml +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/assets/importlinter.ini +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/assets/mypy.ini +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/assets/pyproject-sections.toml +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/assets/ruff.toml +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/baseline_file.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/classified_findings.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/classify_findings.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/finding_context.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/fingerprint.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/fingerprint_context.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/read_baseline.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/baseline/write_baseline.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/baseline_check_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/baseline_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/baseline_update_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/check_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/checked_project.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/init_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/commands/project_option.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/check_schema_version.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/config_error.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/default_generated_globs.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/discover_source_roots.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/discover_test_roots.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/environment_test_budget.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/limits.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/module_role.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/override.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/parse_overrides.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/parse_roles.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/parse_rule_codes.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/pyproject_layout_hints.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/read_config_document.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/reject_duplicate_role_claims.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/config/reject_unknown_keys.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/engine/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/engine/check_project.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/engine/check_result.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/engine/check_source_file.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/engine/fingerprint_findings.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/engine/rule_registry.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/budget_note.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/build_stage_result.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/gate_result.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/gate_stages.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/over_budget_detail.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/run_gate.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/run_stage.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/stage.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/stage_kind.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/stage_result.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/gate/stage_status.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/add_missing_rules.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/apply_init.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/current_branch.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/first_party_packages.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/has_ruff_table.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/managed_asset_files.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/managed_file.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/merge_pyproject_sections.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/merge_quality_group.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/merge_ruff_config.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/plan_asset_file.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/plan_disposition.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/plan_init.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/plan_pyproject.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/plan_ruff.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/plan_shadowed_ruff.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/python_floor_minor.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/read_asset.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/read_requires_python.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/render_asset.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/render_nested_workflow.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/repository_root.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/init/workflow_target.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/model/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/model/finding.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/model/location.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/model/rule_code.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/model/severity.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/parsing/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/parsing/infrastructure_error.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/parsing/parse_source_file.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/parsing/read_source_text.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/parsing/source_file.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/parsing/syntax_error_finding.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/exit_code.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/finding_document.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/findings_summary.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/render_gate_report.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/render_json_report.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/render_text_report.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/report/stage_document.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/roles/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/roles/assign_module_role.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/roles/compile_glob.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/roles/matches_any_pattern.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/roles/matches_glob.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/roles/test_file_patterns.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/barrel_only_init.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/count_code_lines.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/data_unit_findings.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/docstring_line_spans.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/entrypoint_unit_findings.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/file_matches_unit.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/grab_bag_names.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/is_allowed_barrel_statement.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/is_column_list.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/is_docstring_statement.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/is_sql_literal.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/is_static_dunder_assignment.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/is_type_checking_block.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/joined_string_text.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/looks_like_sql.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/max_file_lines.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/no_grab_bag_names.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/no_inline_sql.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/one_primary_unit.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/ordinary_unit_findings.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/sql_subject.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/rules/unit_finding.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/apply_suppressions.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/build_suppression.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/covering_suppression.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/is_overridden.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/parse_suppression_line.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/parse_suppressions.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/suppression/suppression.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/traversal/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/traversal/collect_source_files.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/traversal/default_excludes.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/traversal/gitignore_matcher.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/traversal/walk_root.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/__init__.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/coalesce_overloads.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/coalesce_singledispatch.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/collect_declarations.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/count_primary_declarations.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/declaration.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/declaration_for.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/declaration_kind.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/decorator_name.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/decorator_names.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/is_main_guard.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/is_private_local_handler.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/legacy_type_alias.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/literal_string_names.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/merge_stray_letters.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/named_declaration.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/overload_family_length.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/resolve_exported_names.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/snake_case_word.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/to_snake_case.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/src/codeality_py/units/top_level_statements.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/baseline/test_classify_findings.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/commands/test_baseline_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/commands/test_check_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/commands/test_gate_command.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/config/test_load_config.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/config/test_pyproject_layout_hints.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/conftest.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/gate/test_gate_stages.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/gate/test_run_gate.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/init/test_merge_ruff_config.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/init/test_plan_init.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/init/test_render_asset.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/model/test_finding.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/model/test_rule_code.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/parsing/test_parse_source_file.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/report/test_render_gate_report.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/roles/test_assign_module_role.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/roles/test_matches_glob.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/rules/test_barrel_only_init.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/rules/test_file_matches_unit.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/rules/test_max_file_lines.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/rules/test_no_grab_bag_names.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/rules/test_no_inline_sql.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/rules/test_one_primary_unit.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/test_cli_version.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/traversal/test_collect_source_files.py +0 -0
- {syntopica_codeality_py-0.2.5 → syntopica_codeality_py-0.3.0}/tests/units/test_to_snake_case.py +0 -0
|
@@ -42,3 +42,6 @@ reports/mutation/
|
|
|
42
42
|
|
|
43
43
|
# coverage.py writes its SQLite database beside the tests it measured.
|
|
44
44
|
.coverage
|
|
45
|
+
|
|
46
|
+
# The tools record their own version when their gate runs on themselves; that stamp is only meaningful in a consuming repository.
|
|
47
|
+
packages/*/.baseline-versions.json
|
|
@@ -4,6 +4,33 @@ All notable changes to `syntopica-codeality-py` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.3.0] - 2026-11-29
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `affected` command: runs only the pytest files that reach the files changed
|
|
12
|
+
since a base ref, widens to the whole suite for `conftest.py`, pytest or
|
|
13
|
+
project configuration, lockfiles, `.env*` files and deleted modules, and ends
|
|
14
|
+
by saying the full gate has not run. Configure it with `[affected]` in
|
|
15
|
+
`codeality-py.toml`. Git runs without the hook repository variables.
|
|
16
|
+
- `test-audit` command with the findings `coverage-in-addopts`,
|
|
17
|
+
`missing-testpaths` and `real-sleep-in-tests`, the observations
|
|
18
|
+
`xdist-candidate` and `hook-runs-full-gate`, and `--json` output.
|
|
19
|
+
- The wheel ships `CHANGELOG.md` (as `codeality_py/CHANGELOG.md`). `gate`
|
|
20
|
+
compares the installed version with the one recorded in
|
|
21
|
+
`.baseline-versions.json` and, after an upgrade, prints the changelog sections
|
|
22
|
+
in between to stderr, every `### Action required` subsection first, once.
|
|
23
|
+
Commit the file. Under `CI` it prints without recording.
|
|
24
|
+
|
|
25
|
+
## [0.2.6] - 2026-10-11
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- The workflow `init` writes pins `actions/checkout` v7, `astral-sh/setup-uv`
|
|
30
|
+
v10.3.0 and `actions/upload-artifact` v7.0.2. An existing `quality.yml` from
|
|
31
|
+
an earlier release now differs and reports a conflict; rerun `init --force` to
|
|
32
|
+
take the new pins.
|
|
33
|
+
|
|
7
34
|
## 0.2.5
|
|
8
35
|
|
|
9
36
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: syntopica-codeality-py
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Structural linter and config scaffolder for Python: atomic files, placement, size caps, no inline SQL
|
|
5
5
|
Project-URL: Homepage, https://github.com/syntopica/codeality
|
|
6
6
|
Project-URL: Issues, https://github.com/syntopica/codeality/issues
|
|
@@ -64,12 +64,59 @@ codeality-py init [--check|--apply|--force] # scaffold ruff, mypy, deptry,
|
|
|
64
64
|
codeality-py check [PATH...] # run the structural rules
|
|
65
65
|
codeality-py gate # run the whole quality chain
|
|
66
66
|
codeality-py baseline create|update|check # track migration debt
|
|
67
|
+
codeality-py affected [--base REF] [-- ...] # run only the tests a change reaches
|
|
68
|
+
codeality-py test-audit [--json] # find what makes the suite costly
|
|
67
69
|
```
|
|
68
70
|
|
|
69
71
|
`init` never overwrites: it merges into existing configuration, or reports a
|
|
70
72
|
conflict. `check` never writes. `gate` fails when a required tool is absent
|
|
71
73
|
rather than skipping it.
|
|
72
74
|
|
|
75
|
+
## Inner loop: `affected`
|
|
76
|
+
|
|
77
|
+
`codeality-py affected` runs pytest on the test files that import, directly or
|
|
78
|
+
transitively, a Python file changed since `--base` (default `HEAD`: committed
|
|
79
|
+
since, staged, unstaged and untracked). It builds a static import graph with
|
|
80
|
+
`ast`, so there is no state to keep, no first full run and no new dependency.
|
|
81
|
+
`pytest-testmon` was rejected for the opposite reasons: it keeps a
|
|
82
|
+
`.testmondata` database, traces coverage on every run and needs a full run
|
|
83
|
+
first. `--plan` prints the pytest command without running it, and everything
|
|
84
|
+
after `--` goes to pytest. When `addopts` collects coverage, `--no-cov` is
|
|
85
|
+
added, because a subset would fail the coverage threshold.
|
|
86
|
+
|
|
87
|
+
The whole suite runs when a change can reach every test without an import: a
|
|
88
|
+
`conftest.py`, `pytest.ini`, `tox.ini`, `setup.cfg`, `pyproject.toml`, a
|
|
89
|
+
lockfile, an `.env*` file, or a deleted module. When no test reaches the changed
|
|
90
|
+
files, the command says they are untested and never reports a pass. Every run
|
|
91
|
+
ends by saying the full gate has not run. Git runs without `GIT_DIR`,
|
|
92
|
+
`GIT_WORK_TREE` and `GIT_INDEX_FILE`, so it works inside a hook of a linked
|
|
93
|
+
worktree.
|
|
94
|
+
|
|
95
|
+
Dynamic imports are followed only for a literal `importlib.import_module("x")`
|
|
96
|
+
or `__import__("x")`. Declare the rest in `codeality-py.toml`:
|
|
97
|
+
|
|
98
|
+
```toml
|
|
99
|
+
[affected]
|
|
100
|
+
widen = ["fixtures/**"] # a change here runs the whole suite
|
|
101
|
+
|
|
102
|
+
[[affected.map]]
|
|
103
|
+
when = "migrations/*.sql" # a non-Python file...
|
|
104
|
+
to = ["src/app/db"] # ...counts as a change to these paths
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Suite audit: `test-audit`
|
|
108
|
+
|
|
109
|
+
Findings exit 1; observations never change the exit code. Both print their
|
|
110
|
+
evidence, and `--json` emits `schemaVersion`, `findings` and `observations`.
|
|
111
|
+
|
|
112
|
+
| Name | Kind | Reported when |
|
|
113
|
+
| --------------------- | ----------- | --------------------------------------------------------------------------- |
|
|
114
|
+
| `coverage-in-addopts` | finding | `addopts` has `--cov*`, so every run pays for tracing. |
|
|
115
|
+
| `missing-testpaths` | finding | No `testpaths` and a bare run walks 100 or more directories with no test. |
|
|
116
|
+
| `real-sleep-in-tests` | finding | A literal `time.sleep(n)` or `asyncio.sleep(n)` of 0.5s or more in a test. |
|
|
117
|
+
| `xdist-candidate` | observation | 40 or more test files and no `-n` in `addopts`. |
|
|
118
|
+
| `hook-runs-full-gate` | observation | A lefthook, husky or `.githooks` hook runs `pytest` or `codeality-py gate`. |
|
|
119
|
+
|
|
73
120
|
## Rules
|
|
74
121
|
|
|
75
122
|
| Code | Rule | Enforces |
|
|
@@ -21,12 +21,59 @@ codeality-py init [--check|--apply|--force] # scaffold ruff, mypy, deptry,
|
|
|
21
21
|
codeality-py check [PATH...] # run the structural rules
|
|
22
22
|
codeality-py gate # run the whole quality chain
|
|
23
23
|
codeality-py baseline create|update|check # track migration debt
|
|
24
|
+
codeality-py affected [--base REF] [-- ...] # run only the tests a change reaches
|
|
25
|
+
codeality-py test-audit [--json] # find what makes the suite costly
|
|
24
26
|
```
|
|
25
27
|
|
|
26
28
|
`init` never overwrites: it merges into existing configuration, or reports a
|
|
27
29
|
conflict. `check` never writes. `gate` fails when a required tool is absent
|
|
28
30
|
rather than skipping it.
|
|
29
31
|
|
|
32
|
+
## Inner loop: `affected`
|
|
33
|
+
|
|
34
|
+
`codeality-py affected` runs pytest on the test files that import, directly or
|
|
35
|
+
transitively, a Python file changed since `--base` (default `HEAD`: committed
|
|
36
|
+
since, staged, unstaged and untracked). It builds a static import graph with
|
|
37
|
+
`ast`, so there is no state to keep, no first full run and no new dependency.
|
|
38
|
+
`pytest-testmon` was rejected for the opposite reasons: it keeps a
|
|
39
|
+
`.testmondata` database, traces coverage on every run and needs a full run
|
|
40
|
+
first. `--plan` prints the pytest command without running it, and everything
|
|
41
|
+
after `--` goes to pytest. When `addopts` collects coverage, `--no-cov` is
|
|
42
|
+
added, because a subset would fail the coverage threshold.
|
|
43
|
+
|
|
44
|
+
The whole suite runs when a change can reach every test without an import: a
|
|
45
|
+
`conftest.py`, `pytest.ini`, `tox.ini`, `setup.cfg`, `pyproject.toml`, a
|
|
46
|
+
lockfile, an `.env*` file, or a deleted module. When no test reaches the changed
|
|
47
|
+
files, the command says they are untested and never reports a pass. Every run
|
|
48
|
+
ends by saying the full gate has not run. Git runs without `GIT_DIR`,
|
|
49
|
+
`GIT_WORK_TREE` and `GIT_INDEX_FILE`, so it works inside a hook of a linked
|
|
50
|
+
worktree.
|
|
51
|
+
|
|
52
|
+
Dynamic imports are followed only for a literal `importlib.import_module("x")`
|
|
53
|
+
or `__import__("x")`. Declare the rest in `codeality-py.toml`:
|
|
54
|
+
|
|
55
|
+
```toml
|
|
56
|
+
[affected]
|
|
57
|
+
widen = ["fixtures/**"] # a change here runs the whole suite
|
|
58
|
+
|
|
59
|
+
[[affected.map]]
|
|
60
|
+
when = "migrations/*.sql" # a non-Python file...
|
|
61
|
+
to = ["src/app/db"] # ...counts as a change to these paths
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Suite audit: `test-audit`
|
|
65
|
+
|
|
66
|
+
Findings exit 1; observations never change the exit code. Both print their
|
|
67
|
+
evidence, and `--json` emits `schemaVersion`, `findings` and `observations`.
|
|
68
|
+
|
|
69
|
+
| Name | Kind | Reported when |
|
|
70
|
+
| --------------------- | ----------- | --------------------------------------------------------------------------- |
|
|
71
|
+
| `coverage-in-addopts` | finding | `addopts` has `--cov*`, so every run pays for tracing. |
|
|
72
|
+
| `missing-testpaths` | finding | No `testpaths` and a bare run walks 100 or more directories with no test. |
|
|
73
|
+
| `real-sleep-in-tests` | finding | A literal `time.sleep(n)` or `asyncio.sleep(n)` of 0.5s or more in a test. |
|
|
74
|
+
| `xdist-candidate` | observation | 40 or more test files and no `-n` in `addopts`. |
|
|
75
|
+
| `hook-runs-full-gate` | observation | A lefthook, husky or `.githooks` hook runs `pytest` or `codeality-py gate`. |
|
|
76
|
+
|
|
30
77
|
## Rules
|
|
31
78
|
|
|
32
79
|
| Code | Rule | Enforces |
|
|
@@ -19,6 +19,9 @@ data = [
|
|
|
19
19
|
"src/codeality_py/engine/rule_registry.py",
|
|
20
20
|
"src/codeality_py/init/managed_asset_files.py",
|
|
21
21
|
"src/codeality_py/commands/project_option.py",
|
|
22
|
+
"src/codeality_py/affected/hook_git_variables.py",
|
|
23
|
+
"src/codeality_py/affected/widen_file_names.py",
|
|
24
|
+
"src/codeality_py/pytest_config/default_norecursedirs.py",
|
|
22
25
|
]
|
|
23
26
|
entrypoint = ["src/codeality_py/cli.py"]
|
|
24
27
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "syntopica-codeality-py"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Structural linter and config scaffolder for Python: atomic files, placement, size caps, no inline SQL"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -43,6 +43,9 @@ dev = [
|
|
|
43
43
|
[tool.hatch.build.targets.wheel]
|
|
44
44
|
packages = ["src/codeality_py"]
|
|
45
45
|
|
|
46
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
47
|
+
"CHANGELOG.md" = "codeality_py/CHANGELOG.md"
|
|
48
|
+
|
|
46
49
|
[tool.deptry]
|
|
47
50
|
known_first_party = ["codeality_py"]
|
|
48
51
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The inner-loop test run: only the tests the changed files reach."""
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""The ``[affected]`` table of codeality-py.toml."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
from codeality_py.affected.affected_map_entry import AffectedMapEntry
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True, slots=True)
|
|
9
|
+
class AffectedConfig:
|
|
10
|
+
"""Dependencies no import expresses, relative to the project root."""
|
|
11
|
+
|
|
12
|
+
widen: tuple[str, ...] = ()
|
|
13
|
+
map: tuple[AffectedMapEntry, ...] = ()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""The line that says what is about to run and why."""
|
|
2
|
+
|
|
3
|
+
from codeality_py.affected.affected_plan import AffectedPlan
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def affected_headline(plan: AffectedPlan, base: str, test_count: int) -> str:
|
|
7
|
+
"""Return the headline for a plan that runs something."""
|
|
8
|
+
if plan.kind == "full":
|
|
9
|
+
return f"affected: whole suite, because {plan.reason}"
|
|
10
|
+
return (
|
|
11
|
+
f"affected: {test_count} test file(s) reach {len(plan.sources)} changed file(s) "
|
|
12
|
+
f"since {base}"
|
|
13
|
+
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""One dependency no import expresses."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True, slots=True)
|
|
7
|
+
class AffectedMapEntry:
|
|
8
|
+
"""A change matching ``when`` also reaches the ``to`` files or directories."""
|
|
9
|
+
|
|
10
|
+
when: str
|
|
11
|
+
to: tuple[str, ...]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""The closing line of a passing inner-loop run."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def affected_outcome(test_count: int) -> str:
|
|
5
|
+
"""Say how much ran and that the full gate did not; zero is never a pass.
|
|
6
|
+
|
|
7
|
+
``test_count`` is the number of test files run, zero for the whole suite.
|
|
8
|
+
"""
|
|
9
|
+
ran = f"{test_count} test file(s)" if test_count else "the whole suite"
|
|
10
|
+
return f"affected: {ran} passed; the full gate has not run"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""What the inner-loop run will do."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True, slots=True)
|
|
9
|
+
class AffectedPlan:
|
|
10
|
+
"""The whole suite, the tests reached from some sources, or nothing."""
|
|
11
|
+
|
|
12
|
+
kind: Literal["full", "related", "none"]
|
|
13
|
+
# Why the whole suite runs; empty otherwise.
|
|
14
|
+
reason: str = ""
|
|
15
|
+
# The changed modules, and the mapped ones, that tests are traced from.
|
|
16
|
+
sources: tuple[Path, ...] = ()
|
|
17
|
+
# Changed files the import graph does not trace.
|
|
18
|
+
ignored: tuple[Path, ...] = ()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""The pytest argument vector of an inner-loop run."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from codeality_py.affected.relative_posix import relative_posix
|
|
6
|
+
from codeality_py.pytest_config.pytest_settings import PytestSettings
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def affected_pytest_args(
|
|
10
|
+
tests: tuple[Path, ...], passthrough: tuple[str, ...], settings: PytestSettings, root: Path
|
|
11
|
+
) -> tuple[str, ...]:
|
|
12
|
+
"""Return the arguments; an empty ``tests`` means the whole suite.
|
|
13
|
+
|
|
14
|
+
A project that collects coverage in ``addopts`` would fail its coverage
|
|
15
|
+
threshold on a subset of the suite and pay the tracing cost on every run,
|
|
16
|
+
so the inner loop turns it off. The gate collects coverage itself.
|
|
17
|
+
"""
|
|
18
|
+
skip_coverage = any(option.startswith("--cov") for option in settings.addopts)
|
|
19
|
+
switch = ("--no-cov",) if skip_coverage and "--no-cov" not in passthrough else ()
|
|
20
|
+
return (*(relative_posix(test, root) for test in tests), *switch, *passthrough)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""A file the repository reports as changed."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(frozen=True, slots=True)
|
|
8
|
+
class ChangedFile:
|
|
9
|
+
"""The absolute path of a changed file, and whether it is gone."""
|
|
10
|
+
|
|
11
|
+
path: Path
|
|
12
|
+
deleted: bool
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Run git in a directory and return what it prints."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from codeality_py.affected.repository_discovery_env import repository_discovery_env
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def git_output(cwd: Path, args: tuple[str, ...]) -> str:
|
|
11
|
+
"""Return stdout of ``git <args>`` run in ``cwd``; raise when git fails.
|
|
12
|
+
|
|
13
|
+
git finds the repository from ``cwd``, even inside a hook.
|
|
14
|
+
"""
|
|
15
|
+
completed = subprocess.run(
|
|
16
|
+
("git", *args),
|
|
17
|
+
cwd=cwd,
|
|
18
|
+
env=repository_discovery_env(os.environ),
|
|
19
|
+
capture_output=True,
|
|
20
|
+
text=True,
|
|
21
|
+
check=True,
|
|
22
|
+
)
|
|
23
|
+
return completed.stdout
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Variables a git hook exports that stop git finding the repository from a directory."""
|
|
2
|
+
|
|
3
|
+
# In a linked worktree git sets GIT_DIR without GIT_WORK_TREE, so a git run
|
|
4
|
+
# from a subdirectory takes that subdirectory for the top of the tree and
|
|
5
|
+
# reports every file outside it as deleted.
|
|
6
|
+
HOOK_GIT_VARIABLES: tuple[str, ...] = ("GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""The sources a configured map adds for the changed files."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from codeality_py.affected.affected_config import AffectedConfig
|
|
6
|
+
from codeality_py.affected.relative_posix import relative_posix
|
|
7
|
+
from codeality_py.roles.matches_glob import matches_glob
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def mapped_sources(
|
|
11
|
+
changed: tuple[Path, ...], config: AffectedConfig, root: Path
|
|
12
|
+
) -> tuple[Path, ...]:
|
|
13
|
+
"""Return the ``to`` files of every entry a changed file matches.
|
|
14
|
+
|
|
15
|
+
A directory stands for every Python file under it.
|
|
16
|
+
"""
|
|
17
|
+
found: list[Path] = []
|
|
18
|
+
for entry in config.map:
|
|
19
|
+
if not any(matches_glob(relative_posix(path, root), entry.when) for path in changed):
|
|
20
|
+
continue
|
|
21
|
+
for target in entry.to:
|
|
22
|
+
resolved = root / target
|
|
23
|
+
found.extend(sorted(resolved.rglob("*.py")) if resolved.is_dir() else [resolved])
|
|
24
|
+
return tuple(found)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Decide between nothing, the related tests of the changed modules, or the whole suite."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from codeality_py.affected.affected_config import AffectedConfig
|
|
6
|
+
from codeality_py.affected.affected_plan import AffectedPlan
|
|
7
|
+
from codeality_py.affected.changed_file import ChangedFile
|
|
8
|
+
from codeality_py.affected.mapped_sources import mapped_sources
|
|
9
|
+
from codeality_py.affected.widen_reason import widen_reason
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def plan_affected(
|
|
13
|
+
changed: tuple[ChangedFile, ...], config: AffectedConfig, root: Path
|
|
14
|
+
) -> AffectedPlan:
|
|
15
|
+
"""Return the plan for these changes."""
|
|
16
|
+
reason = widen_reason(changed, config, root)
|
|
17
|
+
if reason:
|
|
18
|
+
return AffectedPlan(kind="full", reason=reason)
|
|
19
|
+
present = tuple(file.path for file in changed if not file.deleted)
|
|
20
|
+
modules = tuple(path for path in present if path.suffix == ".py")
|
|
21
|
+
mapped = mapped_sources(present, config, root)
|
|
22
|
+
ignored = tuple(path for path in present if path.suffix != ".py" and path not in mapped)
|
|
23
|
+
sources = tuple(dict.fromkeys((*modules, *mapped)))
|
|
24
|
+
if not sources:
|
|
25
|
+
return AffectedPlan(kind="none", ignored=ignored)
|
|
26
|
+
return AffectedPlan(kind="related", sources=sources, ignored=ignored)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Every file that differs from a base ref in the working tree."""
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from codeality_py.affected.changed_file import ChangedFile
|
|
7
|
+
from codeality_py.affected.git_output import git_output
|
|
8
|
+
from codeality_py.config.config_error import ConfigError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def read_changed_files(root: Path, base: str) -> tuple[ChangedFile, ...]:
|
|
12
|
+
"""Return the files committed since ``base``, staged, unstaged and untracked.
|
|
13
|
+
|
|
14
|
+
Renames count as a deletion plus an addition, so both sides are seen.
|
|
15
|
+
"""
|
|
16
|
+
try:
|
|
17
|
+
top = Path(git_output(root, ("rev-parse", "--show-toplevel")).strip())
|
|
18
|
+
except (subprocess.CalledProcessError, OSError) as error:
|
|
19
|
+
raise ConfigError(f"{root} is not inside a git repository") from error
|
|
20
|
+
try:
|
|
21
|
+
diff = git_output(top, ("diff", "--name-status", "--no-renames", "-z", base, "--"))
|
|
22
|
+
except subprocess.CalledProcessError as error:
|
|
23
|
+
raise ConfigError(f"git cannot diff against {base}") from error
|
|
24
|
+
fields = [field for field in diff.split("\0") if field]
|
|
25
|
+
changed = [
|
|
26
|
+
ChangedFile(top / fields[index + 1], fields[index] == "D")
|
|
27
|
+
for index in range(0, len(fields) - 1, 2)
|
|
28
|
+
]
|
|
29
|
+
untracked = git_output(top, ("ls-files", "--others", "--exclude-standard", "-z"))
|
|
30
|
+
changed.extend(ChangedFile(top / path, False) for path in untracked.split("\0") if path)
|
|
31
|
+
return tuple(changed)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""The test files that reach a set of changed sources."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from codeality_py.config.baseline_config import BaselineConfig
|
|
6
|
+
from codeality_py.imports.build_import_graph import build_import_graph
|
|
7
|
+
from codeality_py.imports.find_test_files import find_test_files
|
|
8
|
+
from codeality_py.imports.search_roots import search_roots
|
|
9
|
+
from codeality_py.imports.tests_reaching import tests_reaching
|
|
10
|
+
from codeality_py.pytest_config.pytest_settings import PytestSettings
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def related_tests(
|
|
14
|
+
sources: tuple[Path, ...], config: BaselineConfig, settings: PytestSettings
|
|
15
|
+
) -> tuple[Path, ...]:
|
|
16
|
+
"""Return the sorted test files that are, or import, one of ``sources``."""
|
|
17
|
+
root = config.project_root.resolve()
|
|
18
|
+
tests = find_test_files(root, config.test_roots, settings.python_files, settings.norecursedirs)
|
|
19
|
+
roots = search_roots(root, config.source_roots, settings.pythonpath)
|
|
20
|
+
graph = build_import_graph(tests, roots, root)
|
|
21
|
+
return tests_reaching(graph, tests, tuple(path.resolve() for path in sources))
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""A path relative to a root, with forward slashes."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def relative_posix(path: Path, root: Path) -> str:
|
|
8
|
+
"""Return ``path`` relative to ``root``; outside it the result starts with ``..``."""
|
|
9
|
+
return Path(os.path.relpath(path, root)).as_posix()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""The environment git needs to find the repository from its working directory."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
|
|
5
|
+
from codeality_py.affected.hook_git_variables import HOOK_GIT_VARIABLES
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def repository_discovery_env(environ: Mapping[str, str]) -> dict[str, str]:
|
|
9
|
+
"""Return ``environ`` without the variables a git hook pins to one checkout."""
|
|
10
|
+
return {name: value for name, value in environ.items() if name not in HOOK_GIT_VARIABLES}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Run pytest in a project with the terminal attached."""
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def run_pytest(project_root: Path, args: tuple[str, ...]) -> int | None:
|
|
9
|
+
"""Return pytest's exit code; ``None`` when pytest is not installed."""
|
|
10
|
+
executable = shutil.which("pytest")
|
|
11
|
+
if executable is None:
|
|
12
|
+
return None
|
|
13
|
+
return subprocess.run((executable, *args), cwd=project_root, check=False).returncode
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""The line for changes no test reaches."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from codeality_py.affected.relative_posix import relative_posix
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def untested_message(sources: tuple[Path, ...], root: Path) -> str:
|
|
9
|
+
"""Say that nothing tests these changes, so no run reads as a pass."""
|
|
10
|
+
names = ", ".join(relative_posix(path, root) for path in sources)
|
|
11
|
+
return f"affected: no test reaches {names}; these changes are untested"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""File names whose change can reach every test without an import."""
|
|
2
|
+
|
|
3
|
+
# The runner's own configuration and fixtures, dependency manifests and
|
|
4
|
+
# lockfiles, environment files. Matched against the base name, wherever the
|
|
5
|
+
# file is inside the project.
|
|
6
|
+
WIDEN_FILE_NAMES: tuple[str, ...] = (
|
|
7
|
+
"conftest.py",
|
|
8
|
+
"pytest.ini",
|
|
9
|
+
"tox.ini",
|
|
10
|
+
"setup.cfg",
|
|
11
|
+
"setup.py",
|
|
12
|
+
"noxfile.py",
|
|
13
|
+
"pyproject.toml",
|
|
14
|
+
"codeality-py.toml",
|
|
15
|
+
".coveragerc",
|
|
16
|
+
".python-version",
|
|
17
|
+
"uv.lock",
|
|
18
|
+
"poetry.lock",
|
|
19
|
+
"Pipfile.lock",
|
|
20
|
+
"pdm.lock",
|
|
21
|
+
"requirements*.txt",
|
|
22
|
+
"constraints*.txt",
|
|
23
|
+
".env*",
|
|
24
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Why a set of changes needs the whole suite."""
|
|
2
|
+
|
|
3
|
+
from fnmatch import fnmatchcase
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from codeality_py.affected.affected_config import AffectedConfig
|
|
7
|
+
from codeality_py.affected.changed_file import ChangedFile
|
|
8
|
+
from codeality_py.affected.relative_posix import relative_posix
|
|
9
|
+
from codeality_py.affected.widen_file_names import WIDEN_FILE_NAMES
|
|
10
|
+
from codeality_py.roles.matches_glob import matches_glob
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def widen_reason(changed: tuple[ChangedFile, ...], config: AffectedConfig, root: Path) -> str:
|
|
14
|
+
"""Return the first reason related tests do not suffice, or an empty string.
|
|
15
|
+
|
|
16
|
+
Three reasons: a file every test may depend on without importing it, a
|
|
17
|
+
configured widen glob, or a deleted module whose importers the graph no
|
|
18
|
+
longer shows. The name rule applies inside the project only: a sibling
|
|
19
|
+
project's ``pyproject.toml`` is not this suite's configuration.
|
|
20
|
+
"""
|
|
21
|
+
for file in changed:
|
|
22
|
+
local = relative_posix(file.path, root)
|
|
23
|
+
inside = not local.startswith("..")
|
|
24
|
+
if inside and any(fnmatchcase(file.path.name, name) for name in WIDEN_FILE_NAMES):
|
|
25
|
+
return f"{local} can reach every test"
|
|
26
|
+
if any(matches_glob(local, pattern) for pattern in config.widen):
|
|
27
|
+
return f"{local} matches a widen glob"
|
|
28
|
+
if file.deleted and file.path.suffix == ".py":
|
|
29
|
+
return f"{local} was deleted, so its importers are no longer traceable"
|
|
30
|
+
return ""
|
|
@@ -16,12 +16,12 @@ jobs:
|
|
|
16
16
|
matrix:
|
|
17
17
|
python-version: ['3.11', '3.13']
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
20
20
|
with:
|
|
21
21
|
persist-credentials: false
|
|
22
22
|
|
|
23
23
|
- name: Install uv
|
|
24
|
-
uses: astral-sh/setup-uv@
|
|
24
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
25
25
|
with:
|
|
26
26
|
enable-cache: true
|
|
27
27
|
|
|
@@ -46,7 +46,7 @@ jobs:
|
|
|
46
46
|
|
|
47
47
|
- name: Upload the pyrefly shadow report
|
|
48
48
|
if: always()
|
|
49
|
-
uses: actions/upload-artifact@
|
|
49
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
50
50
|
with:
|
|
51
51
|
name: pyrefly-shadow-${{ matrix.python-version }}
|
|
52
52
|
path: pyrefly.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""What a gate tells the person who just upgraded the tool."""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Render the notice shown after an upgrade."""
|
|
2
|
+
|
|
3
|
+
from codeality_py.changes.release_section import ReleaseSection
|
|
4
|
+
from codeality_py.changes.split_action_required import split_action_required
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def format_upgrade_notice(
|
|
8
|
+
name: str, old: str, new: str, sections: list[ReleaseSection], link: str
|
|
9
|
+
) -> str:
|
|
10
|
+
"""Put what must be done first, then the notes of each release passed, newest first."""
|
|
11
|
+
actions: list[str] = []
|
|
12
|
+
notes = [f"{name} {old} -> {new}"]
|
|
13
|
+
if not sections:
|
|
14
|
+
notes.append(f" no changelog entries shipped, see {link}")
|
|
15
|
+
for section in sections:
|
|
16
|
+
action, rest = split_action_required(section.body)
|
|
17
|
+
if action:
|
|
18
|
+
actions.append(f"{name} {section.label}\n{action}")
|
|
19
|
+
if rest:
|
|
20
|
+
indented = "\n".join(f" {line}" if line else "" for line in rest.splitlines())
|
|
21
|
+
notes.append(f" {section.label}\n{indented}")
|
|
22
|
+
head = f"ACTION REQUIRED\n\n{chr(10).join(actions)}\n\n" if actions else ""
|
|
23
|
+
return f"{head}Changes\n\n" + "\n".join(notes)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Split a changelog into its released sections."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
from codeality_py.changes.release_section import ReleaseSection
|
|
6
|
+
|
|
7
|
+
_VERSION_HEADING = re.compile(r"^## \[?(\d+)\.(\d+)\.(\d+)\]?")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def parse_changelog(text: str) -> list[ReleaseSection]:
|
|
11
|
+
"""Return every versioned section; `Unreleased` and unversioned headings are dropped."""
|
|
12
|
+
sections: list[tuple[tuple[int, int, int], str, list[str]]] = []
|
|
13
|
+
current: list[str] | None = None
|
|
14
|
+
for line in text.splitlines():
|
|
15
|
+
if line.startswith("## "):
|
|
16
|
+
match = _VERSION_HEADING.match(line)
|
|
17
|
+
current = [] if match else None
|
|
18
|
+
if match and current is not None:
|
|
19
|
+
version = (int(match[1]), int(match[2]), int(match[3]))
|
|
20
|
+
sections.append((version, ".".join(match.groups()), current))
|
|
21
|
+
elif current is not None:
|
|
22
|
+
current.append(line)
|
|
23
|
+
return [ReleaseSection(v, label, "\n".join(lines).strip()) for v, label, lines in sections]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Read a `major.minor.patch` string."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
_VERSION = re.compile(r"(\d+)\.(\d+)\.(\d+)")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def parse_version(text: str) -> tuple[int, int, int] | None:
|
|
9
|
+
"""Return the numbers of a release version, or None when there are not three."""
|
|
10
|
+
match = _VERSION.match(text)
|
|
11
|
+
if match is None:
|
|
12
|
+
return None
|
|
13
|
+
return int(match[1]), int(match[2]), int(match[3])
|