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