The former is correct, if arg
accepts an instance of CustomClass
:
def FuncA(arg: CustomClass):
# ^ instance of CustomClass
In case you want the class CustomClass
itself (or a subtype), then you should write:
from typing import Type # you have to import Type
def FuncA(arg: Type[CustomClass]):
# ^ CustomClass (class object) itself
Like it is written in the documentation about Typing:
class typing.Type(Generic[CT_co])
A variable annotated with
C
may accept a value of typeC
. In
contrast, a variable annotated withType[C]
may accept values that
are classes themselves – specifically, it will accept the class
object ofC
.
The documentation includes an example with the int
class:
a = 3 # Has type 'int' b = int # Has type 'Type[int]' c = type(a) # Also has type 'Type[int]'