Issue with type checking in Pyhton

Hi @izzylys,

I’m experiencing an issue with the type checking that is conducted in the Python Base class in the specklepy client. I actually just updated the specklepy version to 2.3.4, before I had version 2.2.3 (should have update earlier :sweat_smile:). The issue I’m having only occurs now, with the previous version it didn’t.

The actual issue is that the type checking of values that are assigned is giving an error for a Union type hint including other typing type hints, e.g.: meta_data: Optional[Dict[str, Any]] = None
While checking, this will be interpreted as a Union with Dict[str, Any] and NoneType arguments.

The error is thrown in the Base method _type_check, which carries out lightweight type checking as described. Problem is that in this kind of nested Union type hint, the argument Dict[str, Any] is not being replaced by a simple dict type hint (line 252). This raises an error when the isinstance check is being performed (line 258).

Below I’ve quickly added two lines of code that fix the issue for me.

Would be nice if you can take a look at it!

Hey Rob,

Thanks a lot for reporting this - looks like my tests weren’t covering it!

I’ve just updated the tests and merged a fix. v2.3.5 is available to install and should fix your problems :tada:

1 Like

Thanks! Works now :slight_smile:

1 Like