Closed Tarrasch closed 7 years ago
Thanks for trying it out!
It is an interesting problem. As it turns out, this is a problem with blindly attempting to enforce runtime type safety on every attribute of a given class (especially if it inherits from an inbuilt class).
It will be possible to use named tuples as a type hint in the functions. However, it will be slightly harder to make named tuples truly typed.
I have some ideas how it can be done. I will look at it over the coming weekend and will keep you updated.
OK, I just pushed a patch into 'dev' branch enabling your specific use case of NamedTuples. Full support for named tuples (i.e. named tuple as a type hint) will be coming a bit later.
As I don't consider myself a power user yet, I'll wait for some sort of pypi release. But thanks for implementing this!
I am sorry for the long delay but the pypi version of Enforce.py was just updated to 0.3.2. This version includes all the fixes for the NamedTuples and adds a support for Python 3.5.3 and 3.6.0.
Please have a look if you are still interested.
First, thanks for this awesome project!
Can this project be used with
typing.NamedTuple
? I tried this but I couldn't get it to work.I use version typing=0.3.1 and python=3.5.2.