Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

func_typecheck_callfunc_assigment.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """check assignment to function call where the function doesn't return
  2. 'E1111': ('Assigning to function call which doesn\'t return',
  3. 'Used when an assignment is done on a function call but the \
  4. infered function doesn\'t return anything.'),
  5. 'W1111': ('Assigning to function call which only returns None',
  6. 'Used when an assignment is done on a function call but the \
  7. infered function returns nothing but None.'),
  8. """
  9. from __future__ import generators, print_function
  10. def func_no_return():
  11. """function without return"""
  12. print('dougloup')
  13. A = func_no_return()
  14. def func_return_none():
  15. """function returning none"""
  16. print('dougloup')
  17. return None
  18. A = func_return_none()
  19. def func_implicit_return_none():
  20. """Function returning None from bare return statement."""
  21. return
  22. A = func_implicit_return_none()
  23. def func_return_none_and_smth():
  24. """function returning none and something else"""
  25. print('dougloup')
  26. if 2 or 3:
  27. return None
  28. return 3
  29. A = func_return_none_and_smth()
  30. def generator():
  31. """no problemo"""
  32. yield 2
  33. A = generator()
  34. class Abstract(object):
  35. """bla bla"""
  36. def abstract_method(self):
  37. """use to return something in concrete implementation"""
  38. raise NotImplementedError
  39. def use_abstract(self):
  40. """should not issue E1111"""
  41. var = self.abstract_method()
  42. print(var)