inspect_stringized_annotations.py 612 B

12345678910111213141516171819202122232425262728293031323334
  1. from __future__ import annotations
  2. a:int=3
  3. b:str="foo"
  4. class MyClass:
  5. a:int=4
  6. b:str="bar"
  7. def __init__(self, a, b):
  8. self.a = a
  9. self.b = b
  10. def __eq__(self, other):
  11. return isinstance(other, MyClass) and self.a == other.a and self.b == other.b
  12. def function(a:int, b:str) -> MyClass:
  13. return MyClass(a, b)
  14. def function2(a:int, b:"str", c:MyClass) -> MyClass:
  15. pass
  16. def function3(a:"int", b:"str", c:"MyClass"):
  17. pass
  18. class UnannotatedClass:
  19. pass
  20. def unannotated_function(a, b, c): pass
  21. class MyClassWithLocalAnnotations:
  22. mytype = int
  23. x: mytype