API Reference¶
Core Modules¶
CLI Module¶
.. py:module:: preen.cli
Command‑line interface for preen.
This module defines a Typer application exposing the preen command. At
present only the sync subcommand is implemented, which reads the
pyproject.toml in the current working directory (or a user‑supplied
directory) and regenerates derived files. Additional subcommands will be
added in future phases of development.
.. py:function:: bump(part: ~typing.Literal[‘major’, ‘minor’, ‘patch’] = <typer.models.ArgumentInfo object>, path: str | None = <typer.models.OptionInfo object>, no_commit: bool = <typer.models.OptionInfo object>, dry_run: bool = <typer.models.OptionInfo object>) -> None :module: preen.cli
Bump package version and sync derived files.
Updates the version in pyproject.toml according to semantic versioning, then syncs all derived files (CITATION.cff, workflows, etc.) and optionally commits the changes to git.
.. rubric:: Examples
preen bump patch # 1.0.0 -> 1.0.1 preen bump minor # 1.0.1 -> 1.1.0 preen bump major # 1.1.0 -> 2.0.0
.. py:function:: check(path: str | None = <typer.models.ArgumentInfo object>, strict: bool = <typer.models.OptionInfo object>, explain: bool = <typer.models.OptionInfo object>, skip: list[str] | None = <typer.models.OptionInfo object>, only: list[str] | None = <typer.models.OptionInfo object>) -> None :module: preen.cli
Run checks on the package (pure detection, no fixing).
This command runs various checks including linting, tests, and configuration validation. For fixing issues, use ‘preen fix’. For guided release workflow, use ‘preen release’.
.. py:function:: fix(check_name: str | None = <typer.models.ArgumentInfo object>, path: str | None = <typer.models.OptionInfo object>, auto: bool = <typer.models.OptionInfo object>, interactive: bool = <typer.models.OptionInfo object>) -> None :module: preen.cli
Apply fixes for issues found by checks.
This command finds and applies fixes for issues detected by preen checks. Use after running ‘preen check’ to fix detected problems.
.. rubric:: Examples
preen fix # Fix all issues interactively preen fix ruff # Fix only ruff issues preen fix –auto # Apply all fixes automatically preen fix citation –auto # Auto-fix citation issues only
.. py:function:: init(package_name: str | None = <typer.models.ArgumentInfo object>, directory: str | None = <typer.models.OptionInfo object>) -> None :module: preen.cli
Initialize a new Python package with opinionated structure.
Creates a new package directory with:
pyproject.toml with modern Python packaging configuration
Opinionated directory structure (src/ layout by default)
Basic tests and CI configuration
Generated files (CITATION.cff, workflows, etc.)
.. py:function:: release(path: str | None = <typer.models.OptionInfo object>, target: str = <typer.models.OptionInfo object>, skip_checks: bool = <typer.models.OptionInfo object>, dry_run: bool = <typer.models.OptionInfo object>) -> None :module: preen.cli
Interactive release workflow similar to devtools::release().
Runs checks, asks questions, and guides you through the release process. Allows overriding non-critical issues with informed consent.
.. py:function:: run() :module: preen.cli
Entry point for console scripts created by the build backend.
.. py:function:: sync(path: str | None = <typer.models.ArgumentInfo object>, quiet: bool = <typer.models.OptionInfo object>, check: bool = <typer.models.OptionInfo object>, only: list[str] | None = <typer.models.OptionInfo object>) -> None :module: preen.cli
Synchronise derived files from pyproject.toml.
This command reads the project’s configuration and writes or updates files
such as CITATION.cff, documentation configuration and GitHub Actions
workflows. It treats pyproject.toml as the single source of truth.
Configuration¶
.. py:module:: preen.config
Configuration management for preen.
This module handles loading and merging configuration from pyproject.toml’s [tool.preen] section with default values.
.. py:class:: PreenConfig(src_layout: bool = True, tests_at_root: bool = True, examples_at_root: bool = True, sphinx_theme: str = ‘furo’, use_myst: bool = True, readme_includes: bool = True, autodoc: bool = True, ci_os: ~typing.List[str] =
Bases: :py:class:object
Configuration for preen behavior.
.. py:attribute:: PreenConfig.autodoc :module: preen.config :type: bool :value: True
.. py:attribute:: PreenConfig.ci_extras :module: preen.config :type: ~typing.List[str]
.. py:attribute:: PreenConfig.ci_os :module: preen.config :type: ~typing.List[str]
.. py:attribute:: PreenConfig.ci_runner :module: preen.config :type: str :value: ‘uv’
.. py:attribute:: PreenConfig.custom_checks :module: preen.config :type: ~typing.List[str]
.. py:attribute:: PreenConfig.examples_at_root :module: preen.config :type: bool :value: True
.. py:method:: PreenConfig.from_pyproject(project_dir: ~pathlib.Path) -> ~preen.config.PreenConfig :module: preen.config :classmethod:
Load configuration from pyproject.toml.
:param project_dir: Path to the project directory
:returns: PreenConfig instance with values from [tool.preen] or defaults
.. py:method:: PreenConfig.get_ci_python_versions(pyproject_data: ~typing.Dict[str, ~typing.Any]) -> ~typing.List[str] :module: preen.config
Get Python versions from explicit preen config or sensible defaults.
:param pyproject_data: Parsed pyproject.toml data
:returns: List of Python version strings for CI matrix
.. py:attribute:: PreenConfig.llm_enabled :module: preen.config :type: bool :value: False
.. py:attribute:: PreenConfig.llm_model :module: preen.config :type: str :value: ‘claude-3-sonnet-20240320’
.. py:attribute:: PreenConfig.llm_provider :module: preen.config :type: str :value: ‘anthropic’
.. py:attribute:: PreenConfig.readme_includes :module: preen.config :type: bool :value: True
.. py:attribute:: PreenConfig.release_branch :module: preen.config :type: str :value: ‘main’
.. py:attribute:: PreenConfig.skip_checks :module: preen.config :type: ~typing.List[str]
.. py:attribute:: PreenConfig.sphinx_theme :module: preen.config :type: str :value: ‘furo’
.. py:attribute:: PreenConfig.src_layout :module: preen.config :type: bool :value: True
.. py:attribute:: PreenConfig.tag_prefix :module: preen.config :type: str :value: ‘v’
.. py:attribute:: PreenConfig.tests_at_root :module: preen.config :type: bool :value: True
.. py:attribute:: PreenConfig.trusted_publisher :module: preen.config :type: bool :value: True
.. py:attribute:: PreenConfig.use_myst :module: preen.config :type: bool :value: True
Syncer¶
.. py:module:: preen.syncer
Synchronisation utilities for preen.
This module contains the implementation of the sync_project function, which
generates a set of standard configuration files based on the metadata found in
a project’s pyproject.toml. The goal of sync_project is to treat
pyproject.toml as the single source of truth and update derivative files
such as GitHub Actions workflows, documentation configuration and a
CITATION.cff accordingly.
The implementation is deliberately conservative and only performs a subset of the full functionality described in the vision document. It is intended to provide a working foundation for Phase 1 of the project while leaving room for future extension. The function will create directories as needed and overwrite existing generated files.
.. py:function:: sync_project(project_dir: str | ~pathlib.Path, quiet: bool = False, check: bool = False, targets: ~typing.Set[str] | None = None) -> ~typing.Dict[str, ~typing.Dict[str, str]] :module: preen.syncer
Synchronise derived files based on pyproject.toml.
This function reads the project’s pyproject.toml and writes a set of
files that are derived from its metadata. It always overwrites existing
generated files and returns a mapping of relative file paths to the
generated content.
Parameters¶
project_dir: The root directory of the project.
quiet: If true, suppresses printing informational messages. The function always returns the mapping irrespective of this flag.
check: If true, only checks if files would change without writing them. Returns exit code 1 if any files would change.
targets: If specified, only sync these targets. Valid values: ‘ci’, ‘citation’, ‘docs’, ‘workflows’
Returns¶
dict A mapping with ‘updated’, ‘unchanged’, and ‘would_change’ keys.
Commands¶
Base Commands¶
.. py:module:: preen.commands
Commands for preen CLI.
Initialize Command¶
.. py:module:: preen.commands.init
Init command for creating new packages.
.. py:function:: create_license_file(target_dir: ~pathlib.Path, license_name: str) -> None :module: preen.commands.init
Create LICENSE file based on license type.
.. py:function:: create_package_structure(target_dir: ~pathlib.Path, metadata: dict[str, ~typing.Any], src_layout: bool = True) -> None :module: preen.commands.init
Create the package directory structure.
.. py:function:: get_package_metadata() -> dict[str, ~typing.Any] :module: preen.commands.init
Collect package metadata from user input.
.. py:function:: init_package(package_name: str | None = None, target_dir: ~pathlib.Path | None = None) -> None :module: preen.commands.init
Initialize a new package.
.. py:function:: is_valid_package_name(name: str) -> bool :module: preen.commands.init
Check if package name follows Python naming conventions.
Bump Command¶
.. py:module:: preen.commands.bump
Version bump command.
.. py:function:: bump_package_version(part: ~typing.Literal[‘major’, ‘minor’, ‘patch’], project_dir: ~pathlib.Path | None = None, commit: bool = True, dry_run: bool = False) -> None :module: preen.commands.bump
Bump package version and sync derived files.
:param part: Which part of version to bump :param project_dir: Project directory (defaults to current) :param commit: Whether to commit changes to git :param dry_run: Show what would be done without making changes
.. py:function:: bump_version(current_version: str, part: ~typing.Literal[‘major’, ‘minor’, ‘patch’]) -> str :module: preen.commands.bump
Bump version according to semantic versioning rules.
:param current_version: Current version string :param part: Which part to bump (‘major’, ‘minor’, or ‘patch’)
:returns: New version string
.. py:function:: commit_version_bump(project_dir: ~pathlib.Path, new_version: str) -> None :module: preen.commands.bump
Commit the version bump to git.
:param project_dir: Project directory path :param new_version: New version string
.. py:function:: format_version(major: int, minor: int, patch: int) -> str :module: preen.commands.bump
Format version components into a string.
.. py:function:: get_current_version(project_dir: ~pathlib.Path) -> str :module: preen.commands.bump
Get current version from pyproject.toml.
:param project_dir: Project directory path
:returns: Current version string
:raises FileNotFoundError: If pyproject.toml doesn’t exist :raises ValueError: If version is not found or invalid
.. py:function:: is_git_clean(project_dir: ~pathlib.Path) -> bool :module: preen.commands.bump
Check if git working directory is clean.
.. py:function:: is_git_repo(project_dir: ~pathlib.Path) -> bool :module: preen.commands.bump
Check if directory is a git repository.
.. py:function:: parse_version(version_str: str) -> tuple[int, int, int] :module: preen.commands.bump
Parse a semantic version string into components.
:param version_str: Version string like “1.2.3”
:returns: Tuple of (major, minor, patch) integers
:raises ValueError: If version string is invalid
.. py:function:: update_pyproject_version(project_dir: ~pathlib.Path, new_version: str) -> None :module: preen.commands.bump
Update version in pyproject.toml.
:param project_dir: Project directory path :param new_version: New version string
Fix Command¶
.. py:module:: preen.commands.fix
Fix command for applying targeted fixes.
.. py:function:: apply_fixes(project_dir: ~pathlib.Path, check_name: str | None = None, interactive: bool = True, auto: bool = False, console: ~rich.console.Console | None = None) -> None :module: preen.commands.fix
Apply fixes for specific check or all checks.
:param project_dir: Path to project directory :param check_name: Specific check to fix, or None for all :param interactive: Ask before applying each fix :param auto: Apply all fixes automatically :param console: Rich console for output
Release Command¶
.. py:module:: preen.commands.release
Release command implementing devtools::release() pattern.
.. py:function:: release_to_pypi(project_dir: ~pathlib.Path, target: str = ‘pypi’, skip_checks: bool = False, dry_run: bool = False, console: ~rich.console.Console | None = None) -> None :module: preen.commands.release
Interactive release workflow similar to devtools::release().
:param project_dir: Path to project directory :param target: Release target (pypi, github, both) :param skip_checks: Skip running checks (if you just ran them) :param dry_run: Show what would happen without doing it :param console: Rich console for output
Checks¶
Base Check Classes¶
.. py:module:: preen.checks.base
Base classes for the check framework.
.. py:class:: Check(project_dir: ~pathlib.Path) :module: preen.checks.base
Bases: :py:class:~abc.ABC
Abstract base class for all checks.
.. py:method:: Check.can_fix() -> bool :module: preen.checks.base
Return True if this check can automatically fix issues.
.. py:property:: Check.description :module: preen.checks.base :type: str
Return a description of what this check does.
.. py:property:: Check.name :module: preen.checks.base :abstractmethod: :type: str
Return the name of this check.
.. py:method:: Check.run() -> ~preen.checks.base.CheckResult :module: preen.checks.base :abstractmethod:
Run the check and return the result.
:returns: CheckResult containing any issues found.
.. py:class:: CheckResult(check: str, passed: bool, issues: list[~preen.checks.base.Issue] =
Bases: :py:class:object
Result of running a check.
.. py:attribute:: CheckResult.check :module: preen.checks.base :type: str
.. py:attribute:: CheckResult.duration :module: preen.checks.base :type: float :value: 0.0
.. py:method:: CheckResult.get_issues_by_impact(impact: ~preen.checks.base.Impact) -> list[~preen.checks.base.Issue] :module: preen.checks.base
Get all issues with a specific impact level.
.. py:property:: CheckResult.has_blocking_issues :module: preen.checks.base :type: bool
Return True if any issues are blocking (critical impact).
.. py:property:: CheckResult.has_errors :module: preen.checks.base :type: bool
Return True if any issues are errors.
.. py:property:: CheckResult.has_overridable_issues :module: preen.checks.base :type: bool
Return True if any issues can be overridden.
.. py:property:: CheckResult.has_warnings :module: preen.checks.base :type: bool
Return True if any issues are warnings.
.. py:attribute:: CheckResult.issues :module: preen.checks.base :type: list[~preen.checks.base.Issue]
.. py:attribute:: CheckResult.passed :module: preen.checks.base :type: bool
.. py:class:: Fix(description: str, diff: str, apply: ~typing.Callable[[], None]) :module: preen.checks.base
Bases: :py:class:object
Represents a proposed fix for an issue.
.. py:attribute:: Fix.apply :module: preen.checks.base :type: ~typing.Callable[[], None]
.. py:attribute:: Fix.description :module: preen.checks.base :type: str
.. py:attribute:: Fix.diff :module: preen.checks.base :type: str
.. py:method:: Fix.preview() -> str :module: preen.checks.base
Return a preview of the fix as a diff.
.. py:class:: Impact(*values) :module: preen.checks.base
Bases: :py:class:~enum.Enum
Impact classification for release workflow decision making.
.. py:attribute:: Impact.CRITICAL :module: preen.checks.base :value: ‘critical’
.. py:attribute:: Impact.IMPORTANT :module: preen.checks.base :value: ‘important’
.. py:attribute:: Impact.INFORMATIONAL :module: preen.checks.base :value: ‘info’
.. py:class:: Issue(check: str, severity: ~preen.checks.base.Severity, description: str, file: ~pathlib.Path | None = None, line: int | None = None, proposed_fix: ~preen.checks.base.Fix | None = None, impact: ~preen.checks.base.Impact = Impact.IMPORTANT, explanation: str = ‘’, override_question: str = ‘’) :module: preen.checks.base
Bases: :py:class:object
Represents an issue found by a check.
.. py:method:: Issue.can_override() -> bool :module: preen.checks.base
Return True if this issue can be overridden in interactive mode.
.. py:attribute:: Issue.check :module: preen.checks.base :type: str
.. py:attribute:: Issue.description :module: preen.checks.base :type: str
.. py:attribute:: Issue.explanation :module: preen.checks.base :type: str :value: ‘’
.. py:attribute:: Issue.file :module: preen.checks.base :type: ~pathlib.Path | None :value: None
.. py:method:: Issue.get_impact_symbol() -> str :module: preen.checks.base
Get emoji symbol for impact level.
.. py:attribute:: Issue.impact :module: preen.checks.base :type: ~preen.checks.base.Impact :value: ‘important’
.. py:method:: Issue.is_blocking() -> bool :module: preen.checks.base
Return True if this issue should block release by default.
.. py:attribute:: Issue.line :module: preen.checks.base :type: int | None :value: None
.. py:attribute:: Issue.override_question :module: preen.checks.base :type: str :value: ‘’
.. py:attribute:: Issue.proposed_fix :module: preen.checks.base :type: ~preen.checks.base.Fix | None :value: None
.. py:attribute:: Issue.severity :module: preen.checks.base :type: ~preen.checks.base.Severity
.. py:class:: Severity(*values) :module: preen.checks.base
Bases: :py:class:~enum.Enum
Severity levels for issues.
.. py:attribute:: Severity.ERROR :module: preen.checks.base :value: ‘error’
.. py:attribute:: Severity.INFO :module: preen.checks.base :value: ‘info’
.. py:attribute:: Severity.WARNING :module: preen.checks.base :value: ‘warning’
Check Runner¶
.. py:module:: preen.checks.runner
Check runner implementation.
.. py:function:: run_checks(project_dir: ~pathlib.Path, check_classes: list[~typing.Type[~preen.checks.base.Check]], skip: list[str] | None = None, only: list[str] | None = None) -> dict[str, ~preen.checks.base.CheckResult] :module: preen.checks.runner
Run multiple checks and return their results.
:param project_dir: Path to the project directory. :param check_classes: List of Check classes to instantiate and run. :param skip: List of check names to skip. :param only: List of check names to run exclusively.
:returns: Dictionary mapping check names to their results.
Structure Check¶
.. py:module:: preen.checks.structure
Project structure validation check.
.. py:class:: StructureCheck(project_dir: ~pathlib.Path) :module: preen.checks.structure
Bases: :py:class:~preen.checks.base.Check
Check project structure follows opinionated best practices.
.. py:method:: StructureCheck.can_fix() -> bool :module: preen.checks.structure
Return True if this check can automatically fix issues.
.. py:property:: StructureCheck.description :module: preen.checks.structure :type: str
Return a description of what this check does.
.. py:property:: StructureCheck.name :module: preen.checks.structure :type: str
Return the name of this check.
.. py:method:: StructureCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.structure
Check project structure.
Ruff Check¶
.. py:module:: preen.checks.ruff
Ruff linting and formatting check.
.. py:class:: RuffCheck(project_dir: ~pathlib.Path) :module: preen.checks.ruff
Bases: :py:class:~preen.checks.base.Check
Check for linting and formatting issues using ruff.
.. py:method:: RuffCheck.can_fix() -> bool :module: preen.checks.ruff
Return True if this check can automatically fix issues.
.. py:property:: RuffCheck.description :module: preen.checks.ruff :type: str
Return a description of what this check does.
.. py:property:: RuffCheck.name :module: preen.checks.ruff :type: str
Return the name of this check.
.. py:method:: RuffCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.ruff
Run ruff check and ruff format.
Dependency Tree Check¶
.. py:module:: preen.checks.deptree
Circular dependency check using a simple Python implementation.
.. py:class:: DeptreeCheck(project_dir: ~pathlib.Path) :module: preen.checks.deptree
Bases: :py:class:~preen.checks.base.Check
Check for circular dependencies in Python code.
.. py:method:: DeptreeCheck.can_fix() -> bool :module: preen.checks.deptree
Return True if this check can automatically fix issues.
.. py:property:: DeptreeCheck.description :module: preen.checks.deptree :type: str
Return a description of what this check does.
.. py:property:: DeptreeCheck.name :module: preen.checks.deptree :type: str
Return the name of this check.
.. py:method:: DeptreeCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.deptree
Run circular dependency detection.
Version Check¶
.. py:module:: preen.checks.version
Version hardcoding detection check.
.. py:class:: VersionCheck(project_dir: ~pathlib.Path) :module: preen.checks.version
Bases: :py:class:~preen.checks.base.Check
Check for hardcoded version strings outside pyproject.toml.
.. py:method:: VersionCheck.can_fix() -> bool :module: preen.checks.version
Return True if this check can automatically fix issues.
.. py:property:: VersionCheck.description :module: preen.checks.version :type: str
Return a description of what this check does.
.. py:property:: VersionCheck.name :module: preen.checks.version :type: str
Return the name of this check.
.. py:method:: VersionCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.version
Check for version hardcoding.
CI Matrix Check¶
.. py:module:: preen.checks.ci_matrix
CI matrix validation check.
.. py:class:: CIMatrixCheck(project_dir: ~pathlib.Path) :module: preen.checks.ci_matrix
Bases: :py:class:~preen.checks.base.Check
Check if CI matrix covers all declared Python versions.
.. py:method:: CIMatrixCheck.can_fix() -> bool :module: preen.checks.ci_matrix
Return True if this check can automatically fix issues.
.. py:property:: CIMatrixCheck.description :module: preen.checks.ci_matrix :type: str
Return a description of what this check does.
.. py:property:: CIMatrixCheck.name :module: preen.checks.ci_matrix :type: str
Return the name of this check.
.. py:method:: CIMatrixCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.ci_matrix
Check CI matrix against declared Python versions.
Dependencies Check¶
.. py:module:: preen.checks.deps
Dependencies check using deptry.
.. py:class:: DepsCheck(project_dir: ~pathlib.Path) :module: preen.checks.deps
Bases: :py:class:~preen.checks.base.Check
Check for unused/missing dependencies using deptry.
.. py:method:: DepsCheck.can_fix() -> bool :module: preen.checks.deps
Return True if this check can automatically fix issues.
.. py:property:: DepsCheck.description :module: preen.checks.deps :type: str
Return a description of what this check does.
.. py:property:: DepsCheck.name :module: preen.checks.deps :type: str
Return the name of this check.
.. py:method:: DepsCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.deps
Run deptry to check dependencies.
Citation Check¶
.. py:module:: preen.checks.citation
Citation file check.
.. py:class:: CitationCheck(project_dir: ~pathlib.Path) :module: preen.checks.citation
Bases: :py:class:~preen.checks.base.Check
Check if CITATION.cff is in sync with pyproject.toml.
.. py:method:: CitationCheck.can_fix() -> bool :module: preen.checks.citation
Return True if this check can automatically fix issues.
.. py:property:: CitationCheck.description :module: preen.checks.citation :type: str
Return a description of what this check does.
.. py:property:: CitationCheck.name :module: preen.checks.citation :type: str
Return the name of this check.
.. py:method:: CitationCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.citation
Check if citation file needs updating.
Tests Check¶
.. py:module:: preen.checks.tests
Test runner check.
.. py:class:: TestsCheck(project_dir: ~pathlib.Path) :module: preen.checks.tests
Bases: :py:class:~preen.checks.base.Check
Run pytest and report results.
.. py:property:: TestsCheck.description :module: preen.checks.tests :type: str
Return a description of what this check does.
.. py:property:: TestsCheck.name :module: preen.checks.tests :type: str
Return the name of this check.
.. py:method:: TestsCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.tests
Run pytest and report results.
Links Check¶
.. py:module:: preen.checks.links
Link validation check.
.. py:class:: LinkCheck(project_dir: ~pathlib.Path) :module: preen.checks.links
Bases: :py:class:~preen.checks.base.Check
Check for broken or dead links in project files.
.. py:attribute:: LinkCheck.DEFAULT_SKIP_PATTERNS :module: preen.checks.links :value: {‘0.0.0.0’, ‘127.0.0.1’, ‘example.com’, ‘example.org’, ‘localhost’, ‘placeholder.com’, ‘test.com’, ‘your-domain.com’}
.. py:attribute:: LinkCheck.SCAN_PATTERNS :module: preen.checks.links :value: {’.cfg’, ‘.ini’, ‘.json’, ‘.md’, ‘.py’, ‘.rst’, ‘.sh’, ‘.toml’, ‘.txt’, ‘.yaml’, ‘*.yml’}
.. py:attribute:: LinkCheck.URL_PATTERN :module: preen.checks.links :value: re.compile(‘https?://(?:[-\w.])+(?:[:\d]+)?(?:/(?:[\w/_.])(?:\?(?:[\w&=%.]))?(?:#(?:[\w.])*)?)?’, re.IGNORECASE)
.. py:method:: LinkCheck.can_fix() -> bool :module: preen.checks.links
Return True if this check can automatically fix issues.
.. py:property:: LinkCheck.description :module: preen.checks.links :type: str
Return a description of what this check does.
.. py:property:: LinkCheck.name :module: preen.checks.links :type: str
Return the name of this check.
.. py:method:: LinkCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.links
Run the link check.
Codespell Check¶
.. py:module:: preen.checks.codespell
Codespell spell checking check.
.. py:class:: CodespellCheck(project_dir: ~pathlib.Path) :module: preen.checks.codespell
Bases: :py:class:~preen.checks.base.Check
Check for spelling errors in documentation and comments using codespell.
.. py:method:: CodespellCheck.can_fix() -> bool :module: preen.checks.codespell
Return True if this check can automatically fix issues.
.. py:property:: CodespellCheck.description :module: preen.checks.codespell :type: str
Return a description of what this check does.
.. py:property:: CodespellCheck.name :module: preen.checks.codespell :type: str
Return the name of this check.
.. py:method:: CodespellCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.codespell
Run codespell check.
Pydoclint Check¶
.. py:module:: preen.checks.pydoclint
Pydoclint documentation linting check.
.. py:class:: PydoclintCheck(project_dir: ~pathlib.Path) :module: preen.checks.pydoclint
Bases: :py:class:~preen.checks.base.Check
Check for docstring quality and completeness using pydoclint.
.. py:method:: PydoclintCheck.can_fix() -> bool :module: preen.checks.pydoclint
Return True if this check can automatically fix issues.
.. py:property:: PydoclintCheck.description :module: preen.checks.pydoclint :type: str
Return a description of what this check does.
.. py:property:: PydoclintCheck.name :module: preen.checks.pydoclint :type: str
Return the name of this check.
.. py:method:: PydoclintCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.pydoclint
Run pydoclint check.
Pyright Check¶
.. py:module:: preen.checks.pyright
Pyright static type checking check.
.. py:class:: PyrightCheck(project_dir: ~pathlib.Path) :module: preen.checks.pyright
Bases: :py:class:~preen.checks.base.Check
Check for type errors and warnings using pyright static type checker.
.. py:method:: PyrightCheck.can_fix() -> bool :module: preen.checks.pyright
Return True if this check can automatically fix issues.
.. py:property:: PyrightCheck.description :module: preen.checks.pyright :type: str
Return a description of what this check does.
.. py:property:: PyrightCheck.name :module: preen.checks.pyright :type: str
Return the name of this check.
.. py:method:: PyrightCheck.run() -> ~preen.checks.base.CheckResult :module: preen.checks.pyright
Run pyright type checking.
Templates¶
Template Manager¶
.. py:module:: preen.templates.manager
Template manager for rendering project files.
.. py:class:: TemplateManager(templates_dir: ~pathlib.Path | None = None) :module: preen.templates.manager
Bases: :py:class:object
Manages templates for project initialization.
.. py:method:: TemplateManager.get_template_path(template_name: str) -> ~pathlib.Path :module: preen.templates.manager
Get path to a template file.
.. py:method:: TemplateManager.list_templates() -> list[str] :module: preen.templates.manager
List available templates.
.. py:method:: TemplateManager.render(template_name: str, context: ~typing.Dict[str, ~typing.Any]) -> str :module: preen.templates.manager
Render a template with the given context.
:param template_name: Name of template file to render.
:param context: Variables to use in template.
:returns: Rendered template content.