Skip to content

Conversation

seanbudd
Copy link
Member

@seanbudd seanbudd commented Sep 8, 2025

This pull request introduces a major overhaul of the project's Python environment management, CI configuration, and developer tooling. The changes replace the legacy tox and flake8 setup with modern tools such as uv, ruff, and pyright, streamline Windows batch/PowerShell scripts, and update CI workflows to use the latest GitHub Actions versions. The new configuration files (pyproject.toml, .pre-commit-config.yml, .python-version) standardize dependencies and development practices, while redundant or outdated files are removed.

Environment and Dependency Management:

  • Added pyproject.toml to define dependencies, build system, linting, and testing tools, replacing legacy requirements and configuration files. Introduced uv for dependency management and updated Python version requirements to 3.13.
  • Added .python-version to specify the required Python interpreter for consistency across development environments.

Continuous Integration and Pre-commit:

  • Added .pre-commit-config.yml to configure automated linting, formatting, and type checking with ruff, pyright, and other hooks. This replaces manual linting steps and integrates with pre-commit CI.
  • Updated .github/workflows/testCode.yaml to use the latest GitHub Actions versions, switch from PowerShell to batch scripts for test/lint/validation steps, and utilize uv for environment setup.

Script Modernization:

  • Replaced PowerShell scripts (*.ps1) for linting, testing, and validation with batch scripts (*.bat) that invoke Python tools via uv, improving Windows compatibility and simplifying execution. [1] [2] [3] [4] [5] [6]
  • Added a robust ensureuv.ps1 script to ensure the correct version of uv is installed or updated, with user-friendly prompts for installation via WinGet or the official script.

Cleanup and Removal:

  • Removed legacy configuration and utility files, including tox.ini, PowerShell scripts for old virtualenv management, and outdated lint/test scripts. [1] [2] [3] [4] [5] [6] [7]

These changes modernize the project's development workflow, improve CI reliability, and ensure consistent environments for contributors.

References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]

@seanbudd seanbudd marked this pull request as draft September 8, 2025 23:04
@seanbudd seanbudd marked this pull request as ready for review September 17, 2025 02:50
@seanbudd seanbudd requested a review from Copilot September 17, 2025 02:51
Copy link

@Copilot Copilot AI left a comment

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 Python development environment by replacing the legacy tox/flake8 toolchain with UV, Ruff, and Pyright. The changes migrate from PowerShell scripts to batch scripts for Windows compatibility, introduce modern CI configuration with pre-commit hooks, and eliminate legacy virtual environment management in favor of UV's integrated dependency handling.

  • Replaces tox/flake8 with UV package management and Ruff linting/formatting
  • Migrates PowerShell scripts to batch scripts for improved Windows compatibility
  • Modernizes CI workflows with latest GitHub Actions and streamlined tooling

Reviewed Changes

Copilot reviewed 31 out of 34 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pyproject.toml Comprehensive project configuration with UV, Ruff, and Pyright settings
ensureuv.ps1 Robust UV installation script with WinGet and official script fallback
*.bat files Batch script replacements for PowerShell scripts using UV commands
.pre-commit-config.yml Pre-commit hooks for automated linting, formatting, and type checking
.github/workflows/testCode.yaml Updated CI workflow using UV and batch scripts
_validate/*.py Type annotation updates and import refactoring for modern Python

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +11 to +15
if "%1" NEQ "" set ruffFormatArgs=--diff > %1/lint-diff.diff
call uv run --group lint --directory "%here%" ruff check --fix %ruffCheckArgs%
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
call uv run --group lint --directory "%here%" ruff format %ruffFormatArgs%
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
Copy link
Preview

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

Line 11 has incorrect syntax. The redirection operator > should not be part of the variable assignment. It should be: if \"%1\" NEQ \"\" set ruffFormatArgs=--diff and the redirection should be applied when the command is executed.

Suggested change
if "%1" NEQ "" set ruffFormatArgs=--diff > %1/lint-diff.diff
call uv run --group lint --directory "%here%" ruff check --fix %ruffCheckArgs%
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
call uv run --group lint --directory "%here%" ruff format %ruffFormatArgs%
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
if "%1" NEQ "" set ruffFormatArgs=--diff
call uv run --group lint --directory "%here%" ruff check --fix %ruffCheckArgs%
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
if "%1" NEQ "" (
call uv run --group lint --directory "%here%" ruff format %ruffFormatArgs% > %1/lint-diff.diff
) else (
call uv run --group lint --directory "%here%" ruff format %ruffFormatArgs%
)

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

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

If this is true, it needs to be fixed in NVDA too

@seanbudd
Copy link
Member Author

@SaschaCowley - could you please review all meta dev env changes first (i.e. everything outside of _tests and _validate)?
Once those changes are reviewed, I will rebase as follows:

  • Meta file changes (everything outside of _tests and _validate)
  • Automatic ruff lint of _tests and _validate
  • All other changes to _tests and _validate (e.g typing fixes)

@seanbudd seanbudd changed the title Use UV add UV, pre-commit, ruff, pyright Sep 18, 2025
Copy link
Member

@SaschaCowley SaschaCowley left a comment

Choose a reason for hiding this comment

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

Changes outside of _test and _validate seem fine

@SaschaCowley
Copy link
Member

Why have you replaced all the PowerShell scripts with batch scripts?

@seanbudd
Copy link
Member Author

Why have you replaced all the PowerShell scripts with batch scripts?

To more closely match NVDA, so keeping our dev envs in sync is easier.

@SaschaCowley
Copy link
Member

Okay

@seanbudd
Copy link
Member Author

@SaschaCowley - okay this has been rebased, can you check the 3rd commit
2e77412 ? The first commit should be unmodified from what you reviewed before. The second commit was generated from running pre-commit, but letting pyright fail.

@seanbudd
Copy link
Member Author

I've had to push 2 more commits because for some reason the folder being named _tests was preventing some pre-commit hooks from picking it up

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.

2 participants