Repository navigation
Add docstrings to FirstMatchRegistry - #832
JazzyJJ0601 wants to merge 1 commit into
Conversation
mayureshsonawane17
left a comment
There was a problem hiding this comment.
I read through the proposed docstrings and compared them against the implementation in responses/registries.py.
The docstring formatting is clean and follows the project style. In FirstMatchRegistry.replace(), the docstring states it replaces the response with the same method and URL. Since self.registered.index(response) invokes BaseResponse.__eq__ (which evaluates matchers in addition to URL/method), would it be helpful to clarify that matcher equality is also considered?
|
|
||
| def replace(self, response: "BaseResponse") -> "BaseResponse": | ||
| """Replace the registered response with the same method and URL as ``response``. | ||
|
|
There was a problem hiding this comment.
Since self.registered.index(response) compares BaseResponse instances using __eq__ (evaluating matchers alongside method and URL), should the docstring note that matching rules/matchers are also evaluated when locating the response to replace?
| def add(self, response: "BaseResponse") -> "BaseResponse": | ||
| """Register a response and return it. | ||
|
|
||
| If the same `Response` instance is already registered, a deep copy is |
There was a problem hiding this comment.
| If the same `Response` instance is already registered, a deep copy is | |
| If the same ``Response`` instance is already registered, a deep copy is |
python docstrings are RST shaped.
FirstMatchRegistryis the default registry, but unlikeOrderedRegistryit had no docstrings. This adds them in the same numpy style: the class (including how multiple matches are handled),registered,reset,find,add(the deep copy when the same instance is added twice),removeandreplace(both compare by method and URL, viaBaseResponse.__eq__).Docstrings only; no code changes.
pytest responses/tests/test_registries.pypasses.AI disclosure: I found the gap with an audit tool I'm building, drafted the text with an AI assistant (Claude), and checked every line against the code by hand.
(Audit tool: Legacy Doc-AI.)