Commit 7ad6c89
committed
Complete type stubs for
mypy 1.20 (python/mypy#20350) changes how it types the return value of
functions that return `None`: previously it used `Any` (suppressing downstream
errors), now it propagates the actual `None` type. This means the existing
`-> None` annotation on `assertTemplateUsed` / `assertTemplateNotUsed` causes
type errors when these functions are used as context managers.
This adds `@overload` signatures to distinguish the two calling conventions,
matching the pattern already used by `assertNumQueries` in this file:
* `response` is `HttpResponseBase`: direct assertion, returns `None`
* `response` is a `str` (shorthand for `template_name`): returns context manager
* `response` is `None` (`template_name` passed by keyword): returns context managerassertTemplateUsed / assertTemplateNotUsed
1 parent 587b65f commit 7ad6c89
1 file changed
+52
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
115 | 142 | | |
116 | 143 | | |
117 | 144 | | |
118 | 145 | | |
119 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
120 | 171 | | |
121 | 172 | | |
122 | 173 | | |
123 | 174 | | |
124 | 175 | | |
125 | 176 | | |
126 | | - | |
| 177 | + | |
127 | 178 | | |
128 | 179 | | |
129 | 180 | | |
| |||
0 commit comments