Not compatible with NumPy >= 2.5.0

Open Beginner friendly
#218 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python
Domain
backend

Research direction

Start at variable_value.py:107 and reproduce the import failure with NumPy 2.5.0 or newer using the issue's virtual-environment steps. Check how CommonArrayValue uses numpy.typing.NDArray, then verify that importing ansys.tools.variableinterop succeeds with the affected NumPy versions and add or update regression coverage if the repository provides it.

Written by the indexing model from the issue text.

Description

bug
πŸ” Before submitting the issue
  • I have searched among the existing issues
  • I am using a Python virtual environment
🐞 Description of the bug

If you try to use this AVI library with NumPy 2.5.0 or greater, you will receive a weird error:

    from .variable_value import IVariableValue
  File "/home/nsharp/ver/py-cam-common/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/variable_value.py", line 107, in <module>
    class CommonArrayValue(Generic[T], NDArray[T], IVariableValue, ABC):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

This is because numpy 2.5.0 redefines numpy.typing.NDArray as a PEP 695 type alias (typing.TypeAliasType), which is not a class and therefore cannot be used as a base class. pyansys-tools-variableinterop 0.1.4 does exactly that in variable_value.py:107:

class CommonArrayValue(Generic[T], NDArray[T], IVariableValue, ABC):
πŸ“ Steps to reproduce
nsharp@ubuntu-linux-2404:~/src/delme$ python3 -m venv .venv
nsharp@ubuntu-linux-2404:~/src/delme$ . .venv/bin/activate
(.venv) nsharp@ubuntu-linux-2404:~/src/delme$ pip install pyansys-tools-variableinterop==0.1.4
Collecting pyansys-tools-variableinterop==0.1.4
  Using cached pyansys_tools_variableinterop-0.1.4-py3-none-any.whl.metadata (10 kB)
Collecting anyio>=3.5 (from pyansys-tools-variableinterop==0.1.4)
  Using cached anyio-4.14.2-py3-none-any.whl.metadata (4.6 kB)
Collecting numpy>=1.20.3 (from pyansys-tools-variableinterop==0.1.4)
  Downloading numpy-2.5.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.metadata (6.6 kB)
Collecting overrides>=7.4 (from pyansys-tools-variableinterop==0.1.4)
  Using cached overrides-7.7.0-py3-none-any.whl.metadata (5.8 kB)
Collecting idna>=2.8 (from anyio>=3.5->pyansys-tools-variableinterop==0.1.4)
  Using cached idna-3.18-py3-none-any.whl.metadata (6.1 kB)
Collecting typing_extensions>=4.5 (from anyio>=3.5->pyansys-tools-variableinterop==0.1.4)
  Using cached typing_extensions-4.16.0-py3-none-any.whl.metadata (3.3 kB)
Using cached pyansys_tools_variableinterop-0.1.4-py3-none-any.whl (86 kB)
Using cached anyio-4.14.2-py3-none-any.whl (125 kB)
Downloading numpy-2.5.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (15.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.6/15.6 MB 31.1 MB/s eta 0:00:00
Using cached overrides-7.7.0-py3-none-any.whl (17 kB)
Using cached idna-3.18-py3-none-any.whl (65 kB)
Using cached typing_extensions-4.16.0-py3-none-any.whl (45 kB)
Installing collected packages: typing_extensions, overrides, numpy, idna, anyio, pyansys-tools-variableinterop
Successfully installed anyio-4.14.2 idna-3.18 numpy-2.5.2 overrides-7.7.0 pyansys-tools-variableinterop-0.1.4 typing_extensions-4.16.0
(.venv) nsharp@ubuntu-linux-2404:~/src/delme$ python
Python 3.12.3 (main, Jun 19 2026, 12:46:00) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ansys.tools.variableinterop import RealValue
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/__init__.py", line 39, in <module>
    from .api_serialization import from_api_string, to_api_string
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/api_serialization.py", line 27, in <module>
    from .api_string_to_value_visitor import APIStringToValueVisitor
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/api_string_to_value_visitor.py", line 33, in <module>
    from .array_values import BooleanArrayValue, IntegerArrayValue, RealArrayValue, StringArrayValue
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/array_values.py", line 36, in <module>
    from .scalar_values import BooleanValue, IntegerValue, RealValue, StringValue
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/scalar_values.py", line 32, in <module>
    from .exceptions import IncompatibleTypesException
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/exceptions.py", line 28, in <module>
    from .variable_type import VariableType
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/variable_type.py", line 29, in <module>
    from .variable_value import IVariableValue
  File "/home/nsharp/src/delme/.venv/lib/python3.12/site-packages/ansys/tools/variableinterop/variable_value.py", line 107, in <module>
    class CommonArrayValue(Generic[T], NDArray[T], IVariableValue, ABC):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
>>> 
πŸ’» Which operating system are you using?

Linux

πŸ“€ Which ANSYS version are you using?

No response

🐍 Which Python version are you using?

3.12

πŸ“¦ Installed packages
anyio==4.14.2
idna==3.18
numpy==2.5.2
overrides==7.7.0
pyansys-tools-variableinterop==0.1.4
typing_extensions==4.16.0
Dominant language
Python
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

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.

More from ansys/pyansys-tools-variableinterop

All issues in ansys/pyansys-tools-variableinterop

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.