Commit 12497e4
Improve
* Improve `RegisteredResponse` init doc & signature
`RegisteredResponse.__init__` allowed any keyword arguments via
`**kwargs` usage, but would later pass these to `responses.Response`
via the `add()` or `replace()` methods, at which point there would be
a `TypeError`.
This can make it hard to understand what features are being exposed
during development. e.g., "Was the parameter name `status` or
`status_code`?"
To resolve and provide an improved experience for development with
`RegisteredResponse`, the init parameters are better documented and
the signature is improved to explicitly enumerate supported args.
1. Add `:param ...:` docstring items
2. Explicitly enumerate parameters, removing `**kwargs: Any`
3. Document which parameters come from `responses.Response`, which
come from `responses.BaseResponse`, and which ones are omitted (and
why)
4. Update `service` and `method` to use Literals to show the values
In terms of lost functionality, technically the following three
parameters are removed in this change:
- auto_calculate_content_length
- passthrough
- match_querystring
However, given that `_testing` has a weaker backwards compatibility
contract than the rest of the SDK and there are no known usages for
these, this seems like a good change rather than a bad one. We can
always add `auto_calculate_content_length` in the future. The other
two would require stronger justification, since
- match_querystring is deprecated in `responses`
- passthrough doesn't seem applicable to any normal uses of
`globus_sdk._testing`
- we don't forbid anyone from using `responses` directly
* Update src/globus_sdk/_testing/models.py
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>
* Enforce `RegisteredResponse.method` correctness
Compare in a test against the options supported by `http.HTTPMethod`,
and thereby compare against the strings supported by `responses`.
Add `OPTIONS`, `CONNECT`, and `TRACE` for completeness.
* Make `RegisteredResponse.match` default to None
In order to ensure that we aren't overriding a potentially new default
in `responses` by passing `()` explicitly to it, simply default to
`None` and only pass a value if it is non-null.
Also refine docstrings.
---------
Co-authored-by: Kurt McKee <contactme@kurtmckee.org>RegisteredResponse init doc & signature (#1126)1 parent bf6dbf1 commit 12497e4
File tree
2 files changed
+97
-8
lines changed- src/globus_sdk/_testing
- tests/unit/_testing
2 files changed
+97
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
22 | 41 | | |
23 | 42 | | |
24 | 43 | | |
| |||
40 | 59 | | |
41 | 60 | | |
42 | 61 | | |
| 62 | + | |
| 63 | + | |
43 | 64 | | |
44 | | - | |
45 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
46 | 95 | | |
47 | | - | |
48 | 96 | | |
49 | | - | |
50 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
51 | 110 | | |
52 | 111 | | |
53 | 112 | | |
| |||
69 | 128 | | |
70 | 129 | | |
71 | 130 | | |
72 | | - | |
| 131 | + | |
73 | 132 | | |
| 133 | + | |
74 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
75 | 140 | | |
76 | 141 | | |
77 | | - | |
78 | 142 | | |
79 | 143 | | |
80 | 144 | | |
| |||
94 | 158 | | |
95 | 159 | | |
96 | 160 | | |
| 161 | + | |
| 162 | + | |
97 | 163 | | |
98 | | - | |
99 | 164 | | |
100 | 165 | | |
101 | 166 | | |
102 | 167 | | |
103 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
104 | 173 | | |
105 | 174 | | |
106 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments