To use a type hint to specify a parameter can be any subclass object of the hinted class, use typing.Type and in the annotation do Type[A]. This is useful if getting warnings for f-strings passed into functions that expect strings.

from typing import Type
s = f"blah"
process(fstring=s)
def process(fstring=Type[str]):
 return fstring

This isn’t needed for instances that are subtypes, though.

Project Source#