Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. from typing import *
  2.  
  3. def example_decorator(
  4. fn: Callable[[List[str]], List[str]]
  5. ) -> Callable[[List[str]], str]:
  6. def wrapper(data: List[str]) -> str:
  7. res = fn(data)
  8. return ', '.join(res)
  9.  
  10. return wrapper
  11.  
  12.  
  13. @example_decorator
  14. def func(data: List[str]) -> List[str]:
  15. data.append('XYZ')
  16. return data
  17.  
  18.  
  19. def test() -> str:
  20. result = func(['ABC', 'EFG'])
  21. print(type(result)) # <class 'str'>
  22. return result # Incompatible return type [7]: Expected str but got typing.List[str].
  23.  
  24.  
  25. test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement