Skip to content

Conversation

@poshul
Copy link
Contributor

@poshul poshul commented May 14, 2025

with current versions of Cython we get the following error:

261.3   File "/root/miniforge3/envs/streamlit-env/lib/python3.11/site-packages/autowrap/PXDParser.py", line 191, in parse_line_annotations
261.3     if isinstance(doc, basestring):
261.3                        ^^^^^^^^^^
261.3 NameError: name 'basestring' is not defined

which appears to be due to PXDParser not defining basestring as (str, bytes). Since py2 is very dead this PR removes the compatibility blocks, replaces basestring with (str,bytes) explicitly, and for good measure gets rid of our custom OrderKeepingDict, since as of python 3.7 all the functionality is in standard dict.

Summary by CodeRabbit

  • Refactor

    • Removed legacy Python 2 compatibility code and updated type checks to align with Python 3 standards.
    • Replaced custom ordered dictionary with standard Python dictionaries for method storage.
    • Modernized resource loading and package discovery mechanisms.
  • Chores

    • Updated maintainer and license metadata in project configuration.
    • Improved Python version compatibility and clarified package inclusion/exclusion rules.
  • Tests

    • Adjusted test code to ensure compatibility with Python 3 dictionary and view behaviors.
  • CI

    • Updated GitHub Actions workflow to support newer Python and Cython versions and upgraded action versions.

…py 2 compatibility which resulted in continued use of basestring
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 14, 2025

## Walkthrough

The changes remove legacy Python 2 compatibility code, update type checks to use Python 3 conventions, and replace a custom ordered dictionary with standard dicts. Resource loading is modernized, and setup metadata is refreshed. Minor test adjustments ensure compatibility with Python 3’s dictionary view semantics.

## Changes

| File(s)                                                                 | Change Summary                                                                                                                |
|-------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| autowrap/Code.py<br>autowrap/CodeGenerator.py<br>autowrap/ConversionProvider.py<br>autowrap/PXDParser.py | Removed Python 2/3 compatibility blocks; updated all string type checks from `basestring`/`unicode` to `(str, bytes)`/`str`. |
| autowrap/DeclResolver.py<br>autowrap/PXDParser.py                      | Replaced `OrderKeepingDictionary` with standard `dict` for method storage and type annotations.                               |
| autowrap/PXDParser.py                                                  | Updated resource loading from `pkg_resources.resource_filename` to `importlib.resources.files`.                               |
| autowrap/tools.py                                                      | Deleted file; removed the `OrderKeepingDictionary` implementation entirely.                                                   |
| setup.py                                                               | Switched to `find_namespace_packages`, updated maintainer and license metadata, refined package inclusion/exclusion.          |
| tests/test_decl_resolver.py                                            | Changed extraction of first method from dict values to use `list()` for Python 3 compatibility.                               |
| tests/test_pxd_parser.py                                               | Modified assertion to compare lists instead of dict_keys view for Python 3 compatibility.                                     |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant Code
    participant CodeGenerator
    participant ConversionProvider
    participant PXDParser

    User->>Code: add() / _render()
    Code->>Code: isinstance(..., (str, bytes))

    User->>CodeGenerator: generate code
    CodeGenerator->>CodeGenerator: isinstance(..., (str, bytes))

    User->>ConversionProvider: input_conversion()
    ConversionProvider->>ConversionProvider: isinstance(..., str)

    User->>PXDParser: parse_pxd_file()
    PXDParser->>PXDParser: importlib.resources.files

Poem

🐇
Out with the old, in with the new,
Python 3 shines, no more two!
Ordered dicts now just plain,
String checks simple, less arcane.
Setup’s fresh, the tests align—
This rabbit’s code is sleek and fine!


<!-- walkthrough_end -->

<!-- announcements_start -->

> [!TIP]
> <details>
> <summary>⚡️ Faster reviews with caching</summary>
> 
> - CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure `Review - Disable Cache` at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the `Data Retention` setting under your Organization Settings.
> 
> Enjoy the performance boost—your workflow just got faster.
> 
> </details>

