Skip to content

Transition to UV#90

Open
ajwalkiewicz wants to merge 3 commits into
mainfrom
refactor/transition-to-uv
Open

Transition to UV#90
ajwalkiewicz wants to merge 3 commits into
mainfrom
refactor/transition-to-uv

Conversation

@ajwalkiewicz

@ajwalkiewicz ajwalkiewicz commented Nov 4, 2025

Copy link
Copy Markdown
Owner

Use UV as a new project management tool

Summary by Sourcery

Transition the project to use UV for build, test, and release management and migrate packaging to PEP 621 via pyproject.toml while updating CI pipelines accordingly.

Enhancements:

  • Introduce UV-based Makefile tasks for setup, build, test, formatting, type checking, and documentation
  • Migrate packaging and project metadata to pyproject.toml with uv_build backend
  • Add pytest.ini for test discovery and marker configuration

Build:

  • Add GitHub Actions workflow to publish Python package releases to PyPI using UV
  • Add GitHub Actions workflows for running tests, linting with Ruff, and type checks with mypy

CI:

  • Separate CI workflows for test, format check, and type check on main branch and pull requests

Chores:

  • Remove legacy packaging files, Docker configuration, and outdated CI workflows

@sourcery-ai

sourcery-ai Bot commented Nov 4, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR fully transitions the project to the UV build and project management tool, replacing existing workflows and build scripts with UV-based implementations and updating project metadata accordingly.

Entity relationship diagram for pyproject.toml dependency groups

erDiagram
  PROJECT ||--o{ DEPENDENCY_GROUP : has
  DEPENDENCY_GROUP {
    string name
    string[] dependencies
  }
  PROJECT {
    string name
    string version
    string description
    string[] keywords
    string[] classifiers
  }
  PROJECT ||--o{ SCRIPT : defines
  SCRIPT {
    string name
    string entrypoint
  }
Loading

Class diagram for Makefile targets using UV

classDiagram
  class Makefile {
    +setup()
    +check-uv()
    +build()
    +test()
    +test_all()
    +clean()
    +clean_venv()
    +clean_build()
    +clean_cache()
    +format()
    +check()
    +type()
    +docs()
  }
  class UV {
    +sync()
    +build()
    +run()
  }
  Makefile --> UV : uses
  class ruff {
    +format()
    +check()
  }
  Makefile --> ruff : uses
  class mypy {
    +type_check()
  }
  Makefile --> mypy : uses
  class pytest {
    +run_tests()
  }
  Makefile --> pytest : uses
  class sphinx_build {
    +build_docs()
  }
  Makefile --> sphinx_build : uses
Loading

File-Level Changes

Change Details Files
Integrate UV into CI workflows
  • Add GitHub Action for release uploads using UV artifacts
  • Introduce test, format, and type-check workflows invoking make targets
  • Remove legacy workflow files (black.yml, python-package.yml)
.github/workflows/release.yml
.github/workflows/tests.yml
.github/workflows/check_format.yml
.github/workflows/check_types.yml
.github/workflows/black.yml
.github/workflows/python-package.yml
Revise Makefile to drive tasks via UV
  • Implement check-uv target to install UV if missing
  • Update setup, build, test, format, check, type, docs targets to use uv commands
  • Add clean, clean_build, and clean_cache routines
Makefile
Switch project build backend to UV
  • Set build-backend to uv_build and add uv.lock to lockfile
  • Update project metadata, dependencies, and dev groups in pyproject.toml
pyproject.toml
Add UV lockfile
  • Commit generated uv.lock to track UV dependency tree
uv.lock
Configure pytest settings
  • Define testpaths, pythonpath, and slow marker in pytest.ini
pytest.ini

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

Blocking issues:

  • An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload. (link)

General comments:

  • In the pypi-publish job you need to pass your PyPI token (e.g. pypi_token: ${{ secrets.PYPI_API_TOKEN }}) to the pypa/gh-action-pypi-publish step for authentication.
  • Your make setup target currently just runs uv sync—you should include the dev dependency group (e.g. uv sync -g dev) so that tests, linting, and type checks install correctly in CI.
  • Installing UV via a curl script on every build can lead to version drift; consider pinning the installer version or adding UV as a locked dependency in your project to ensure reproducible builds.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the pypi-publish job you need to pass your PyPI token (e.g. `pypi_token: ${{ secrets.PYPI_API_TOKEN }}`) to the pypa/gh-action-pypi-publish step for authentication.
- Your `make setup` target currently just runs `uv sync`—you should include the dev dependency group (e.g. `uv sync -g dev`) so that tests, linting, and type checks install correctly in CI.
- Installing UV via a curl script on every build can lead to version drift; consider pinning the installer version or adding UV as a locked dependency in your project to ensure reproducible builds.

## Individual Comments

### Comment 1
<location> `.github/workflows/release.yml:73` </location>
<code_context>
        uses: pypa/gh-action-pypi-publish@release/v1
</code_context>

<issue_to_address>
**security (yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha):** An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA helps mitigate the risk of a bad actor adding a backdoor to the action's repository, as they would need to generate a SHA-1 collision for a valid Git object payload.

*Source: opengrep*
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/release.yml
@ajwalkiewicz ajwalkiewicz linked an issue Nov 4, 2025 that may be closed by this pull request
* Update Move from Sphinx to Mkdocs

* Update Move from Sphinx to Mkdocs

* Update Move from Sphinx to Mkdocs

* Update Move from Sphinx to Mkdocs

* Update Move from Sphinx to Mkdocs

* Update Move from Sphinx to Mkdocs

* Update Move from Sphinx to Mkdocs

* Update documentation
Copilot AI review requested due to automatic review settings November 9, 2025 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the cochar package by migrating from setup.py to a modern pyproject.toml build system with uv as the package manager. The changes include significant refactoring of the codebase to use modern Python type hints, reorganization of imports, and improvements to code structure.

Key Changes

  • Migration to modern Python packaging with uv.lock and pyproject.toml
  • Modernization of type hints (Dict→dict, List→list, Union→|)
  • Reorganization of code structure with better separation of concerns (config.py)
  • Updated docstring format from Sphinx-style to Google-style
  • Removed deprecated files (setup.py, requirements.txt, upload.sh)

Reviewed Changes

Copilot reviewed 68 out of 86 changed files in this pull request and generated no comments.

Show a summary per file
File Description
uv.lock New lock file with dependency versions - contains some suspicious future-dated versions
upload.sh Removed legacy upload script
setup.py Removed in favor of pyproject.toml
requirements.txt Removed in favor of uv.lock
tests/*.py Updated imports to use new module structure (cochar.config, cochar.cochar)
src/cochar/init.py Simplified to export only public API
src/cochar/config.py Refactored configuration with modern type hints
src/cochar/main.py Fixed typo in function name (pars_arguments→parse_arguments)
src/cochar/*.py Updated type hints and docstring formats across all source files
docs/* Documentation structure updates
Comments suppressed due to low confidence (1)

src/cochar/main.py:24

  • Function renamed from pars_arguments to parse_arguments, but there's a typo in the old name. The new name is correct ('parse' not 'pars').

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move to UV as project management tool

2 participants