NCAS-CMS / NCAS-CMS/cf-python

Support for Python 3.10?

Open
#921 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug?
Dominant language
Python
Stars
150
Forks
23
Avg merge
1d 11h
Merged PRs (30d)
2

Description

Firstly, thank you for maintaining this software.

The latest update of cf-python appears to break for Python 3.10.

Importing leads to a traceback detailed below.

PyPI still lists 3.10 as being supported and there is a possible fix (see below) so we presume this is a bug and not a dropping in support for Python 3.10 (not mentioned in the release notes for cf-python 3.19).

Steps to reproduce:

Create an environment with Python 3.10 and install cf-python, launch a repl, and attempt to import cf.

python3.10 -m venv cf-venv
source cf-venv/bin/activate
pip install cf-python
python
Python 3.10.19 (main, Oct  9 2025, 15:25:03) [Clang 17.0.0 (clang-1700.0.13.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cf

Expected behaviour:

cf-python imported and useable, as is the case for Python >=3.11

Actual behaviour:

Import fails due to invalid syntax

>>> import cf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jwa34/venv/lib/python3.10/site-packages/cf/__init__.py", line 215, in <module>
    from .regrid import RegridOperator
  File "/Users/jwa34/venv/lib/python3.10/site-packages/cf/regrid/__init__.py", line 1, in <module>
    from .regrid import regrid
  File "/Users/jwa34/venv/lib/python3.10/site-packages/cf/regrid/regrid.py", line 2203
    mask1 = mask1[..., *partition]
                       ^
SyntaxError: invalid syntax

Version:

Downloaded: cf_python-3.19.0.tar.gz
Working on M2 Macbook, but reproducible on linux rhel environment and GitHub Workflow.

Possible Solution/Workaround:

Editing the offending line to be a tuple of arguments allows successful import, but this is not extensively tested to you will need to confirm that it is satisfactory for the wider package.

mask1 = mask1[(..., *partition)]

cc @sjavis

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cf/regrid/regrid.py at the mask1 assignment around line 2203 and reproduce the import failure in a Python 3.10 environment using the commands in the issue. Check whether the tuple-indexing workaround works for the wider package, then verify that cf imports successfully on Python 3.10 without regressing supported versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.