Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commit88557bc
committed
Have git module use sys.platform to check for Windows
This changes the way code throughout the git module checks to seeif it is running on a native Windows system.Some checks using os.name were already changed to use sys.platformindc95a76 and4191f7d. (Seedc95a76 on why the specific questionof whether the system is native Windows can be answered by eitherchecking os.name or sys.platform, even though in general theydiffer in granularity and are not always suited to the same tasks.)The reasons for this change are:- Consistency: Due todc95a76 and4191f7d, some of these checks use sys.platform, so in the absence of a reason to do otherwise, it is best that they all do. Otherwise, it creates an appearance that the technical reasons behind the difference are stronger than they really are, or even that differnt things are being checked.- Better static typing: mypy treats sys.platform as a constant (and also allows checking on platform on another via --platform). Likewise, typeshed conditions platform-dependent declarations on sys.platform checks, rather than os.name or other checks. Really this is the original reason for those earlier, more selective changes, but here the goal is more general, since this is not needed to address any specific preexisting mypy errors.This is incomplete, for two reasons:- I'm deliberately not including changes in the tests in this commit. Arguably it should be kept as os.name in the tests, on the grounds that the test suite is not currently statically typed anyway, plus having them differ more compellingly shows that the behavior is the same whether an os.name or sys.platform check is used. However, it would be confusing to keep them different, and also somewhat unnatural; one approach would probably end up leaking through. Furthermore, because some tests have to check for cygwin specifically, which cannot be done with os.name, it may be clearer to use sys.platform for all platform checking in the test suite. But to verify and demonstrate that the change really is safe, I'm waiting to make the change in the tests until after making them in the code under test.- Some forms of checks against constants produce unreachable code errors from mypy (python/mypy#10773). This can be worked around, but I have not done that in this commit. Furthermore, the new mypy errors this produces--one on Windows, and one on non-Windows systems--could be fixed in a way that makes type annotations richer, by allowing the return type to be a literal on one platform or the other.1 parent2decbe4 commit88557bc
6 files changed
+21
-15
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
246 | 246 |
| |
247 | 247 |
| |
248 | 248 |
| |
249 |
| - | |
| 249 | + | |
250 | 250 |
| |
251 | 251 |
| |
252 | 252 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| 16 | + | |
16 | 17 |
| |
17 | 18 |
| |
18 | 19 |
| |
| |||
107 | 108 |
| |
108 | 109 |
| |
109 | 110 |
| |
110 |
| - | |
| 111 | + | |
111 | 112 |
| |
112 | 113 |
| |
113 | 114 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
| |||
99 | 100 |
| |
100 | 101 |
| |
101 | 102 |
| |
102 |
| - | |
| 103 | + | |
103 | 104 |
| |
104 | 105 |
| |
105 | 106 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
| |||
401 | 402 |
| |
402 | 403 |
| |
403 | 404 |
| |
404 |
| - | |
| 405 | + | |
405 | 406 |
| |
406 | 407 |
| |
407 | 408 |
| |
|
Lines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
15 | 16 |
| |
16 | 17 |
| |
17 | 18 |
| |
| |||
336 | 337 |
| |
337 | 338 |
| |
338 | 339 |
| |
339 |
| - | |
| 340 | + | |
340 | 341 |
| |
341 | 342 |
| |
342 |
| - | |
| 343 | + | |
343 | 344 |
| |
344 | 345 |
| |
345 | 346 |
| |
| |||
618 | 619 |
| |
619 | 620 |
| |
620 | 621 |
| |
621 |
| - | |
| 622 | + | |
622 | 623 |
| |
623 | 624 |
| |
624 | 625 |
| |
|
Lines changed: 10 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
120 |
| - | |
| 120 | + | |
121 | 121 |
| |
122 | 122 |
| |
123 | 123 |
| |
| |||
223 | 223 |
| |
224 | 224 |
| |
225 | 225 |
| |
226 |
| - | |
| 226 | + | |
227 | 227 |
| |
228 | 228 |
| |
229 | 229 |
| |
| |||
235 | 235 |
| |
236 | 236 |
| |
237 | 237 |
| |
238 |
| - | |
| 238 | + | |
239 | 239 |
| |
240 | 240 |
| |
241 | 241 |
| |
| |||
276 | 276 |
| |
277 | 277 |
| |
278 | 278 |
| |
279 |
| - | |
| 279 | + | |
280 | 280 |
| |
281 | 281 |
| |
282 | 282 |
| |
| |||
328 | 328 |
| |
329 | 329 |
| |
330 | 330 |
| |
331 |
| - | |
| 331 | + | |
332 | 332 |
| |
333 | 333 |
| |
334 | 334 |
| |
| |||
354 | 354 |
| |
355 | 355 |
| |
356 | 356 |
| |
357 |
| - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
358 | 360 |
| |
359 | 361 |
| |
360 | 362 |
| |
| |||
451 | 453 |
| |
452 | 454 |
| |
453 | 455 |
| |
454 |
| - | |
455 |
| - | |
| 456 | + | |
| 457 | + | |
456 | 458 |
| |
457 | 459 |
| |
458 | 460 |
| |
|
0 commit comments
Comments
(0)