Commit 410902f
authored
## Summary
<!-- What's the purpose of the change? What does it do, and why? -->
Back in Python 3.5, the docs referred to `typing.io` as the primary
location for `IO`, `TextIO`, and `BinaryIO` and `typing.re` as the
primary location for `Pattern` and `Match`:
- https://docs.python.org/3.5/library/typing.html#typing.io
- https://docs.python.org/3.5/library/typing.html#typing.re
In Python 3.6, reference to `typing.io` and `typing.re` disappeared and
these types were importable directly from `typing`:
- https://docs.python.org/3.6/library/typing.html#typing.IO
- https://docs.python.org/3.6/library/typing.html#typing.Pattern
In Python 3.9, the `typing.io` and `typing.re` namespaces were
deprecated pending removal in Python 3.12. In addition, `typing.Pattern`
and `typing.Match` were deprecated in favour of `re.Pattern` and
`re.Match`:
- https://docs.python.org/3.9/library/typing.html#typing.IO
- https://docs.python.org/3.9/library/typing.html#typing.Pattern
Although interestingly it implies that the deprecation of the namespaces
was from Python 3.8.
The pending removal version for the namespaces was updated from 3.12 to
3.13 as the deprecation warning was only in place from 3.11 - that
update was backported through 3.10:
- https://docs.python.org/3.10/library/typing.html#typing.IO
- https://docs.python.org/3.10/library/typing.html#typing.Pattern
The namespaces were removed in Python 3.13:
- https://docs.python.org/3.13/library/typing.html#typing.IO
- https://docs.python.org/3.13/library/typing.html#typing.Pattern
On this basis, it seems we could update `UP035` for the `typing.io` and
`typing.re` namespaces to target as far back as Python 3.6 as they
weren't even mentioned in the docs for Python 3.6 to 3.8 and only
mentioned again when soft deprecated in Python 3.9. The versions of
these types in the main `typing` module have been available the whole
time. As ruff only targets 3.7+, let's go for 3.7.
## Test Plan
<!-- How was it tested? -->
Updated snapshots.
1 parent 729610a commit 410902f
File tree
3 files changed
+128
-3
lines changed- crates/ruff_linter
- resources/test/fixtures/pyupgrade
- src/rules/pyupgrade
- rules
- snapshots
3 files changed
+128
-3
lines changedLines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| |||
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
221 | 230 | | |
222 | 231 | | |
223 | 232 | | |
| |||
268 | 277 | | |
269 | 278 | | |
270 | 279 | | |
271 | | - | |
| 280 | + | |
272 | 281 | | |
273 | 282 | | |
274 | 283 | | |
| |||
592 | 601 | | |
593 | 602 | | |
594 | 603 | | |
595 | | - | |
596 | | - | |
| 604 | + | |
| 605 | + | |
597 | 606 | | |
598 | 607 | | |
599 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
600 | 620 | | |
601 | 621 | | |
602 | 622 | | |
| |||
Lines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1163 | 1163 | | |
1164 | 1164 | | |
1165 | 1165 | | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
0 commit comments