Skip to content

feat: update support Python versions #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 13, 2024
Merged

Conversation

shenxianpeng
Copy link
Contributor

@shenxianpeng shenxianpeng commented Dec 13, 2024

Since Python 3.8 has already end of life (2024-10-07) https://devguide.python.org/versions

We might need to drop support it and also include Python 3.12 and 3.13

Summary by CodeRabbit

  • New Features

    • Added a Python version badge to the README, indicating supported Python versions.
    • Updated project metadata to specify a minimum required Python version of 3.9.
  • Chores

    • Expanded the range of Python versions tested in the CI workflow to include versions 3.9 through 3.13.
    • Modified the order of badges in the README to include the new Python version badge.
    • Corrected the author's name in project metadata.

@shenxianpeng shenxianpeng added the enhancement New feature or request label Dec 13, 2024
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Dec 13, 2024
Copy link

coderabbitai bot commented Dec 13, 2024

Walkthrough

The changes in this pull request involve updates to the configuration files for a project. The Python versions in the CI testing matrix have been expanded to include versions 3.9, 3.10, 3.11, 3.12, and 3.13. Additionally, a new badge indicating the supported Python version has been added to the README.rst file, and the order of existing badges has been modified. Lastly, the pyproject.toml file has been updated to specify a minimum required Python version of 3.9.

Changes

File Change Summary
.github/workflows/run-dev-tests.yml Updated Python versions in the testing matrix to include 3.9, 3.10, 3.11, 3.12, and 3.13.
README.rst Added a Python version badge and updated the order of badges displayed.
pyproject.toml Updated author name to Xianpeng Shen, added requires-python = ">=3.9", and added classifiers for Python versions 3.9 through 3.13.

Sequence Diagram(s)

sequenceDiagram
    participant CI as Continuous Integration
    participant Repo as Repository
    participant User as Developer

    User->>Repo: Push changes
    Repo->>CI: Trigger workflow
    CI->>CI: Run tests on Python 3.9, 3.10, 3.11, 3.12, 3.13
    CI-->>User: Test results
Loading

🐰 In a world of code, so bright and new,
A badge for Python, shiny and true.
With versions updated, the tests now run,
Hopping through changes, oh what fun!
From 3.9 to 3.13, we leap and cheer,
For every new feature, we hold so dear! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3996ef4 and 9eeb03b.

📒 Files selected for processing (1)
  • cpp_linter/clang_tools/patcher.py (1 hunks)
🔇 Additional comments (3)
cpp_linter/clang_tools/patcher.py (3)

10-10: LGTM! Clean and maintainable constant definition

The simplified assignment of INDENT_HEURISTIC directly from DiffOption.INDENT_HEURISTIC is a good improvement. This change aligns well with dropping Python 3.8 support and makes the code more maintainable.


8-8: Verify if type ignore comment is still necessary

The # type: ignore comment might have been added for older Python versions. Since we're dropping Python 3.8 support, let's verify if this type ignore is still required.

✅ Verification successful

Keep the type ignore comment

The # type: ignore comment should be retained as it's consistently used across the codebase for all pygit2 imports. This is evidenced by similar type ignore comments in multiple files:

  • tests/capture_tools_output/test_tools_output.py
  • cpp_linter/git/init.py
  • cpp_linter/common_fs/init.py
  • cpp_linter/clang_tools/patcher.py
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if pygit2 has type hints in newer versions
# This will help determine if the type ignore comment is still necessary

# Check if there are any stub files for pygit2
fd -e pyi "pygit2"

# Check if pygit2 package has type hints
rg -l "from typing import" -g "pygit2/**/*.py"

Length of output: 216


Script:

#!/bin/bash
# Let's check if mypy reports any issues with the pygit2 import
# Create a temporary file for mypy check
echo 'from pygit2.enums import DiffOption' > /tmp/test_import.py
mypy /tmp/test_import.py

# Let's also check how this import is handled in other files
rg "from pygit2.*import.*DiffOption" -A 2 -B 2

# Check if there are any other type: ignore comments for pygit2
rg "pygit2.*# type: ignore"

Length of output: 968


8-10: Verify pygit2 compatibility with newer Python versions

Since we're updating Python version support to include 3.12 and 3.13, we should verify that the pygit2 library is compatible with these versions.

✅ Verification successful

Let me gather more information about the pygit2 dependency and its version constraints.


No compatibility concerns with pygit2 for Python version update

The codebase already has fallback mechanisms for pygit2 issues (as seen in git_str.py), and the package is listed as a direct dependency without version constraints. The code's Python requirement of ">=3.9" is compatible with newer versions, and pygit2 officially supports Python 3.9+ through to the latest versions.

  • The type ignore comments on pygit2 imports are intentional and unrelated to version compatibility
  • There's a documented fallback in git_str.py for handling any pygit2 parsing issues
  • The only pygit2-related test (test_pygit2_bug1260) is for a specific issue that's already been resolved
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check pygit2 version constraints and Python compatibility

# Check if pyproject.toml specifies pygit2 version
rg "pygit2" pyproject.toml

