pydantic-numpy
pydantic-numpy copied to clipboard
Type subscription requires python >= 3.9
Under python 3.8, from pydantic_numpy import NDArrayFP32 raise TypeError: Type subscription requires python >= 3.9. Any workaround to this issue?
I've experimented the same issue:
○ → python
Python 3.8.11 (default, Nov 15 2022, 09:08:50)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydantic_numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sngular/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pydantic_numpy/__init__.py", line 1, in <module>
from pydantic_numpy.dtype import *
File "/home/sngular/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pydantic_numpy/dtype.py", line 7, in <module>
from pydantic_numpy.ndarray import NDArray
File "/home/sngular/.pyenv/versions/3.8.11/lib/python3.8/site-packages/pydantic_numpy/ndarray.py", line 10, in <module>
nd_array_type = np.ndarray if NumpyVersion(np.__version__) < "1.22.0" else np.ndarray[Any, T]
TypeError: Type subscription requires python >= 3.9
>>>
Unfortunately pyproject.toml states ^3.7 :pensive:
Anyone knows what kind of advantages do this type subscription has?
np.ndarray[Any, T]
Shouldn't it be enough with the following?
np.ndarray
I think this issue was actually resolved in #10 , specifically commit https://github.com/cheind/pydantic-numpy/pull/10/commits/ccdf57e7545d2abf4b9fb323577bc4151db3f523. The issue seems to be that the version of this package in the PyPI index is four months old. Similarly, the version number has not been updated from 1.3.0 in four months.
Maybe we can get @caniko or @cheind to bump the version number and publish an updated package to PyPI. Otherwise you'll need to figure out another way to install the latest code from GitHub.
My earlier post got lost, sorry: i do not own the PyPi package, so I cannot update it. Installing from github is easy though
pip install git+https://github.com/cheind/pydantic-numpy.git
which should install the latest from main branch. I will update the readme instructions accordingly.
I updated the ReadMe and performed a version bump to 1.4.0
I can upload when I am back from vacation!
I made some changes to the PR on my own fork—it should work now.
You can install from PyPi.