brain_responses.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  2. # For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
  3. # Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
  4. """
  5. Astroid hooks for responses.
  6. It might need to be manually updated from the public methods of
  7. :class:`responses.RequestsMock`.
  8. See: https://github.com/getsentry/responses/blob/master/responses.py
  9. """
  10. from astroid.brain.helpers import register_module_extender
  11. from astroid.builder import parse
  12. from astroid.manager import AstroidManager
  13. def responses_funcs():
  14. return parse(
  15. """
  16. DELETE = "DELETE"
  17. GET = "GET"
  18. HEAD = "HEAD"
  19. OPTIONS = "OPTIONS"
  20. PATCH = "PATCH"
  21. POST = "POST"
  22. PUT = "PUT"
  23. response_callback = None
  24. def reset():
  25. return
  26. def add(
  27. method=None, # method or ``Response``
  28. url=None,
  29. body="",
  30. adding_headers=None,
  31. *args,
  32. **kwargs
  33. ):
  34. return
  35. def add_passthru(prefix):
  36. return
  37. def remove(method_or_response=None, url=None):
  38. return
  39. def replace(method_or_response=None, url=None, body="", *args, **kwargs):
  40. return
  41. def add_callback(
  42. method, url, callback, match_querystring=False, content_type="text/plain"
  43. ):
  44. return
  45. calls = []
  46. def __enter__():
  47. return
  48. def __exit__(type, value, traceback):
  49. success = type is None
  50. return success
  51. def activate(func):
  52. return func
  53. def start():
  54. return
  55. def stop(allow_assert=True):
  56. return
  57. """
  58. )
  59. register_module_extender(AstroidManager(), "responses", responses_funcs)