from ctypes import CDLL, c_char_p from ctypes.util import find_library from inspect import signature def fn() -> None: pass # prints () -> NoneType starting in python 3.10, () -> None before that print(signature(fn)) libc = CDLL(find_library('c')) # Works as expected perror = libc.perror perror.restype = None perror.argtypes = [c_char_p] perror(b"error") # Causes TypeError: NoneType takes no arguments perror = libc.perror perror.restype = type(None) perror.argtypes = [c_char_p] perror(b"error") # Thus the following would work on Python 3.9 but fail on 3.10 def error(message: c_char_p) -> None: pass s = signature(error) perror.restype = s.return_annotation perror.argtypes = [v.annotation for v in s.parameters.values()] perror(b"error")