The type signature of get_grouped_opcodes() was incorrect. Resulting in type errors when checking return values.
The usage of this function is like this:
groups = sm.get_grouped_opcodes() # groups is Iterable[List[Tuple[str, int, int, int, int]]]
for group in groups: # group is List[Tuple[str, int, int, int, int]]
for opcode in group: # opcode is Tuple[str, int, int, int, int]
Fixes#1961.
I mostly just replaced all str annotations with Text, including in return types. This is
only broadly correct; diffing a str and a unicode sequence actually results in a mixed
output of str and unicode. We could also keep the return types as str if using Text
causes errors in real code. For callbacks that take str, I introduced a Union alias
because a callable taking a str would not be a compatible with a parameter of type
Callable[[Text], bool].
I also fixed the return type of difflib.restore.