inspect getsource didn't response with annotation on a class

20 Views Asked by At

For exampel I have a class in Python:

def dec(clz):
  return clz

@dec
class Test:
  pass 

when I use insepct.getsource(Test) in python 3.8, the souce code has no @dec But sourcecode will contain @dec when I use python 3.10

any information where this difference comes? If I have to support 3.8 python, what function I need to use the get the annotation along with source code?

Thanks

0

There are 0 best solutions below