ramonhagenaars / nptyping

💡 Type hints for Numpy and Pandas
MIT License
576 stars 29 forks source link

NDArray backward compatibility with v1.4.4 #87

Open jckhang opened 2 years ago

jckhang commented 2 years ago

I really like the new API for shapes. However the new change in the NDArray is now backward compatible.

In v1.4.4, you can construct a NDArray of int32 with any dimension like this

>>> NDArray[np.int32]
NDArray[(typing.Any, ...), Int[32]]

The old ways of hint no longer works and you need to do the same thing with

>>> NDArray[typing.Any, np.int32]

Backward compatible will make the migration a lot easier.

ramonhagenaars commented 1 year ago

Backward compatibility is not possible with the new syntax. The new syntax has been designed to be mypy and pyright compliant and with more expressiveness. These were things that were not possible in the 1.* syntax unfortunately.

What difficulties do you precisely have with migrating to the 2.* version? Have you considered maybe to carefully replace your hints with regular expressions throughout your codebase?