# Check for any version-specific imports or compatibility code
rg -A 5 "import.*pygit2"

Length of output: 508


Script:

#!/bin/bash
# Check for dependency specifications in setup.py, setup.cfg, or requirements files
fd -e txt -e cfg -e py "setup|requirements" --exec rg "pygit2"

# Check Python version constraints in pyproject.toml
rg "python" pyproject.toml

# Look for any version-specific handling or imports of pygit2
rg -g "!*.{json,md}" "pygit2" .

Length of output: 1971


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
pyproject.toml (1)

15-17: Fix inconsistent spacing around the new field

The new requires-python field has inconsistent spacing around it. Consider removing the extra blank lines to maintain consistent spacing with other fields in the section.

 authors = [
     { name = "Brendan Doherty", email = "2bndy5@gmail.com" },
     { name = "Peter Shen", email = "xianpeng.shen@gmail.com" },
 ]
-
-
 requires-python = ">=3.9"
-
 classifiers = [
.github/workflows/run-dev-tests.yml (1)

44-44: Consider Python 3.13 testing strategy

Python 3.13 is currently in development (alpha stage). While it's good to test against future versions, there are some considerations:

  1. It might cause unstable test results
  2. Some dependencies might not work with 3.13 yet
  3. GitHub Actions runners might not have stable support for 3.13

Consider either:

  • Adding continue-on-error: true for Python 3.13 jobs
  • Or waiting until Python 3.13 reaches beta/RC stage
 matrix:
-  py: ['3.9', '3.10', '3.11', '3.12', '3.13']
+  py: ['3.9', '3.10', '3.11', '3.12']
+  include:
+    - py: '3.13'
+      continue-on-error: true
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6bfbcc and 0c64196.

📒 Files selected for processing (3)
  • .github/workflows/run-dev-tests.yml (1 hunks)
  • README.rst (2 hunks)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • README.rst
🔇 Additional comments (1)
.github/workflows/run-dev-tests.yml (1)

44-44: Verify GitHub Actions runner compatibility

Let's verify that the selected GitHub Actions runners support Python 3.12 and 3.13.

✅ Verification successful

Python 3.12 and 3.13 are supported by the workflow configuration

The workflow uses actions/setup-python@v5 which officially supports Python 3.12 and 3.13-dev (as of December 2024). The workflow runs on ubuntu-22.04 and windows-latest, both of which are compatible with these Python versions through the setup-python action. The matrix configuration is correctly set up to test across all specified Python versions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check GitHub Actions runner images for Python version support

# Query GitHub API for runner image details
gh api graphql -f query='
{
  repository(owner: "actions", name: "runner-images") {
    object(expression: "main") {
      ... on Commit {
        tree {
          entries {
            name
            object {
              ... on Tree {
                entries {
                  name
                  object {
                    ... on Blob {
                      text
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}' | jq -r '.data.repository.object.tree.entries[] | select(.name | test("(ubuntu|windows).*")).name'

Length of output: 610


Script:

#!/bin/bash
# Let's check the workflow file to understand which runner is being used
cat .github/workflows/run-dev-tests.yml

Length of output: 3433

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c64196 and 14d0052.

📒 Files selected for processing (1)
  • pyproject.toml (2 hunks)

Copy link
Contributor

@2bndy5 2bndy5 left a comment

Choose a reason for hiding this comment

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

I was a little afraid because Ubuntu 20.04 LTS uses 3.8 by default, but that was bumped to 3.10 in Ubuntu 22.04.

shenxianpeng and others added 2 commits December 13, 2024 17:25
Co-authored-by: Brendan <2bndy5@gmail.com>
@2bndy5 2bndy5 added the minor A minor version bump label Dec 13, 2024
@2bndy5

This comment was marked as resolved.

@shenxianpeng
Copy link
Contributor Author

Like this 9eeb03b?

@shenxianpeng
Copy link
Contributor Author

By the way. setup.py seems useless now since we have pyproject.toml, do you think I can remove it?

@2bndy5
Copy link
Contributor

2bndy5 commented Dec 13, 2024

Like this 9eeb03b?

Yeah! Let's see if the tests pass.

setup.py seems useless now since we have pyproject.toml, do you think I can remove it?

I'm leaving it there in case people try to install with an older version of pip (that does not support the latest PEPs).


Since this is technically a minor version bump, I'd like to get this released with #131 feature as well (in v1.11.0).

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d6bfbcc) to head (9eeb03b).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #134   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         1873      1869    -4     
=========================================
- Hits          1873      1869    -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shenxianpeng shenxianpeng requested a review from 2bndy5 December 13, 2024 16:18
@shenxianpeng shenxianpeng merged commit 239d6b8 into main Dec 13, 2024
133 checks passed
@shenxianpeng shenxianpeng deleted the update-python-version branch December 13, 2024 16:29
@shenxianpeng shenxianpeng removed documentation Improvements or additions to documentation minor A minor version bump labels Jan 31, 2025
@shenxianpeng shenxianpeng changed the title feat: update support python versions feat: update support Python versions Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants