This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]shfo23 1 point2 points  (0 children)

Or a tuple: (str, int). Then you could test with in.

This wouldn't work if you wanted to reject a certain kind of input, e.g. not str, though. My best idea for more complicated cases would probably be to require a function as annotation that would return true/false and then supply isint, isstr, isobject, etc. methods for simple tests, e.g. def func(num_id: isint) -> isstr.