<!-- announcements_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIhsSZnwpSAB5CiUKAGkSEm54DCIAEXgxDXRkfAAzHn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zYaJQlGhVQ1AE0OqIoIah5QOC5uRAGmSI50BCmPcGEolAMDmDcQg4bENiD5bYhMEJAXELiBDh8s+WAgbEOT0aB1A6gAgBgJiHJ64hghfLRoAwFxB1ByeaARoJiDqCE1xg9UZKBTEHACA6giQ3EAuCiHk8GAAAVhICE0QhAgGIaUNoBJDMQpQuoJiFxC1DBwtABgITTKEMAagWQiAJAFxDNDsQmIRoLQFxC0AqgjQBrnUEaGE1BwVQJQB4NyG5A6gjQKoLiDQClCxhJAUoZgnoBODzB3USwTUhsFWs7BqUKaHoCAA= -->

<!-- internal state end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=OpenMS/autowrap&utm_content=189):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `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 explain this code block.`
  -	`@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 explain its main purpose.`
  - `@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.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

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](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@poshul poshul requested a review from jpfeuffer May 14, 2025 10:47
Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
setup.py (1)

12-12: Consider using a context manager for file handling

The file is correctly read directly now, but it would be better to use a context manager to ensure proper file closure.

-exec(open(versionfile).read())
+with open(versionfile) as f:
+    exec(f.read())
🧰 Tools
🪛 Ruff (0.8.2)

12-12: Use a context manager for opening files

(SIM115)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 35eb3ab and 928808a.

📒 Files selected for processing (9)
  • autowrap/Code.py (2 hunks)
  • autowrap/CodeGenerator.py (11 hunks)
  • autowrap/ConversionProvider.py (2 hunks)
  • autowrap/DeclResolver.py (2 hunks)
  • autowrap/PXDParser.py (4 hunks)
  • autowrap/tools.py (0 hunks)
  • setup.py (2 hunks)
  • tests/test_decl_resolver.py (1 hunks)
  • tests/test_pxd_parser.py (1 hunks)
💤 Files with no reviewable changes (1)
  • autowrap/tools.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
autowrap/CodeGenerator.py (2)
autowrap/Code.py (2)
  • add (55-74)
  • Code (40-89)
autowrap/ConversionProvider.py (16)
  • output_conversion (131-134)
  • output_conversion (188-191)
  • output_conversion (233-236)
  • output_conversion (268-271)
  • output_conversion (315-318)
  • output_conversion (348-351)
  • output_conversion (378-381)
  • output_conversion (436-440)
  • output_conversion (473-476)
  • output_conversion (508-511)
  • output_conversion (541-544)
  • output_conversion (608-624)
  • output_conversion (747-801)
  • output_conversion (1095-1169)
  • output_conversion (1305-1353)
  • output_conversion (1875-1950)
🪛 Ruff (0.8.2)
setup.py

12-12: Use a context manager for opening files

(SIM115)


16-16: Undefined name __version__

(F821)

🔇 Additional comments (18)
setup.py (5)

9-9: Good update to use namespace packages

The change from find_packages to find_namespace_packages is appropriate for supporting the namespace packaging style used by the autowrap modules.


17-19: Updated project metadata

Updating the maintainer information and simplifying the license string to the SPDX identifier is a good modernization step.


30-31: Added Python 3.12 support

Good addition of Python 3.12 to the supported versions, consistent with dropping Python 2 compatibility.


37-37: Improved package inclusion patterns

The refined package patterns correctly include all autowrap namespace packages while excluding test and example code.


16-16:

Details

✅ Verification successful

Fix undefined version reference

The static analysis tool has flagged a potential issue with __version__ being undefined. This variable should be coming from the version.py file that was just executed, but there's no explicit verification.

-version="%d.%d.%d" % __version__,
+# After executing version.py, __version__ should be defined
+version="%d.%d.%d" % __version__ if '__version__' in globals() else (0, 0, 0),

🏁 Script executed:

#!/bin/bash
# Check how version.py defines the version
cat autowrap/version.py

Length of output: 1631


🏁 Script executed:

#!/bin/bash
sed -n '1,200p' setup.py

Length of output: 1640


No change needed: __version__ is defined via exec

The call to

exec(open("autowrap/version.py").read())

imports

__version__ = (0, 22, 12)
version      = __version__

so __version__ is guaranteed to be defined when used in

version="%d.%d.%d" % __version__,

The static analysis warning can be safely ignored.

🧰 Tools
🪛 Ruff (0.8.2)

16-16: Undefined name __version__

(F821)

tests/test_pxd_parser.py (1)

347-347: Fixed dictionary view compatibility for Python 3

Good update to convert the dictionary keys view to a list before comparison. This is necessary because in Python 3, dict.keys() returns a view object rather than a list.

tests/test_decl_resolver.py (1)

795-795: Fixed dictionary values view for Python 3 compatibility

Good update to convert the dictionary values view to a list before indexing. This is necessary because in Python 3, dict.values() returns a view object that doesn't support direct indexing.

autowrap/PXDParser.py (4)

403-403: Replaced OrderKeepingDict with standard dict

Excellent change to use the standard dict type. Since Python 3.7+, the built-in dictionary preserves insertion order, making the custom OrderKeepingDict implementation unnecessary.


145-145: Updated type checks for Python 3 compatibility

Good replacement of basestring (which doesn't exist in Python 3) with the explicit tuple (str, bytes). This ensures compatibility with Python 3 while maintaining the same behavior.

Also applies to: 210-210


585-588:

Details

✅ Verification successful

Modernized resource loading mechanism

Good update to use importlib.resources.files instead of the older pkg_resources.resource_filename. This is a more modern approach to resource loading that's recommended for Python 3.

However, there could be a potential issue with compatibility. Let's verify that the correct module is imported:


🏁 Script executed:

#!/bin/bash
# Check if importlib.resources is available in the environment
python -c "import importlib.resources; print('importlib.resources is available')" || echo "importlib.resources is not available"

# Check Python version to make sure it's compatible with the new API
python --version

Length of output: 155


Approve modern resource loading via importlib.resources.files

The switch from pkg_resources.resource_filename to importlib.resources.files is fully compatible—your environment (Python 3.11.2) supports this API (added in Python 3.9). No further changes needed.


2-2:

Details

❌ Incorrect review comment

Fix import error with future annotations

The import of annotations from __future__ appears to be incorrect. This should be annotations (to support postponed evaluation of annotations) but the correct import would be from __future__ import annotations.

-from __future__ import print_function, absolute_import, annotations
+from __future__ import print_function, absolute_import, annotations

Let's verify if this import is valid:


🏁 Script executed:

#!/bin/bash
# Check if "annotations" is a valid __future__ import
python -c "from __future__ import annotations; print('Valid import')" || echo "Invalid import"

Length of output: 90


No changes needed for from __future__ import annotations

The import of annotations from __future__ is valid (Python 3.7+), as confirmed by:

python -c "from __future__ import annotations; print('Valid import')"
# Output: Valid import

There is no import error, and no update is required here.

Likely an incorrect or invalid review comment.

autowrap/Code.py (2)

61-61: Updated string type check correctly for Python 3 compatibility.

The change from basestring (which doesn't exist in Python 3) to (str, bytes) is correct and maintains the same functionality of checking for any string-like type.


79-79: Updated string type check correctly for Python 3 compatibility.

Proper replacement of Python 2's basestring with equivalent Python 3 type check using (str, bytes) tuple.

autowrap/DeclResolver.py (2)

172-172: Updated type annotation to use standard dict.

The type annotation has been correctly updated to use the standard dict instead of OrderKeepingDict, aligning with Python 3.7+ where dictionaries maintain insertion order by default.


187-187: Changed implementation to use standard dict instead of OrderKeepingDict.

Good change to utilize Python 3.7+'s built-in ordered dictionaries instead of the custom implementation. This simplifies the codebase while maintaining the same functionality.

autowrap/CodeGenerator.py (1)

1262-1262: Updated all string type checks for Python 3 compatibility.

The replacement of basestring with (str, bytes) throughout the file ensures proper string type checking in Python 3. This change is consistent with similar updates in other modules and effectively removes Python 2 compatibility code.

Also applies to: 1274-1274, 1277-1277, 1346-1346, 1359-1359, 1366-1366, 1441-1441, 1454-1454, 1462-1462, 1559-1559, 1685-1685, 1698-1698, 1705-1705, 1813-1813, 1824-1824

autowrap/ConversionProvider.py (2)

2023-2024: Approve Python 3 string conversion logic
The input conversion in StdStringUnicodeConverter now correctly checks for str (the Python 3 Unicode type) and encodes it to UTF-8 bytes. This aligns with removing the old unicode alias and leverages native Python 3 semantics.


2209-2211: Approve updated type check for string literals
Replacing the old basestring compatibility check with isinstance(type_, (str, bytes)) correctly handles both text and byte literals in Python 3.7+.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (4)
setup.py (2)

12-12: File handling could be improved using a context manager

The current approach doesn't safely close the file after reading. Consider using a context manager instead.

-exec(open(versionfile).read())
+with open(versionfile) as f:
+    exec(f.read())
🧰 Tools
🪛 Ruff (0.8.2)

12-12: Use a context manager for opening files

(SIM115)


35-35: Good package specification but document the exclusion rationale

The explicit inclusion/exclusion pattern is clear, but consider adding a comment explaining why these specific packages are excluded to help future maintainers understand the reasoning.

-    packages=find_namespace_packages(include=['autowrap*'], exclude=['autowrap.data_files.examples', 'autowrap.data_files.tests', 'autowrap.data_files.ez_setup']),
+    # Include all autowrap namespace packages except examples, tests and setup utilities
+    packages=find_namespace_packages(include=['autowrap*'], exclude=['autowrap.data_files.examples', 'autowrap.data_files.tests', 'autowrap.data_files.ez_setup']),
.github/workflows/ci-autowrap.yaml (2)

24-29: Add stable Cython 3.0.0 across supported Python versions.
Including Cython==3.0.0 for Python 3.10, 3.11, and 3.12 ensures CI coverage for the first non-alpha release of 3.x. Verify that any Cython 3.0 API changes do not break existing code paths.

Consider consolidating the matrix to reduce duplication. For example:

strategy:
  matrix:
    python-version: [3.8, 3.9, 3.10, 3.11, 3.12]
    cython-version: ["<=0.29.21", ">0.29.21", "3.0.0", "3.1.0"]

Then use include/exclude to skip unsupported combinations.


37-37: Upgrade actions/checkout to v4.
Bumping actions/checkout to v4 brings performance and security improvements. If your workflows depend on full Git history (e.g., for version tagging), consider adding:

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 928808a and e2b3939.

📒 Files selected for processing (2)
  • .github/workflows/ci-autowrap.yaml (1 hunks)
  • setup.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
setup.py

12-12: Use a context manager for opening files

(SIM115)


16-16: Undefined name __version__

(F821)

🪛 GitHub Actions: build autowrap
setup.py

[error] 9-9: ModuleNotFoundError: No module named 'setuptools'. The setup.py script failed because the setuptools module is missing.

🪛 GitHub Actions: lint the codebase
setup.py

[error] 1-1: Prettier formatting check failed. File would be reformatted.

🔇 Additional comments (6)
setup.py (4)

9-9: Good update to use namespace packages!

Switching from find_packages to find_namespace_packages is appropriate for supporting namespace packages like autowrap*. This aligns with modern Python packaging practices.

🧰 Tools
🪛 GitHub Actions: build autowrap

[error] 9-9: ModuleNotFoundError: No module named 'setuptools'. The setup.py script failed because the setuptools module is missing.


17-19: Good metadata updates

The maintainer information and license updates follow best practices by using a standardized SPDX identifier for the license and generic organization details.


16-16:

Details

✅ Verification successful

Verify __version__ is defined in the imported file

The static analysis tool flags an undefined __version__ variable. The code assumes this variable is defined in the executed "autowrap/version.py" file, but this should be verified.


🏁 Script executed:

#!/bin/bash
# Check if __version__ is defined in version.py
cat autowrap/version.py | grep -E "__version__\s*="

Length of output: 79


Confirmed __version__ Definition in autowrap/version.py

Verified that __version__ is declared in autowrap/version.py as a tuple (__version__ = (0, 22, 12)), so the usage in setup.py is valid and no changes are required.

🧰 Tools
🪛 Ruff (0.8.2)

16-16: Undefined name __version__

(F821)


28-29:

Details

❓ Verification inconclusive

Verify Python version support removal intentionality

You've removed Python 3.7 and 3.8 support while adding 3.11 and 3.12. This is inconsistent with the PR objective which mentions Python 3.7+ compatibility for dictionary ordering. Ensure this is intentional.


🌐 Web query:

What is the minimum Python version where dictionaries maintain insertion order by default?

💡 Result:

The minimum Python version where dictionaries maintain insertion order by default is Python 3.7. While CPython 3.6 preserved insertion order as an implementation detail, this behavior was formally added to the language specification in Python 3.7, making it guaranteed for all Python implementations[1][2][3][4][5][6]. Thus, you can reliably depend on insertion-order dictionaries starting with Python 3.7.

Citations:


Confirm Intent for Dropping Python 3.7–3.10 Support

The PR’s objective states “Python 3.7+ compatibility” because dict insertion order is guaranteed starting in 3.7, yet the setup.py classifiers now only list 3.11 and 3.12:

  • File: setup.py
    Lines 28–29
  •   "Programming Language :: Python :: 3.11",
    
  •   "Programming Language :: Python :: 3.12",
    
  •   "Programming Language :: Python :: 3.11",
    
  •   "Programming Language :: Python :: 3.12",
    
    
    

Please confirm whether you intend to drop support for 3.7, 3.8, 3.9, and 3.10 entirely. If not, update the classifiers to include all supported 3.7+ versions.

.github/workflows/ci-autowrap.yaml (2)

19-19: Use Python 3.8 for legacy Cython compatibility.
Switching from Python 3.7 to 3.8 for Cython <=0.29.21 correctly addresses its incompatibility with Python 3.10+.


30-35: Test Cython 3.1.0 on the latest Python versions.
The new entries for Cython==3.1.0 on Python 3.10, 3.11, and 3.12 keep CI aligned with cutting-edge Cython releases. Confirm that any experimental features in Cython 3.1 don’t introduce regressions.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
.github/workflows/release-autowrap.yaml (1)

33-35: Consider consolidating pip install steps
You can merge the separate steps for upgrading pip, installing wheel, and installing setuptools into one to reduce setup overhead:

-      - name: Upgrade pip version
-        run: |
-          python -m pip install -U pip
-
-      - name: Install wheel
-        run: |
-          python -m pip install wheel
-
-      - name: Install setuptools
-        run: |
-          python -m pip install setuptools
+      - name: Install build dependencies
+        run: |
+          python -m pip install -U pip setuptools wheel
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e2b3939 and 919817d.

📒 Files selected for processing (2)
  • .github/workflows/ci-autowrap.yaml (2 hunks)
  • .github/workflows/release-autowrap.yaml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci-autowrap.yaml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/release-autowrap.yaml

21-21: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (3)
.github/workflows/release-autowrap.yaml (3)

18-18: Bump actions/checkout to v4
Upgrading from @v3 to @v4 aligns with the latest stable release of the checkout action and brings in performance and security improvements.


23-23: Upgrade Python version to 3.11
Moving the runner to Python 3.11 ensures compatibility with the latest language features and aligns with the overall goal of dropping older Python support.


53-59: Update GitHub Release action to v2 and rename parameter
Using softprops/action-gh-release@v2 and the new name parameter (replacing release_name) matches the action’s updated API. This change correctly modernizes the release step.

Copy link
Member

@t0mdavid-m t0mdavid-m left a comment

Choose a reason for hiding this comment

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

LGTM

@t0mdavid-m
Copy link
Member

Maybe check what the linter is complaining about

@poshul poshul merged commit 8733413 into master May 14, 2025
9 of 11 checks passed
@timosachsenberg timosachsenberg deleted the remove_py2 branch May 15, 2025 07:37
This was referenced Nov 28, 2025
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.

3 participants