### Install dependencies with uv Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Navigate into the project directory and install all project dependencies using uv. ```bash cd cookiecutter-uv uv sync ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/{{cookiecutter.project_name}}/CONTRIBUTING.md After navigating into the project directory, install and activate the development environment using uv. ```bash cd {{cookiecutter.project_name}} uv sync ``` -------------------------------- ### Install uv Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/tutorial.md Installs the 'uv' package manager. This is the first step before generating a new project. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Install pre-commit to automatically run linters and formatters before each commit. ```bash uv run pre-commit install ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/uv.md Run this command to install all project-specific dependencies defined in the configuration. This ensures your environment is up-to-date. ```bash uv sync ``` -------------------------------- ### Install Development Environment and Pre-commit Hooks Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/{{cookiecutter.project_name}}/README.md Install the project's development environment and pre-commit hooks. This command also generates the 'uv.lock' file. ```bash make install ``` -------------------------------- ### Clone the repository Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Clone your forked repository locally to start development. Replace YOUR_NAME with your GitHub username. ```bash cd bool: """Example function with PEP 484 type annotations. Args: param1: The first parameter. param2: The second parameter. Returns: The return value. True for success, False otherwise. """ ``` -------------------------------- ### Generate Project Interactively with uvx Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Use this command to generate a new project interactively by running Cookiecutter against the remote repository. Ensure uv is installed first. ```bash # Requires uv (https://docs.astral.sh/uv/#getting-started) curl -LsSf https://astral.sh/uv/install.sh | sh # Generate a new project interactively uvx cookiecutter https://github.com/osprey-oss/cookiecutter-uv.git # Expected prompt sequence: # author [Florian Maas]: Your Name # email [foo@email.com]: you@example.com # author_github_handle [fpgmaas]: your-handle # project_name [example-project]: my-library # project_slug [my_library]: my_library # project_description [...]: A short description. # layout (flat, src) [flat]: flat # include_github_actions (y, n) [y]: y # publish_to_pypi (y, n) [y]: y # deptry (y, n) [y]: y # docs_tool (mkdocs, zensical, none): mkdocs # codecov (y, n) [y]: y # dockerfile (y, n) [y]: y # devcontainer (y, n) [y]: y # type_checker (mypy, ty) [mypy]: mypy # open_source_license [MIT license]: MIT license # # Result: ./my-library/ directory with complete project scaffold ``` -------------------------------- ### Generate Project with uvx Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/index.md Use this command to generate a new Python project using the cookiecutter-uv template when uv is installed. ```bash uvx cookiecutter https://github.com/osprey-oss/cookiecutter-uv.git ``` -------------------------------- ### Generate Project with pip install cookiecutter Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/index.md Use this command to generate a new Python project using the cookiecutter-uv template if uv is not yet installed. ```bash pip install cookiecutter cookiecutter https://github.com/osprey-oss/cookiecutter-uv.git ``` -------------------------------- ### Makefile Targets for Project Lifecycle Management Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Provides standard Makefile targets for common development tasks like installation, code checking, testing, building, and serving documentation, all delegating to `uv`. ```bash # Install / sync the virtual environment make install # Equivalent to: uv sync # Run all code quality checks make check # Runs in sequence: # uv lock --locked (lock file consistency) # uv run pre-commit run -a (formatting & lint via ruff) # uv run mypy (static type checking) # uv run deptry . (dependency audit, if enabled) # Run the test suite with coverage make test # Equivalent to: # uv run python -m pytest --cov --cov-config=pyproject.toml --cov-report=xml tests # Build a wheel make build # Build and publish to PyPI make build-and-publish # Equivalent to: # uvx --from build pyproject-build --installer uv # uvx twine upload --repository-url https://upload.pypi.org/legacy/ dist/* # Serve documentation locally at http://localhost:8000 make docs # Validate documentation build (no warnings/errors) make docs-test ``` -------------------------------- ### Run Podman Container in Detached Mode Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Starts a Podman container in detached mode, allowing it to run in the background. Use `-d` for detached mode. ```bash podman run -d my-library ``` -------------------------------- ### MyPy Static Type Checking Configuration Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/linting.md Configure MyPy for static type checking. This setup enforces strict type checking by disallowing untyped definitions and any unimported types, and warns about potential issues like returning any type or unused ignores. It also specifies files and directories to exclude from checking. ```toml [tool.mypy] disallow_untyped_defs = true disallow_any_unimported = true no_implicit_optional = true check_untyped_defs = true warn_return_any = true warn_unused_ignores = true show_error_codes = true exclude = [ '\.venv', '{{cookiecutter.project_name}}', 'tests' ] ``` -------------------------------- ### Initialize Project and Push to GitHub Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/tutorial.md Initializes a new Git repository, adds all files, commits them, sets the remote origin, and pushes to GitHub. Replace placeholders with your project and username. ```bash cd git init -b main git add . git commit -m "Init commit" git remote add origin git@github.com:/.git git push -u origin main ``` -------------------------------- ### Build and check documentation Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Update documentation files and check the rendered output. ```bash make docs ``` -------------------------------- ### Initialize Git Repository Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/{{cookiecutter.project_name}}/README.md Initialize a new Git repository with the main branch, add all files, make an initial commit, set the remote origin, and push to the remote. ```bash git init -b main git add . git commit -m "init commit" git remote add origin git@github.com:{{cookiecutter.author_github_handle}}/{{cookiecutter.project_name}}.git git push -u origin main ``` -------------------------------- ### List Makefile Commands Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/makefile.md Run 'make help' to display all available commands in the Makefile. This is useful for understanding the project's build and development workflow. ```bash install Install the uv environment and install the pre-commit hooks check Lint and check code by running ruff, mypy and deptry. test Test the code with pytest build Build wheel file using uv clean-build clean build artifacts publish publish a release to pypi. build-and-publish Build and publish. docs-test Test if documentation can be built without warnings or errors docs Build and serve the documentation ``` -------------------------------- ### uv Commands for Dependency Management Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Demonstrates essential `uv` commands for adding dependencies, syncing the environment, and running commands within the virtual environment, leveraging the `pyproject.toml` configuration. ```bash # Add a runtime dependency uv add requests # Add a development-only dependency uv add --dev pytest-asyncio # Sync the environment (installs all deps from uv.lock) uv sync # Run any command inside the virtual environment uv run python -m pytest uv run mypy uv run pre-commit run -a # Run tox for multi-Python compatibility testing uv run tox # Tests against Python 3.10, 3.11, 3.12, 3.13, 3.14 by default (see tox.ini) ``` -------------------------------- ### Docker/Podman Container Build and Run Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Commands for building a Docker or Podman container image from the project and running it in the background. ```bash # Build the container image docker build . -t my-library # or with Podman: podman build . -t my-library # Run in background docker run -d my-library ``` -------------------------------- ### Build Container Image Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/docker.md Use these commands to build a container image from the Dockerfile. Choose Docker or Podman based on your environment. ```bash docker build . -t my-container-image ``` ```bash podman build . -t my-container-image ``` -------------------------------- ### Bake Project Fixture Usage Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Demonstrates how to use the `bake` fixture to create a new project with various configurations. The `BakedProject` helper provides methods for file inspection and subprocess execution. ```python def test_bake_project(bake): project = bake(project_name="my-project") assert project.path.name == "my-project" assert project.path.is_dir() ``` ```python def test_mkdocs_setup(bake): project = bake(docs_tool="mkdocs") assert project.has_file("mkdocs.yml") # mkdocs config present assert not project.has_file("zensical.toml") # zensical config removed assert project.has_dir("docs") assert project.is_valid_yaml(".github/workflows/on-release-main.yml") assert project.file_contains(".github/workflows/on-release-main.yml", "mkdocs") ``` ```python def test_src_layout(bake): project = bake(layout="src") assert project.has_dir("src") ``` ```python def test_license_mit(bake): project = bake(open_source_license="MIT license") assert project.file_contains("LICENSE", "MIT License") ``` ```python def test_license_none(bake): project = bake(open_source_license="Not open source") assert not project.has_file("LICENSE") ``` ```python def test_pypi_publish_secrets(bake): project = bake(publish_to_pypi="y") assert project.file_contains( ".github/workflows/on-release-main.yml", "PYPI_TOKEN" ) assert project.file_contains("Makefile", "build-and-publish") ``` -------------------------------- ### Local PyPI Publishing Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/publishing.md Run this command to build and publish your project to PyPI from your local machine. This method is not recommended for general use. ```bash make build-and-publish ``` -------------------------------- ### Create Project with Cookiecutter UV Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/README.md Use this command to initiate a new Python project using the cookiecutter-uv template. Follow the prompts to configure your project settings. ```bash uvx cookiecutter https://github.com/osprey-oss/cookiecutter-uv.git ``` ```bash pip install cookiecutter cookiecutter https://github.com/osprey-oss/cookiecutter-uv.git ``` -------------------------------- ### Run Pre-commit Hooks for Formatting Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/{{cookiecutter.project_name}}/README.md Execute all pre-commit hooks to automatically format the code and resolve any formatting issues that might cause CI/CD pipeline failures. ```bash uv run pre-commit run -a ``` -------------------------------- ### Run Tests with Make Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/pytest.md Use the `make test` command to execute the project's unit tests. Pytest is automatically configured and available in the environment. ```bash make test ``` -------------------------------- ### Run formatting checks Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Check that your changes adhere to the project's formatting standards. ```bash make check ``` -------------------------------- ### Commit and push changes Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Add, commit, and push your changes to your forked repository. ```bash git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature ``` -------------------------------- ### Importing Project Module with Project Slug Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/prompt_arguments.md Demonstrates how the project slug is used to import the main module of the project. This slug is derived from the project name. ```python from import foo ``` -------------------------------- ### Add Package with uv Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/uv.md Use this command to add a new package to your project's dependencies. uv will update the configuration. ```bash uv add ``` -------------------------------- ### Run Podman Container Interactively Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Executes a Podman container with the specified image and overrides the entrypoint to bash for interactive use. Use `--rm` to automatically remove the container when it exits. ```bash podman run --rm -it --entrypoint bash my-library ``` -------------------------------- ### Commit Formatting Changes Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/{{cookiecutter.project_name}}/README.md Add the changes made by the pre-commit hooks, commit them with a descriptive message, and push the changes to the main branch. ```bash git add . git commit -m 'Fix formatting issues' git push origin main ``` -------------------------------- ### Create a new branch Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Create a new branch for your bugfix or feature development. ```bash git checkout -b name-of-your-bugfix-or-feature ``` -------------------------------- ### Run Docker Container Interactively Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Executes a Docker container with the specified image and overrides the entrypoint to bash for interactive use. Use `--rm` to automatically remove the container when it exits. ```bash docker run --rm -it --entrypoint bash my-library ``` -------------------------------- ### Run Tox Locally with uv Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/tox.md Execute Tox tests locally using uv to manage dependencies. This command ensures that the testing environment is set up correctly before running the tests. ```sh uv run tox ``` -------------------------------- ### Run Container in Interactive Mode Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/docker.md Launch the container with an interactive bash shell. This is helpful for debugging or exploring the container's environment. ```bash docker run --rm -it --entrypoint bash my-container-image ``` ```bash podman run --rm -it --entrypoint bash my-container-image ``` -------------------------------- ### Version Fetcher API Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Provides low-level helper functions to fetch the latest version strings from PyPI and GitHub. These functions are used internally by the updaters but can be imported and used directly. ```APIDOC ## Version Fetcher API (`cookiecutter_uv.cicd.fetchers`) ### `get_pypi_version`, `get_github_release`, `get_github_tag` Low-level helpers that fetch the latest version string from PyPI or GitHub. Used internally by the updaters but importable directly. ```python from cookiecutter_uv.cicd.fetchers import ( GitHubRepo, get_pypi_version, get_github_release, get_github_tag, ) # Fetch latest version of a PyPI package version = get_pypi_version("ruff") print(version) # e.g. "0.15.7" version = get_pypi_version("nonexistent-pkg-xyz") print(version) # None (never raises; returns None on any error) # Fetch latest GitHub release tag (strips leading "v") uv_repo = GitHubRepo(owner="astral-sh", repo="uv") release = get_github_release(uv_repo) print(release) # e.g. "0.7.8" print(str(uv_repo)) # "astral-sh/uv" # Fetch latest tag (for repos that don't use GitHub Releases) hooks_repo = GitHubRepo(owner="pre-commit", repo="pre-commit-hooks") tag = get_github_tag(hooks_repo) print(tag) # e.g. "5.0.0" ``` ``` -------------------------------- ### Apply Dependency Updates Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Applies dependency updates by rewriting version pins in specified files. Supports multiple file paths for `--pyproject`, `--action-yml`, and `--precommit-config` flags. ```bash cookiecutter-uv-cicd update-dependencies \ --pyproject pyproject.toml \ --pyproject "{{cookiecutter.project_name}}/pyproject.toml" \ --action-yml .github/actions/setup-python-env/action.yml \ --action-yml "{{cookiecutter.project_name}}/.github/actions/setup-python-env/action.yml" \ --precommit-config .pre-commit-config.yaml \ --precommit-config "{{cookiecutter.project_name}}/.pre-commit-config.yaml" ``` -------------------------------- ### GitHub Actions CI/CD Workflows Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Overview of the three generated GitHub Actions workflows for continuous integration and deployment, triggered by pushes, releases, and pull requests. ```yaml # .github/workflows/main.yml — triggers on push to main # .github/workflows/on-release-main.yml — triggers on new GitHub Release tag (e.g. 1.2.3) # .github/workflows/validate-codecov-config.yml — validates codecov.yaml on PRs # on-release-main.yml performs: # 1. Run checks (ruff, mypy/ty, deptry) # 2. Run tests with coverage (uploaded to codecov if enabled) # 3. Publish to PyPI (if publish_to_pypi = "y") using PYPI_TOKEN secret # 4. Build and deploy documentation to GitHub Pages (if docs_tool != "none") # Required GitHub repository secrets: # PYPI_TOKEN — API token from https://pypi.org/manage/account/ # # To trigger a release: # GitHub UI -> Releases -> Draft a new release -> tag: 1.0.0 -> Publish release ``` -------------------------------- ### Generate Project Non-interactively Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Use this command for CI or testing to apply all cookiecutter.json defaults without interactive prompts. You can specify options like layout. ```bash # Flat layout (default) uv run cookiecutter --no-input . --overwrite-if-exists # Force src layout uv run cookiecutter --no-input . --overwrite-if-exists layout="src" ``` -------------------------------- ### Run tox for cross-version testing Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/CONTRIBUTING.md Run tox to execute tests across different Python versions. This step is also part of the CI/CD pipeline. ```bash tox ``` -------------------------------- ### Run Command in uv Environment Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/uv.md Execute commands within the context of your uv-managed virtual environment. This is useful for running development tools like pytest. ```bash uv run python -m pytest ``` -------------------------------- ### Fetch Latest PyPI Package Version Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Retrieves the latest version string for a given PyPI package. Returns `None` if the package does not exist or an error occurs, without raising exceptions. ```python from cookiecutter_uv.cicd.fetchers import ( GitHubRepo, get_pypi_version, get_github_release, get_github_tag, ) # Fetch latest version of a PyPI package version = get_pypi_version("ruff") print(version) # e.g. "0.15.7" version = get_pypi_version("nonexistent-pkg-xyz") print(version) # None (never raises; returns None on any error) ``` -------------------------------- ### Dry Run Dependency Updates Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Performs a dry run of the `update-dependencies` command to preview changes without modifying files. Specify target files using `--pyproject`, `--action-yml`, and `--precommit-config` flags. ```bash cookiecutter-uv-cicd update-dependencies \ --dry-run \ --pyproject pyproject.toml \ --action-yml .github/actions/setup-python-env/action.yml \ --precommit-config .pre-commit-config.yaml ``` -------------------------------- ### Run Container in Background Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/docker.md Execute the built container image in detached mode. This is useful for running services. ```bash docker run -d my-container-image ``` ```bash podman run -d my-container-image ``` -------------------------------- ### Ruff Linting and Formatting Configuration Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/linting.md Configure Ruff for linting and code formatting. This includes setting the target Python version, line length, enabling automatic fixes, and selecting specific linting rules. It also specifies files to ignore for certain rules. ```toml [tool.ruff] target-version = "py310" line-length = 120 fix = true select = [ # flake8-2020 "YTT", # flake8-bandit "S", # flake8-bugbear "B", # flake8-builtins "A", # flake8-comprehensions "C4", # flake8-debugger "T10", # flake8-simplify "SIM", # isort "I", # mccabe "C90", # pycodestyle "E", "W", # pyflakes "F", # pygrep-hooks "PGH", # pyupgrade "UP", # ruff "RUF", # tryceratops "TRY", ] ignore = [ # LineTooLong "E501", # DoNotAssignLambda "E731", ] [tool.ruff.format] preview = true [tool.ruff.per-file-ignores] "tests/*" = ["S101"] ``` -------------------------------- ### Validate Project Name and Slug in Pre-generation Hook Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Ensures the project name and slug adhere to specific naming conventions before project generation. Exits with an error if validation fails. ```python import re, sys PROJECT_NAME_REGEX = r"^[-a-zA-Z][-a-zA-Z0-9]+$" project_name = "{{cookiecutter.project_name}}" # resolved at runtime if not re.match(PROJECT_NAME_REGEX, project_name): print(f"ERROR: '{project_name}' is not valid. Use - not _") sys.exit(1) # cancels generation PROJECT_SLUG_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]+$" project_slug = "{{cookiecutter.project_slug}}" if not re.match(PROJECT_SLUG_REGEX, project_slug): print(f"ERROR: '{project_slug}' is not valid. Use _ not -") sys.exit(1) ``` -------------------------------- ### cookiecutter-uv-cicd CLI - update-dependencies Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt The `update-dependencies` command from the `cookiecutter-uv-cicd` CLI is used to keep the template's pinned versions current. It can perform a dry run to show changes or apply updates directly to specified files. ```APIDOC ## `cookiecutter-uv-cicd` CLI — Automated Dependency Updates ### `update-dependencies` command The `cookiecutter-uv-cicd` CLI is installed as a package entry point and is used to keep the template's own pinned versions current. It fetches the latest versions from PyPI (for Python packages) and GitHub Releases/Tags (for tools like uv and pre-commit hooks), then rewrites the relevant files in place. ```bash # Install the package pip install cookiecutter-uv # or: uv add cookiecutter-uv # Dry run — print what would change without writing files cookiecutter-uv-cicd update-dependencies \ --dry-run \ --pyproject pyproject.toml \ --action-yml .github/actions/setup-python-env/action.yml \ --precommit-config .pre-commit-config.yaml # Example dry-run output: # pyproject.toml: ruff -> 0.15.7 # pyproject.toml: mypy -> 1.19.1 # .github/actions/setup-python-env/action.yml: uv -> 0.7.8 # .pre-commit-config.yaml: ruff-precommit -> v0.15.7 # Dry run complete. 4 update(s) would be applied. # Apply updates for real (multiple --pyproject and --action-yml flags supported) cookiecutter-uv-cicd update-dependencies \ --pyproject pyproject.toml \ --pyproject "{{cookiecutter.project_name}}/pyproject.toml" \ --action-yml .github/actions/setup-python-env/action.yml \ --action-yml "{{cookiecutter.project_name}}/.github/actions/setup-python-env/action.yml" \ --precommit-config .pre-commit-config.yaml \ --precommit-config "{{cookiecutter.project_name}}/.pre-commit-config.yaml" # Output: # pyproject.toml: pytest -> 9.0.2 # Done. 3 update(s) applied. ``` ``` -------------------------------- ### Pre-generation Hook for Name Validation Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt This Python script validates the project name and slug before scaffolding begins. It exits with code 1 on failure, canceling the generation. ```python import re import sys project_name = "{{ cookiecutter.project_name }}" project_slug = "{{ cookiecutter.project_slug }}" # Validate project_name: must start with a letter, then letters, numbers, or hyphens if not re.match(r'^[-a-zA-Z][-a-zA-Z0-9]+$', project_name): print(f"ERROR: project_name '{project_name}' is invalid.") sys.exit(1) # Validate project_slug: must start with a letter or underscore, then letters, numbers, or underscores if not re.match(r'^[_a-zA-Z][_a-zA-Z0-9]+$', project_slug): print(f"ERROR: project_slug '{project_slug}' is invalid.") sys.exit(1) ``` -------------------------------- ### Cookiecutter Template Configuration Schema Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt This JSON defines the configuration for the Cookiecutter template, mapping keys to interactive prompts and their default values or choices. ```json { "author": "Florian Maas", "email": "foo@email.com", "author_github_handle": "fpgmaas", "project_name": "example-project", "project_slug": "{{cookiecutter.project_name|lower|replace('-', '_')}}", "project_description": "This is a template repository ...", "layout": ["flat", "src"], "include_github_actions": ["y", "n"], "publish_to_pypi": ["y", "n"], "deptry": ["y", "n"], "docs_tool": ["mkdocs", "zensical", "none"], "codecov": ["y", "n"], "dockerfile": ["y", "n"], "devcontainer": ["y", "n"], "type_checker": ["mypy", "ty"], "open_source_license": [ "MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source" ] } ``` -------------------------------- ### File Updater Classes Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Classes designed to update version pins in specific file formats like `pyproject.toml`, `action.yml`, and `.pre-commit-config.yaml`. They locate version pins using regex and rewrite them in place, returning the count of updates applied. ```APIDOC ## File Updater Classes (`cookiecutter_uv.cicd.updaters`) ### `PyprojectTomlUpdater`, `ActionYmlUpdater`, `PreCommitConfigUpdater` Each updater targets a specific file format, locates version pins with regex, and rewrites them in place. All return an integer count of updates applied. ```python from pathlib import Path from cookiecutter_uv.cicd.updaters import ( PyprojectTomlUpdater, ActionYmlUpdater, PreCommitConfigUpdater, ) # --- PyprojectTomlUpdater --- # Updates `"package>=X.Y.Z"` pins for all packages listed in config.PYPI_PACKAGES. updater = PyprojectTomlUpdater(files=[ Path("pyproject.toml"), Path("{{cookiecutter.project_name}}/pyproject.toml"), ]) count = updater.update(dry_run=False) print(f"{count} pyproject.toml update(s) applied") # Dry-run mode: logs changes to stdout without writing count = updater.update(dry_run=True) # Logs: "pyproject.toml: ruff -> 0.15.7" # Returns count of matched entries without modifying files # --- ActionYmlUpdater --- # Updates the `default: "X.Y.Z"` field inside uv-version input of action.yml files. action_updater = ActionYmlUpdater(files=[ Path(".github/actions/setup-python-env/action.yml"), ]) count = action_updater.update(dry_run=False) print(f"{count} action.yml update(s) applied") # --- PreCommitConfigUpdater --- # Updates `rev:` pins for hooks defined in config.PRECOMMIT_HOOKS. # Fetches latest tags from GitHub for each configured hook repo. precommit_updater = PreCommitConfigUpdater( config_file=Path(".pre-commit-config.yaml") ) count = precommit_updater.update(dry_run=False) print(f"{count} pre-commit hook(s) updated") # If the config file does not exist, returns 0 silently (no exception) missing_updater = PreCommitConfigUpdater(config_file=Path("nonexistent.yaml")) print(missing_updater.update()) # 0 ``` ``` -------------------------------- ### Ty Type Checker Environment Configuration Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/linting.md Configure the environment for the Ty type checker. This specifies the Python interpreter to use and its version. ```toml [tool.ty.environment] python = "./.venv" python-version = "3.10" ``` -------------------------------- ### Fetch Latest GitHub Release Tag Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Fetches the latest release tag from a GitHub repository. The `GitHubRepo` object specifies the owner and repository name. The tag is returned as a string, with a leading 'v' stripped if present. ```python # Fetch latest GitHub release tag (strips leading "v") uv_repo = GitHubRepo(owner="astral-sh", repo="uv") release = get_github_release(uv_repo) print(release) # e.g. "0.7.8" print(str(uv_repo)) # "astral-sh/uv" ``` -------------------------------- ### Codecov Configuration Defaults Source: https://github.com/osprey-oss/cookiecutter-uv/blob/main/docs/features/codecov.md This YAML configuration defines default settings for Codecov, including coverage ranges, status targets, and paths to ignore. It is used when Codecov is enabled in the project. ```yaml coverage: range: 70..100 round: down precision: 1 status: project: default: target: auto threshold: 1% # Ignoring Paths # -------------- # which folders/files to ignore ignore: - "foo/bar.py" ``` -------------------------------- ### Update Pyproject.toml Versions Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Updates version pins in `pyproject.toml` files for packages listed in `config.PYPI_PACKAGES`. Supports multiple files and dry-run mode. Returns the count of updates applied. ```python from pathlib import Path from cookiecutter_uv.cicd.updaters import ( PyprojectTomlUpdater, ActionYmlUpdater, PreCommitConfigUpdater, ) # --- PyprojectTomlUpdater --- # Updates "package>=X.Y.Z" pins for all packages listed in config.PYPI_PACKAGES. updater = PyprojectTomlUpdater(files=[ Path("pyproject.toml"), Path("{{cookiecutter.project_name}}/pyproject.toml"), ]) count = updater.update(dry_run=False) print(f"{count} pyproject.toml update(s) applied") # Dry-run mode: logs changes to stdout without writing count = updater.update(dry_run=True) # Logs: "pyproject.toml: ruff -> 0.15.7" # Returns count of matched entries without modifying files ``` -------------------------------- ### Conditional File Cleanup in Post-generation Hook Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Removes or renames files and directories after project scaffolding based on user selections for GitHub Actions, documentation tools, project layout, and open-source licenses. ```python # hooks/post_gen_project.py — runs automatically after scaffolding # Key conditional logic (simplified): # Remove .github/ entirely if CI/CD was declined if "{{cookiecutter.include_github_actions}}" != "y": remove_dir(".github") # Pick exactly one docs tool; remove the other config file if "{{cookiecutter.docs_tool}}" == "mkdocs": remove_file("zensical.toml") # keep mkdocs.yml elif "{{cookiecutter.docs_tool}}" == "zensical": remove_file("mkdocs.yml") # keep zensical.toml else: # "none" remove_dir("docs") remove_file("mkdocs.yml") remove_file("zensical.toml") # Move source to src/ layout if requested if "{{cookiecutter.layout}}" == "src": move_dir("{{cookiecutter.project_slug}}", os.path.join("src", "{{cookiecutter.project_slug}}")) # Select correct license file; remove all others if "{{cookiecutter.open_source_license}}" == "MIT license": move_file("LICENSE_MIT", "LICENSE") # LICENSE_BSD, LICENSE_ISC, LICENSE_APACHE, LICENSE_GPL are removed ``` -------------------------------- ### Update Action.yml UV Version Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Updates the `default: "X.Y.Z"` field within the `uv-version` input of `action.yml` files. Returns the count of updates applied. ```python # --- ActionYmlUpdater --- # Updates the `default: "X.Y.Z"` field inside uv-version input of action.yml files. action_updater = ActionYmlUpdater(files=[ Path(".github/actions/setup-python-env/action.yml"), ]) count = action_updater.update(dry_run=False) print(f"{count} action.yml update(s) applied") ``` -------------------------------- ### Fetch Latest GitHub Tag Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Retrieves the latest tag from a GitHub repository, useful for repositories that do not use GitHub Releases. The `GitHubRepo` object is used to specify the repository. ```python # Fetch latest tag (for repos that don't use GitHub Releases) hooks_repo = GitHubRepo(owner="pre-commit", repo="pre-commit-hooks") tag = get_github_tag(hooks_repo) print(tag) # e.g. "5.0.0" ``` -------------------------------- ### Update Pre-commit Hook Versions Source: https://context7.com/osprey-oss/cookiecutter-uv/llms.txt Updates `rev:` pins for hooks defined in `.pre-commit-config.yaml`. It fetches the latest tags from GitHub for each configured hook repository. Returns the count of updates applied. ```python # --- PreCommitConfigUpdater --- # Updates `rev:` pins for hooks defined in config.PRECOMMIT_HOOKS. # Fetches latest tags from GitHub for each configured hook repo. precommit_updater = PreCommitConfigUpdater( config_file=Path(".pre-commit-config.yaml") ) count = precommit_updater.update(dry_run=False) print(f"{count} pre-commit hook(s) updated") # If the config file does not exist, returns 0 silently (no exception) missing_updater = PreCommitConfigUpdater(config_file=Path("nonexistent.yaml")) print(missing_updater.update()) # 0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.