In the docstring of the Token open function user_pin and so_pin are documented as bytes, but the code assumes they are strings:
elif user_pin is not None:
pin = user_pin.encode('utf-8')
c_user_type = user_type if user_type is not None else CKU_USER
elif so_pin is not None:
pin = so_pin.encode('utf-8')
c_user_type = CKU_SO
This causes pycharm (and other type checking tools) to complain