I have a method which inspects and processes the source of arbitrary classes (classes only, not class instances or any other non-class types). The classes can be from any standard library, or 3rd party library, or user-defined classes.
But don't know of a correct way of annotating the type of the class argument using the typing module. I don't think typing.Type is the right one because it also applies to objects:
>>> class A: pass
>>> a = A()
>>> def test(cl: typing.Type) -> typing.Type:
... return type(cl)
>>> test(A)
>>> type
>>> isinstance(A, typing.Type)
>>> True
>>> test(a)
>>> type
>>> isinstance(A, typing.Type)
>>> False
>>> test('A')
>>> str
>>> isinstance(A, typing.Type)
>>> False
Should annotations work this way? Isn't the point that annotated arguments should restrict the calling of the method to recognise only the correct types of arguments?
typing.Generator) and iterators (typing.Iterator), even though a generator is an iterator.isinstance((x for x in range(10)), typing.Iterator)->True